mirror of
https://github.com/vale981/poetry2nix
synced 2025-03-04 08:41:42 -05:00
Merge pull request #758 from cpcloud/check-groups
add support for specifying dependency groups that are checkPhase-only
This commit is contained in:
commit
2de794a0df
7 changed files with 195 additions and 4 deletions
12
default.nix
12
default.nix
|
@ -27,6 +27,7 @@ let
|
|||
, attrs
|
||||
, includeBuildSystem ? true
|
||||
, groups ? [ ]
|
||||
, checkGroups ? [ "dev" ]
|
||||
}:
|
||||
let
|
||||
getInputs = attr: attrs.${attr} or [ ];
|
||||
|
@ -73,7 +74,8 @@ let
|
|||
nativeBuildInputs = mkInput "nativeBuildInputs" [ ];
|
||||
checkInputs = mkInput "checkInputs" (
|
||||
getDeps (pyProject.tool.poetry."dev-dependencies" or { }) # <poetry-1.2.0
|
||||
++ getDeps (pyProject.tool.poetry.group."dev".dependencies or { }) # >=poetry-1.2.0
|
||||
# >=poetry-1.2.0 dependency groups
|
||||
++ lib.flatten (map (g: getDeps (pyProject.tool.poetry.group.${g}.dependencies or { })) checkGroups)
|
||||
);
|
||||
};
|
||||
|
||||
|
@ -131,6 +133,7 @@ lib.makeScope pkgs.newScope (self: {
|
|||
, editablePackageSources ? { }
|
||||
, pyProject ? readTOML pyproject
|
||||
, groups ? [ ]
|
||||
, checkGroups ? [ "dev" ]
|
||||
}:
|
||||
let
|
||||
/* The default list of poetry2nix override overlays */
|
||||
|
@ -257,7 +260,7 @@ lib.makeScope pkgs.newScope (self: {
|
|||
packageOverrides = lib.foldr lib.composeExtensions (self: super: { }) overlays;
|
||||
py = python.override { inherit packageOverrides; self = py; };
|
||||
|
||||
inputAttrs = mkInputAttrs { inherit py pyProject groups; attrs = { }; includeBuildSystem = false; };
|
||||
inputAttrs = mkInputAttrs { inherit py pyProject groups checkGroups; attrs = { }; includeBuildSystem = false; };
|
||||
|
||||
requiredPythonModules = python.pkgs.requiredPythonModules;
|
||||
/* Include all the nested dependencies which are required for each package.
|
||||
|
@ -359,11 +362,12 @@ lib.makeScope pkgs.newScope (self: {
|
|||
, pwd ? projectDir
|
||||
, preferWheels ? false
|
||||
, groups ? [ ]
|
||||
, checkGroups ? [ "dev" ]
|
||||
, ...
|
||||
}@attrs:
|
||||
let
|
||||
poetryPython = self.mkPoetryPackages {
|
||||
inherit pyproject poetrylock overrides python pwd preferWheels groups;
|
||||
inherit pyproject poetrylock overrides python pwd preferWheels groups checkGroups;
|
||||
};
|
||||
py = poetryPython.python;
|
||||
|
||||
|
@ -378,7 +382,7 @@ lib.makeScope pkgs.newScope (self: {
|
|||
];
|
||||
passedAttrs = builtins.removeAttrs attrs specialAttrs;
|
||||
|
||||
inputAttrs = mkInputAttrs { inherit py pyProject attrs groups; };
|
||||
inputAttrs = mkInputAttrs { inherit py pyProject attrs groups checkGroups; };
|
||||
|
||||
app = py.pkgs.buildPythonPackage (
|
||||
passedAttrs // inputAttrs // {
|
||||
|
|
|
@ -126,5 +126,6 @@ builtins.removeAttrs
|
|||
setuptools = callTest ./setuptools { };
|
||||
|
||||
scientific = callTest ./scientific { };
|
||||
test-group = callTest ./test-group { };
|
||||
}
|
||||
skipTests
|
||||
|
|
15
tests/test-group/default.nix
Normal file
15
tests/test-group/default.nix
Normal file
|
@ -0,0 +1,15 @@
|
|||
{ lib, poetry2nix, python310 }:
|
||||
|
||||
poetry2nix.mkPoetryApplication {
|
||||
python = python310;
|
||||
pyproject = ./pyproject.toml;
|
||||
poetrylock = ./poetry.lock;
|
||||
src = lib.cleanSource ./.;
|
||||
checkGroups = [ "test" ];
|
||||
|
||||
checkPhase = ''
|
||||
runHook preCheck
|
||||
pytest
|
||||
runHook postCheck
|
||||
'';
|
||||
}
|
151
tests/test-group/poetry.lock
generated
Normal file
151
tests/test-group/poetry.lock
generated
Normal file
|
@ -0,0 +1,151 @@
|
|||
[[package]]
|
||||
name = "atomicwrites"
|
||||
version = "1.4.1"
|
||||
description = "Atomic file writes."
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
|
||||
|
||||
[[package]]
|
||||
name = "attrs"
|
||||
version = "22.1.0"
|
||||
description = "Classes Without Boilerplate"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.5"
|
||||
|
||||
[package.extras]
|
||||
dev = ["cloudpickle", "coverage[toml] (>=5.0.2)", "furo", "hypothesis", "mypy (>=0.900,!=0.940)", "pre-commit", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "sphinx", "sphinx-notfound-page", "zope.interface"]
|
||||
docs = ["furo", "sphinx", "sphinx-notfound-page", "zope.interface"]
|
||||
tests = ["cloudpickle", "coverage[toml] (>=5.0.2)", "hypothesis", "mypy (>=0.900,!=0.940)", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "zope.interface"]
|
||||
tests_no_zope = ["cloudpickle", "coverage[toml] (>=5.0.2)", "hypothesis", "mypy (>=0.900,!=0.940)", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins"]
|
||||
|
||||
[[package]]
|
||||
name = "colorama"
|
||||
version = "0.4.5"
|
||||
description = "Cross-platform colored terminal text."
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
|
||||
|
||||
[[package]]
|
||||
name = "iniconfig"
|
||||
version = "1.1.1"
|
||||
description = "iniconfig: brain-dead simple config-ini parsing"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
|
||||
[[package]]
|
||||
name = "packaging"
|
||||
version = "21.3"
|
||||
description = "Core utilities for Python packages"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.6"
|
||||
|
||||
[package.dependencies]
|
||||
pyparsing = ">=2.0.2,<3.0.5 || >3.0.5"
|
||||
|
||||
[[package]]
|
||||
name = "pluggy"
|
||||
version = "1.0.0"
|
||||
description = "plugin and hook calling mechanisms for python"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.6"
|
||||
|
||||
[package.extras]
|
||||
dev = ["pre-commit", "tox"]
|
||||
testing = ["pytest", "pytest-benchmark"]
|
||||
|
||||
[[package]]
|
||||
name = "py"
|
||||
version = "1.11.0"
|
||||
description = "library with cross-python path, ini-parsing, io, code, log facilities"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
|
||||
|
||||
[[package]]
|
||||
name = "pyparsing"
|
||||
version = "2.4.7"
|
||||
description = "Python parsing module"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*"
|
||||
|
||||
[[package]]
|
||||
name = "pytest"
|
||||
version = "6.2.5"
|
||||
description = "pytest: simple powerful testing with Python"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.6"
|
||||
|
||||
[package.dependencies]
|
||||
atomicwrites = {version = ">=1.0", markers = "sys_platform == \"win32\""}
|
||||
attrs = ">=19.2.0"
|
||||
colorama = {version = "*", markers = "sys_platform == \"win32\""}
|
||||
iniconfig = "*"
|
||||
packaging = "*"
|
||||
pluggy = ">=0.12,<2.0"
|
||||
py = ">=1.8.2"
|
||||
toml = "*"
|
||||
|
||||
[package.extras]
|
||||
testing = ["argcomplete", "hypothesis (>=3.56)", "mock", "nose", "requests", "xmlschema"]
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.10.2"
|
||||
description = "Python Library for Tom's Obvious, Minimal Language"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*"
|
||||
|
||||
[metadata]
|
||||
lock-version = "1.1"
|
||||
python-versions = "^3.9"
|
||||
content-hash = "2fd243de99be3be1eadebcda05039a76a1813a6af6f00fbaaceed881e0c0f15b"
|
||||
|
||||
[metadata.files]
|
||||
atomicwrites = [
|
||||
{file = "atomicwrites-1.4.1.tar.gz", hash = "sha256:81b2c9071a49367a7f770170e5eec8cb66567cfbbc8c73d20ce5ca4a8d71cf11"},
|
||||
]
|
||||
attrs = [
|
||||
{file = "attrs-22.1.0-py2.py3-none-any.whl", hash = "sha256:86efa402f67bf2df34f51a335487cf46b1ec130d02b8d39fd248abfd30da551c"},
|
||||
{file = "attrs-22.1.0.tar.gz", hash = "sha256:29adc2665447e5191d0e7c568fde78b21f9672d344281d0c6e1ab085429b22b6"},
|
||||
]
|
||||
colorama = [
|
||||
{file = "colorama-0.4.5-py2.py3-none-any.whl", hash = "sha256:854bf444933e37f5824ae7bfc1e98d5bce2ebe4160d46b5edf346a89358e99da"},
|
||||
{file = "colorama-0.4.5.tar.gz", hash = "sha256:e6c6b4334fc50988a639d9b98aa429a0b57da6e17b9a44f0451f930b6967b7a4"},
|
||||
]
|
||||
iniconfig = [
|
||||
{file = "iniconfig-1.1.1-py2.py3-none-any.whl", hash = "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3"},
|
||||
{file = "iniconfig-1.1.1.tar.gz", hash = "sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32"},
|
||||
]
|
||||
packaging = [
|
||||
{file = "packaging-21.3-py3-none-any.whl", hash = "sha256:ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522"},
|
||||
{file = "packaging-21.3.tar.gz", hash = "sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb"},
|
||||
]
|
||||
pluggy = [
|
||||
{file = "pluggy-1.0.0-py2.py3-none-any.whl", hash = "sha256:74134bbf457f031a36d68416e1509f34bd5ccc019f0bcc952c7b909d06b37bd3"},
|
||||
{file = "pluggy-1.0.0.tar.gz", hash = "sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159"},
|
||||
]
|
||||
py = [
|
||||
{file = "py-1.11.0-py2.py3-none-any.whl", hash = "sha256:607c53218732647dff4acdfcd50cb62615cedf612e72d1724fb1a0cc6405b378"},
|
||||
{file = "py-1.11.0.tar.gz", hash = "sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719"},
|
||||
]
|
||||
pyparsing = [
|
||||
{file = "pyparsing-2.4.7-py2.py3-none-any.whl", hash = "sha256:ef9d7589ef3c200abe66653d3f1ab1033c3c419ae9b9bdb1240a85b024efc88b"},
|
||||
{file = "pyparsing-2.4.7.tar.gz", hash = "sha256:c203ec8783bf771a155b207279b9bccb8dea02d8f0c9e5f8ead507bc3246ecc1"},
|
||||
]
|
||||
pytest = [
|
||||
{file = "pytest-6.2.5-py3-none-any.whl", hash = "sha256:7310f8d27bc79ced999e760ca304d69f6ba6c6649c0b60fb0e04a4a77cacc134"},
|
||||
{file = "pytest-6.2.5.tar.gz", hash = "sha256:131b36680866a76e6781d13f101efb86cf674ebb9762eb70d3082b6f29889e89"},
|
||||
]
|
||||
toml = [
|
||||
{file = "toml-0.10.2-py2.py3-none-any.whl", hash = "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"},
|
||||
{file = "toml-0.10.2.tar.gz", hash = "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"},
|
||||
]
|
18
tests/test-group/pyproject.toml
Normal file
18
tests/test-group/pyproject.toml
Normal file
|
@ -0,0 +1,18 @@
|
|||
[tool.poetry]
|
||||
name = "test-group"
|
||||
version = "0.1.0"
|
||||
description = ""
|
||||
authors = ["Your Name <you@example.com>"]
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.9"
|
||||
pyparsing = "^2.4.5"
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
|
||||
[tool.poetry.group.test.dependencies]
|
||||
pytest = "^6"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core>=1.1"]
|
||||
build-backend = "poetry.core.masonry.api"
|
0
tests/test-group/test_group/__init__.py
Normal file
0
tests/test-group/test_group/__init__.py
Normal file
2
tests/test-group/test_group/test_simple.py
Normal file
2
tests/test-group/test_group/test_simple.py
Normal file
|
@ -0,0 +1,2 @@
|
|||
def test_simple():
|
||||
assert True
|
Loading…
Add table
Reference in a new issue