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
|
{ src
|
||||||
, pyproject ? src + "/pyproject.toml"
|
|
||||||
, poetrylock ? src + "/poetry.lock"
|
, poetrylock ? src + "/poetry.lock"
|
||||||
, overrides ? defaultPoetryOverrides
|
, overrides ? defaultPoetryOverrides
|
||||||
, meta ? {}
|
, meta ? {}
|
||||||
, python ? pkgs.python3
|
, python ? pkgs.python3
|
||||||
, ...
|
, ...
|
||||||
}@attrs: let
|
}@attrs: let
|
||||||
pyProject = readTOML pyproject;
|
|
||||||
poetryLock = readTOML poetrylock;
|
poetryLock = readTOML poetrylock;
|
||||||
lockFiles = lib.getAttrFromPath [ "metadata" "files" ] poetryLock;
|
lockFiles = lib.getAttrFromPath [ "metadata" "files" ] poetryLock;
|
||||||
|
|
||||||
specialAttrs = [ "pyproject" "poetrylock" "overrides" ];
|
specialAttrs = [ "poetrylock" "overrides" ];
|
||||||
passedAttrs = builtins.removeAttrs attrs specialAttrs;
|
passedAttrs = builtins.removeAttrs attrs specialAttrs;
|
||||||
|
|
||||||
evalPep508 = mkEvalPep508 python;
|
evalPep508 = mkEvalPep508 python;
|
||||||
|
|
||||||
poetryPkg = poetry.override { inherit python; };
|
|
||||||
|
|
||||||
# Create an overriden version of pythonPackages
|
# Create an overriden version of pythonPackages
|
||||||
#
|
#
|
||||||
|
@ -81,13 +78,36 @@ let
|
||||||
} // nulledPkgs // lockPkgs;
|
} // nulledPkgs // lockPkgs;
|
||||||
in
|
in
|
||||||
python.override { inherit packageOverrides; self = py; };
|
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
|
getDeps = depAttr: let
|
||||||
deps = getAttrDefault depAttr pyProject.tool.poetry {};
|
deps = getAttrDefault depAttr pyProject.tool.poetry {};
|
||||||
depAttrs = builtins.map (d: lib.toLower d) (builtins.attrNames deps);
|
depAttrs = builtins.map (d: lib.toLower d) (builtins.attrNames deps);
|
||||||
in
|
in
|
||||||
builtins.map (dep: pythonPackages."${dep}") depAttrs;
|
builtins.map (dep: py.pkgs."${dep}") depAttrs;
|
||||||
|
|
||||||
getInputs = attr: getAttrDefault attr attrs [];
|
getInputs = attr: getAttrDefault attr attrs [];
|
||||||
mkInput = attr: extraInputs: getInputs attr ++ extraInputs;
|
mkInput = attr: extraInputs: getInputs attr ++ extraInputs;
|
||||||
|
@ -103,7 +123,7 @@ let
|
||||||
in
|
in
|
||||||
knownBuildSystems.${buildSystem} or (throw "unsupported build system ${buildSystem}");
|
knownBuildSystems.${buildSystem} or (throw "unsupported build system ${buildSystem}");
|
||||||
in
|
in
|
||||||
pythonPackages.buildPythonApplication (
|
py.pkgs.buildPythonApplication (
|
||||||
passedAttrs // {
|
passedAttrs // {
|
||||||
pname = pyProject.tool.poetry.name;
|
pname = pyProject.tool.poetry.name;
|
||||||
version = pyProject.tool.poetry.version;
|
version = pyProject.tool.poetry.version;
|
||||||
|
@ -111,11 +131,10 @@ let
|
||||||
format = "pyproject";
|
format = "pyproject";
|
||||||
|
|
||||||
buildInputs = mkInput "buildInputs" getBuildSystemPkgs;
|
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");
|
checkInputs = mkInput "checkInputs" (getDeps "dev-dependencies");
|
||||||
|
|
||||||
passthru = {
|
passthru = {
|
||||||
inherit pythonPackages;
|
|
||||||
python = py;
|
python = py;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -126,8 +145,8 @@ let
|
||||||
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
in
|
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 }:
|
{ lib, poetry2nix, python, fetchFromGitHub, runtimeShell }:
|
||||||
|
|
||||||
poetry2nix.mkPoetryPackage {
|
poetry2nix.mkPoetryApplication {
|
||||||
|
|
||||||
inherit python;
|
inherit python;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{ lib, poetry2nix, python3 }:
|
{ lib, poetry2nix, python3 }:
|
||||||
|
|
||||||
poetry2nix.mkPoetryPackage {
|
poetry2nix.mkPoetryApplication {
|
||||||
python = python3;
|
python = python3;
|
||||||
pyproject = ./pyproject.toml;
|
pyproject = ./pyproject.toml;
|
||||||
poetryLock = ./poetry.lock;
|
poetryLock = ./poetry.lock;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{ lib, poetry2nix, python3 }:
|
{ lib, poetry2nix, python3 }:
|
||||||
|
|
||||||
poetry2nix.mkPoetryPackage {
|
poetry2nix.mkPoetryApplication {
|
||||||
python = python3;
|
python = python3;
|
||||||
pyproject = ./pyproject.toml;
|
pyproject = ./pyproject.toml;
|
||||||
poetryLock = ./poetry.lock;
|
poetryLock = ./poetry.lock;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{ runCommand, lib, poetry2nix, python3 }:
|
{ runCommand, lib, poetry2nix, python3 }:
|
||||||
|
|
||||||
let
|
let
|
||||||
pkg = poetry2nix.mkPoetryPackage {
|
pkg = poetry2nix.mkPoetryApplication {
|
||||||
python = python3;
|
python = python3;
|
||||||
pyproject = ./pyproject.toml;
|
pyproject = ./pyproject.toml;
|
||||||
poetryLock = ./poetry.lock;
|
poetryLock = ./poetry.lock;
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
{ lib, python3, poetry2nix, runCommand }:
|
{ lib, python3, poetry2nix, runCommand }:
|
||||||
|
|
||||||
let
|
let
|
||||||
pyApp = poetry2nix.mkPoetryPackage {
|
python = poetry2nix.mkPoetryPython {
|
||||||
python = python3;
|
python = python3;
|
||||||
pyproject = ./pyproject.toml;
|
|
||||||
poetryLock = ./poetry.lock;
|
poetryLock = ./poetry.lock;
|
||||||
src = lib.cleanSource ./.;
|
src = lib.cleanSource ./.;
|
||||||
overrides = poetry2nix.defaultPoetryOverrides // {
|
overrides = poetry2nix.defaultPoetryOverrides // {
|
||||||
|
@ -16,7 +15,7 @@ let
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
runCommand "test" {} ''
|
runCommand "test" {} ''
|
||||||
x=${builtins.toString (pyApp.pythonPackages.alembic.TESTING_FOOBAR)}
|
x=${builtins.toString (python.pkgs.alembic.TESTING_FOOBAR)}
|
||||||
[ "$x" = "42" ] || exit 1
|
[ "$x" = "42" ] || exit 1
|
||||||
mkdir $out
|
mkdir $out
|
||||||
''
|
''
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{ lib, poetry2nix, python3 }:
|
{ lib, poetry2nix, python3 }:
|
||||||
|
|
||||||
poetry2nix.mkPoetryPackage {
|
poetry2nix.mkPoetryApplication {
|
||||||
python = python3;
|
python = python3;
|
||||||
pyproject = ./pyproject.toml;
|
pyproject = ./pyproject.toml;
|
||||||
poetryLock = ./poetry.lock;
|
poetryLock = ./poetry.lock;
|
||||||
|
|
Loading…
Add table
Reference in a new issue