mirror of
https://github.com/vale981/poetry2nix
synced 2025-03-04 16:51:40 -05:00
split mkPoetryPackage into mkPoetryPython and mkPoetryApplication
This commit is contained in:
parent
84f27ee31d
commit
d8fde74219
7 changed files with 38 additions and 20 deletions
43
default.nix
43
default.nix
|
@ -21,25 +21,22 @@ let
|
|||
);
|
||||
|
||||
|
||||
mkPoetryPackage =
|
||||
mkPoetryPython =
|
||||
{ src
|
||||
, pyproject ? src + "/pyproject.toml"
|
||||
, poetrylock ? src + "/poetry.lock"
|
||||
, overrides ? defaultPoetryOverrides
|
||||
, meta ? {}
|
||||
, python ? pkgs.python3
|
||||
, ...
|
||||
}@attrs: let
|
||||
pyProject = readTOML pyproject;
|
||||
poetryLock = readTOML poetrylock;
|
||||
lockFiles = lib.getAttrFromPath [ "metadata" "files" ] poetryLock;
|
||||
|
||||
specialAttrs = [ "pyproject" "poetrylock" "overrides" ];
|
||||
specialAttrs = [ "poetrylock" "overrides" ];
|
||||
passedAttrs = builtins.removeAttrs attrs specialAttrs;
|
||||
|
||||
evalPep508 = mkEvalPep508 python;
|
||||
|
||||
poetryPkg = poetry.override { inherit python; };
|
||||
|
||||
# Create an overriden version of pythonPackages
|
||||
#
|
||||
|
@ -81,13 +78,36 @@ let
|
|||
} // nulledPkgs // lockPkgs;
|
||||
in
|
||||
python.override { inherit packageOverrides; self = py; };
|
||||
pythonPackages = py.pkgs;
|
||||
in
|
||||
py;
|
||||
|
||||
mkPoetryApplication =
|
||||
{ src
|
||||
, pyproject ? src + "/pyproject.toml"
|
||||
, poetrylock ? src + "/poetry.lock"
|
||||
, overrides ? defaultPoetryOverrides
|
||||
, meta ? {}
|
||||
, python ? pkgs.python3
|
||||
, ...
|
||||
}@attrs: let
|
||||
poetryPkg = poetry.override { inherit python; };
|
||||
|
||||
py = mkPoetryPython (
|
||||
{
|
||||
inherit src pyproject poetrylock overrides meta python;
|
||||
} // attrs
|
||||
);
|
||||
|
||||
pyProject = readTOML pyproject;
|
||||
|
||||
specialAttrs = [ "pyproject" "poetrylock" "overrides" ];
|
||||
passedAttrs = builtins.removeAttrs attrs specialAttrs;
|
||||
|
||||
getDeps = depAttr: let
|
||||
deps = getAttrDefault depAttr pyProject.tool.poetry {};
|
||||
depAttrs = builtins.map (d: lib.toLower d) (builtins.attrNames deps);
|
||||
in
|
||||
builtins.map (dep: pythonPackages."${dep}") depAttrs;
|
||||
builtins.map (dep: py.pkgs."${dep}") depAttrs;
|
||||
|
||||
getInputs = attr: getAttrDefault attr attrs [];
|
||||
mkInput = attr: extraInputs: getInputs attr ++ extraInputs;
|
||||
|
@ -103,7 +123,7 @@ let
|
|||
in
|
||||
knownBuildSystems.${buildSystem} or (throw "unsupported build system ${buildSystem}");
|
||||
in
|
||||
pythonPackages.buildPythonApplication (
|
||||
py.pkgs.buildPythonApplication (
|
||||
passedAttrs // {
|
||||
pname = pyProject.tool.poetry.name;
|
||||
version = pyProject.tool.poetry.version;
|
||||
|
@ -111,11 +131,10 @@ let
|
|||
format = "pyproject";
|
||||
|
||||
buildInputs = mkInput "buildInputs" getBuildSystemPkgs;
|
||||
propagatedBuildInputs = mkInput "propagatedBuildInputs" (getDeps "dependencies") ++ ([ pythonPackages.setuptools ]);
|
||||
propagatedBuildInputs = mkInput "propagatedBuildInputs" (getDeps "dependencies") ++ ([ py.pkgs.setuptools ]);
|
||||
checkInputs = mkInput "checkInputs" (getDeps "dev-dependencies");
|
||||
|
||||
passthru = {
|
||||
inherit pythonPackages;
|
||||
python = py;
|
||||
};
|
||||
|
||||
|
@ -126,8 +145,8 @@ let
|
|||
|
||||
}
|
||||
);
|
||||
|
||||
in
|
||||
{
|
||||
inherit mkPoetryPackage defaultPoetryOverrides;
|
||||
inherit mkPoetryPython mkPoetryApplication defaultPoetryOverrides;
|
||||
mkPoetryPackage = attrs: builtins.trace "mkPoetryPackage is deprecated. Use mkPoetryApplication instead." (mkPoetryApplication attrs);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{ lib, poetry2nix, python, fetchFromGitHub, runtimeShell }:
|
||||
|
||||
poetry2nix.mkPoetryPackage {
|
||||
poetry2nix.mkPoetryApplication {
|
||||
|
||||
inherit python;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{ lib, poetry2nix, python3 }:
|
||||
|
||||
poetry2nix.mkPoetryPackage {
|
||||
poetry2nix.mkPoetryApplication {
|
||||
python = python3;
|
||||
pyproject = ./pyproject.toml;
|
||||
poetryLock = ./poetry.lock;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{ lib, poetry2nix, python3 }:
|
||||
|
||||
poetry2nix.mkPoetryPackage {
|
||||
poetry2nix.mkPoetryApplication {
|
||||
python = python3;
|
||||
pyproject = ./pyproject.toml;
|
||||
poetryLock = ./poetry.lock;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{ runCommand, lib, poetry2nix, python3 }:
|
||||
|
||||
let
|
||||
pkg = poetry2nix.mkPoetryPackage {
|
||||
pkg = poetry2nix.mkPoetryApplication {
|
||||
python = python3;
|
||||
pyproject = ./pyproject.toml;
|
||||
poetryLock = ./poetry.lock;
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
{ lib, python3, poetry2nix, runCommand }:
|
||||
|
||||
let
|
||||
pyApp = poetry2nix.mkPoetryPackage {
|
||||
python = poetry2nix.mkPoetryPython {
|
||||
python = python3;
|
||||
pyproject = ./pyproject.toml;
|
||||
poetryLock = ./poetry.lock;
|
||||
src = lib.cleanSource ./.;
|
||||
overrides = poetry2nix.defaultPoetryOverrides // {
|
||||
|
@ -16,7 +15,7 @@ let
|
|||
};
|
||||
in
|
||||
runCommand "test" {} ''
|
||||
x=${builtins.toString (pyApp.pythonPackages.alembic.TESTING_FOOBAR)}
|
||||
x=${builtins.toString (python.pkgs.alembic.TESTING_FOOBAR)}
|
||||
[ "$x" = "42" ] || exit 1
|
||||
mkdir $out
|
||||
''
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{ lib, poetry2nix, python3 }:
|
||||
|
||||
poetry2nix.mkPoetryPackage {
|
||||
poetry2nix.mkPoetryApplication {
|
||||
python = python3;
|
||||
pyproject = ./pyproject.toml;
|
||||
poetryLock = ./poetry.lock;
|
||||
|
|
Loading…
Add table
Reference in a new issue