-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from sahajsoft/poetry-improvements
Poetry improvements
- Loading branch information
Showing
21 changed files
with
2,154 additions
and
2,015 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,97 @@ | ||
{ | ||
description = "Application packaged using poetry2nix"; | ||
|
||
inputs = { | ||
flake-utils.url = "github:numtide/flake-utils"; | ||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; | ||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05-small"; | ||
poetry2nix = { | ||
url = "github:nix-community/poetry2nix"; | ||
inputs.nixpkgs.follows = "nixpkgs"; | ||
inputs.flake-utils.follows = "flake-utils"; | ||
}; | ||
}; | ||
|
||
outputs = { self, nixpkgs, flake-utils, poetry2nix }: | ||
flake-utils.lib.eachDefaultSystem (system: | ||
outputs = | ||
{ | ||
self, | ||
nixpkgs, | ||
flake-utils, | ||
poetry2nix, | ||
}: | ||
flake-utils.lib.eachDefaultSystem ( | ||
system: | ||
let | ||
|
||
pypkgs-build-requirements = { | ||
conllu = [ "setuptools" ]; | ||
janome = [ "setuptools" ]; | ||
pptree = [ "setuptools" ]; | ||
confection = [ "setuptools" ]; | ||
ftfy = [ "hatchling" ]; | ||
segtok = [ "setuptools" ]; | ||
wikipedia-api = [ "setuptools" ]; | ||
presidio-vault = [ "poetry" ]; | ||
safetensors = [ "maturin" ]; | ||
}; | ||
p2n-overrides = pkgs.poetry2nix.defaultPoetryOverrides.extend ( | ||
final: prev: | ||
builtins.mapAttrs ( | ||
package: build-requirements: | ||
(builtins.getAttr package prev).overridePythonAttrs (old: { | ||
buildInputs = | ||
(old.buildInputs or [ ]) | ||
++ (builtins.map ( | ||
pkg: if builtins.isString pkg then builtins.getAttr pkg prev else pkg | ||
) build-requirements); | ||
}) | ||
) pypkgs-build-requirements | ||
); | ||
myapp = | ||
{ poetry2nix, lib }: | ||
poetry2nix.mkPoetryApplication { | ||
projectDir = self; | ||
overrides = p2n-overrides; | ||
preferWheels = true; | ||
}; | ||
pkgs = import nixpkgs { | ||
inherit system; | ||
config.allowUnfree = true; # needed for vault | ||
config.allowUnfree = true; | ||
overlays = [ | ||
poetry2nix.overlays.default | ||
(final: _: { myapp = final.callPackage myapp { }; }) | ||
]; | ||
}; | ||
nativeBuildInputs = with pkgs; [ | ||
stdenv | ||
python311 | ||
poetry | ||
zlib | ||
tesseract | ||
]; | ||
buildInputs = with pkgs; [ vault jq ]; | ||
in | ||
{ | ||
packages.default = pkgs.myapp; | ||
|
||
# see https://github.com/nix-community/poetry2nix/tree/master#api for more functions and examples. | ||
inherit (poetry2nix.lib.mkPoetry2Nix { inherit pkgs; }) | ||
mkPoetryApplication; | ||
in { | ||
inherit nativeBuildInputs buildInputs; | ||
|
||
packages = { | ||
myapp = mkPoetryApplication { | ||
projectDir = self; | ||
python = pkgs.python311; | ||
}; | ||
default = self.packages.${system}.myapp; | ||
apps.default = { | ||
type = "app"; | ||
program = "${pkgs.myapp}/bin/cli"; | ||
}; | ||
|
||
devShells = { | ||
# Shell for app dependencies. | ||
# | ||
# nix develop | ||
# | ||
# Use this shell for developing your app. | ||
default = pkgs.mkShell { | ||
packages = nativeBuildInputs ++ buildInputs; | ||
LD_LIBRARY_PATH = if pkgs.stdenv.isLinux then | ||
"${ | ||
pkgs.lib.makeLibraryPath nativeBuildInputs | ||
}:${pkgs.stdenv.cc.cc.lib}/lib:/run/opengl-driver/lib:/run/opengl-driver-32/lib" | ||
else | ||
"$LD_LIBRARY_PATH"; | ||
inputsFrom = [ pkgs.myapp ]; | ||
packages = [ | ||
pkgs.vault | ||
pkgs.jq | ||
]; | ||
}; | ||
|
||
# Shell for poetry. | ||
# | ||
# nix develop .#poetry | ||
# | ||
# Use this shell for changes to pyproject.toml and poetry.lock. | ||
poetry = pkgs.mkShell { packages = [ pkgs.poetry ]; }; | ||
}; | ||
}); | ||
legacyPackages = pkgs; | ||
} | ||
); | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from pii_detection_and_anonymizer.cli import main | ||
|
||
if __name__ == "__main__": | ||
main() |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.