From 8a8d3b27411cd0cc22183f1cd6308639f1a4e356 Mon Sep 17 00:00:00 2001 From: adisbladis Date: Tue, 10 Sep 2024 12:23:04 +1200 Subject: [PATCH] pep508.parseMarkers: Make platform_release a distinct type `platform_release` parsing is more complicated than other fields. It can be either a PEP-440 version, or a non-compliant version string. If both lhs and rhs were correctly parsed as PEP-440 versions run regular version comparison, otherwise compare lexicographically See: - https://github.com/pypa/packaging/issues/774 - https://github.com/astral-sh/uv/issues/3917#issuecomment-2141754917 --- .../pep508.mkEnviron.testPypy3Linux.json | 81 + .../pep508.mkEnviron.testPython311Darwin.json | 81 + ....mkEnviron.testPython311DarwinAarch64.json | 81 + .../pep508.mkEnviron.testPython38Linux.json | 81 + ...oetry.parseDependencies.testParseDeps.json | 2059 +++++++++++++++++ ...oject.loadPyprojectDynamic.testPoetry.json | 220 ++ lib/pep440.nix | 19 +- lib/pep508.nix | 63 +- lib/poetry.nix | 7 +- lib/test_pep440.nix | 16 + lib/test_pep508.nix | 358 +-- lib/test_pep621/default.nix | 2 + .../expected/parsedependencies-pandas.nix | 87 + .../expected/parsedependencies-pdm.nix | 22 + lib/test_pip.nix | 4 + lib/test_poetry.nix | 1977 +--------------- lib/test_project.nix | 2 + lib/test_validators.nix | 2 + 18 files changed, 2901 insertions(+), 2261 deletions(-) create mode 100644 lib/expected/pep508.mkEnviron.testPypy3Linux.json create mode 100644 lib/expected/pep508.mkEnviron.testPython311Darwin.json create mode 100644 lib/expected/pep508.mkEnviron.testPython311DarwinAarch64.json create mode 100644 lib/expected/pep508.mkEnviron.testPython38Linux.json create mode 100644 lib/expected/poetry.parseDependencies.testParseDeps.json create mode 100644 lib/expected/project.loadPyprojectDynamic.testPoetry.json diff --git a/lib/expected/pep508.mkEnviron.testPypy3Linux.json b/lib/expected/pep508.mkEnviron.testPypy3Linux.json new file mode 100644 index 0000000..4a4ac25 --- /dev/null +++ b/lib/expected/pep508.mkEnviron.testPypy3Linux.json @@ -0,0 +1,81 @@ +{ + "implementation_name": { + "type": "string", + "value": "pypy" + }, + "implementation_version": { + "type": "version", + "value": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 7, + 3, + 11 + ], + "str": "7.3.11" + } + }, + "os_name": { + "type": "string", + "value": "posix" + }, + "platform_machine": { + "type": "string", + "value": "x86_64" + }, + "platform_python_implementation": { + "type": "string", + "value": "PyPy" + }, + "platform_release": { + "type": "platform_release", + "value": "" + }, + "platform_system": { + "type": "string", + "value": "Linux" + }, + "platform_version": { + "type": "string", + "value": "" + }, + "python_full_version": { + "type": "version", + "value": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 7, + 3, + 11 + ], + "str": "7.3.11" + } + }, + "python_version": { + "type": "version", + "value": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 3, + 9 + ], + "str": "3.9" + } + }, + "sys_platform": { + "type": "string", + "value": "linux" + } +} diff --git a/lib/expected/pep508.mkEnviron.testPython311Darwin.json b/lib/expected/pep508.mkEnviron.testPython311Darwin.json new file mode 100644 index 0000000..393487f --- /dev/null +++ b/lib/expected/pep508.mkEnviron.testPython311Darwin.json @@ -0,0 +1,81 @@ +{ + "implementation_name": { + "type": "string", + "value": "cpython" + }, + "implementation_version": { + "type": "version", + "value": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 3, + 11, + 4 + ], + "str": "3.11.4" + } + }, + "os_name": { + "type": "string", + "value": "posix" + }, + "platform_machine": { + "type": "string", + "value": "x86_64" + }, + "platform_python_implementation": { + "type": "string", + "value": "CPython" + }, + "platform_release": { + "type": "platform_release", + "value": "" + }, + "platform_system": { + "type": "string", + "value": "Darwin" + }, + "platform_version": { + "type": "string", + "value": "" + }, + "python_full_version": { + "type": "version", + "value": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 3, + 11, + 4 + ], + "str": "3.11.4" + } + }, + "python_version": { + "type": "version", + "value": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 3, + 11 + ], + "str": "3.11" + } + }, + "sys_platform": { + "type": "string", + "value": "darwin" + } +} diff --git a/lib/expected/pep508.mkEnviron.testPython311DarwinAarch64.json b/lib/expected/pep508.mkEnviron.testPython311DarwinAarch64.json new file mode 100644 index 0000000..d781e89 --- /dev/null +++ b/lib/expected/pep508.mkEnviron.testPython311DarwinAarch64.json @@ -0,0 +1,81 @@ +{ + "implementation_name": { + "type": "string", + "value": "cpython" + }, + "implementation_version": { + "type": "version", + "value": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 3, + 11, + 4 + ], + "str": "3.11.4" + } + }, + "os_name": { + "type": "string", + "value": "posix" + }, + "platform_machine": { + "type": "string", + "value": "arm64" + }, + "platform_python_implementation": { + "type": "string", + "value": "CPython" + }, + "platform_release": { + "type": "platform_release", + "value": "" + }, + "platform_system": { + "type": "string", + "value": "Darwin" + }, + "platform_version": { + "type": "string", + "value": "" + }, + "python_full_version": { + "type": "version", + "value": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 3, + 11, + 4 + ], + "str": "3.11.4" + } + }, + "python_version": { + "type": "version", + "value": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 3, + 11 + ], + "str": "3.11" + } + }, + "sys_platform": { + "type": "string", + "value": "darwin" + } +} diff --git a/lib/expected/pep508.mkEnviron.testPython38Linux.json b/lib/expected/pep508.mkEnviron.testPython38Linux.json new file mode 100644 index 0000000..2e70c6e --- /dev/null +++ b/lib/expected/pep508.mkEnviron.testPython38Linux.json @@ -0,0 +1,81 @@ +{ + "implementation_name": { + "type": "string", + "value": "cpython" + }, + "implementation_version": { + "type": "version", + "value": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 3, + 8, + 2 + ], + "str": "3.8.2" + } + }, + "os_name": { + "type": "string", + "value": "posix" + }, + "platform_machine": { + "type": "string", + "value": "x86_64" + }, + "platform_python_implementation": { + "type": "string", + "value": "CPython" + }, + "platform_release": { + "type": "platform_release", + "value": "" + }, + "platform_system": { + "type": "string", + "value": "Linux" + }, + "platform_version": { + "type": "string", + "value": "" + }, + "python_full_version": { + "type": "version", + "value": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 3, + 8, + 2 + ], + "str": "3.8.2" + } + }, + "python_version": { + "type": "version", + "value": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 3, + 8 + ], + "str": "3.8" + } + }, + "sys_platform": { + "type": "string", + "value": "linux" + } +} diff --git a/lib/expected/poetry.parseDependencies.testParseDeps.json b/lib/expected/poetry.parseDependencies.testParseDeps.json new file mode 100644 index 0000000..d1aa6c4 --- /dev/null +++ b/lib/expected/poetry.parseDependencies.testParseDeps.json @@ -0,0 +1,2059 @@ +{ + "build-systems": [ + { + "conditions": [ + { + "op": ">=", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 1, + 1, + 0 + ], + "str": "1.1.0" + } + } + ], + "extras": [], + "markers": null, + "name": "poetry-core", + "url": null + } + ], + "dependencies": [ + { + "conditions": [ + { + "op": ">=", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 1, + 0, + 2 + ], + "str": "1.0.2" + } + }, + { + "op": "<", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 2, + 0, + 0 + ], + "str": "2.0.0" + } + } + ], + "extras": [], + "markers": { + "lhs": { + "lhs": { + "type": "variable", + "value": "python_version" + }, + "op": "<", + "rhs": { + "type": "version", + "value": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 3, + 8 + ], + "str": "3.8" + } + }, + "type": "compare" + }, + "op": "and", + "rhs": { + "type": "bool", + "value": true + }, + "type": "boolOp" + }, + "name": "backports.cached-property", + "url": null + }, + { + "conditions": [ + { + "op": ">=", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 0, + 10, + 0 + ], + "str": "0.10.0" + } + }, + { + "op": "<", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 0, + 11, + 0 + ], + "str": "0.11.0" + } + } + ], + "extras": [], + "markers": null, + "name": "build", + "url": null + }, + { + "conditions": [ + { + "op": ">=", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 0, + 12, + 9 + ], + "str": "0.12.9" + } + }, + { + "op": "<", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 0, + 13, + 0 + ], + "str": "0.13.0" + } + } + ], + "extras": [ + "filecache" + ], + "markers": null, + "name": "cachecontrol", + "url": null + }, + { + "conditions": [ + { + "op": ">=", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 2, + 0, + 0 + ], + "str": "2.0.0" + } + }, + { + "op": "<", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 3, + 0, + 0 + ], + "str": "3.0.0" + } + } + ], + "extras": [], + "markers": null, + "name": "cleo", + "url": null + }, + { + "conditions": [ + { + "op": ">=", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 0, + 4, + 1 + ], + "str": "0.4.1" + } + }, + { + "op": "<", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 0, + 5, + 0 + ], + "str": "0.5.0" + } + } + ], + "extras": [], + "markers": null, + "name": "crashtest", + "url": null + }, + { + "conditions": [ + { + "op": ">=", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 0, + 21, + 2 + ], + "str": "0.21.2" + } + }, + { + "op": "<", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 0, + 22, + 0 + ], + "str": "0.22.0" + } + } + ], + "extras": [], + "markers": null, + "name": "dulwich", + "url": null + }, + { + "conditions": [ + { + "op": ">=", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 3, + 8, + 0 + ], + "str": "3.8.0" + } + }, + { + "op": "<", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 4, + 0, + 0 + ], + "str": "4.0.0" + } + } + ], + "extras": [], + "markers": null, + "name": "filelock", + "url": null + }, + { + "conditions": [ + { + "op": ">=", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 1, + 0, + 0 + ], + "str": "1.0.0" + } + }, + { + "op": "<", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 2, + 0, + 0 + ], + "str": "2.0.0" + } + } + ], + "extras": [], + "markers": null, + "name": "html5lib", + "url": null + }, + { + "conditions": [ + { + "op": ">=", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 4, + 4 + ], + "str": "4.4" + } + } + ], + "extras": [], + "markers": { + "lhs": { + "lhs": { + "type": "variable", + "value": "python_version" + }, + "op": "<", + "rhs": { + "type": "version", + "value": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 3, + 10 + ], + "str": "3.10" + } + }, + "type": "compare" + }, + "op": "and", + "rhs": { + "type": "bool", + "value": true + }, + "type": "boolOp" + }, + "name": "importlib-metadata", + "url": null + }, + { + "conditions": [ + { + "op": ">=", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 0, + 7, + 0 + ], + "str": "0.7.0" + } + }, + { + "op": "<", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 0, + 8, + 0 + ], + "str": "0.8.0" + } + } + ], + "extras": [], + "markers": null, + "name": "installer", + "url": null + }, + { + "conditions": [ + { + "op": ">=", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 4, + 10, + 0 + ], + "str": "4.10.0" + } + }, + { + "op": "<", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 5, + 0, + 0 + ], + "str": "5.0.0" + } + } + ], + "extras": [], + "markers": null, + "name": "jsonschema", + "url": null + }, + { + "conditions": [ + { + "op": ">=", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 23, + 9, + 0 + ], + "str": "23.9.0" + } + }, + { + "op": "<", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 24, + 0, + 0 + ], + "str": "24.0.0" + } + } + ], + "extras": [], + "markers": null, + "name": "keyring", + "url": null + }, + { + "conditions": [ + { + "op": ">=", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 0, + 12, + 2 + ], + "str": "0.12.2" + } + }, + { + "op": "<", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 0, + 13, + 0 + ], + "str": "0.13.0" + } + } + ], + "extras": [], + "markers": null, + "name": "lockfile", + "url": null + }, + { + "conditions": [ + { + "op": ">=", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 20, + 4 + ], + "str": "20.4" + } + } + ], + "extras": [], + "markers": null, + "name": "packaging", + "url": null + }, + { + "conditions": [ + { + "op": ">=", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 4, + 7, + 0 + ], + "str": "4.7.0" + } + }, + { + "op": "<", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 5, + 0, + 0 + ], + "str": "5.0.0" + } + } + ], + "extras": [], + "markers": null, + "name": "pexpect", + "url": null + }, + { + "conditions": [ + { + "op": ">=", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 1, + 9, + 4 + ], + "str": "1.9.4" + } + }, + { + "op": "<", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 2, + 0, + 0 + ], + "str": "2.0.0" + } + } + ], + "extras": [], + "markers": null, + "name": "pkginfo", + "url": null + }, + { + "conditions": [ + { + "op": ">=", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 2, + 5, + 2 + ], + "str": "2.5.2" + } + }, + { + "op": "<", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 3, + 0, + 0 + ], + "str": "3.0.0" + } + } + ], + "extras": [], + "markers": null, + "name": "platformdirs", + "url": null + }, + { + "conditions": [ + { + "op": "==", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 1, + 5, + 2 + ], + "str": "1.5.2" + } + } + ], + "extras": [], + "markers": null, + "name": "poetry-core", + "url": null + }, + { + "conditions": [ + { + "op": ">=", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 1, + 3, + 0 + ], + "str": "1.3.0" + } + }, + { + "op": "<", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 2, + 0, + 0 + ], + "str": "2.0.0" + } + } + ], + "extras": [], + "markers": null, + "name": "poetry-plugin-export", + "url": null + }, + { + "conditions": [ + { + "op": ">=", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 1, + 0, + 0 + ], + "str": "1.0.0" + } + }, + { + "op": "<", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 2, + 0, + 0 + ], + "str": "2.0.0" + } + } + ], + "extras": [], + "markers": null, + "name": "pyproject-hooks", + "url": null + }, + { + "conditions": [ + { + "op": ">=", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 3, + 7, + 0 + ], + "str": "3.7.0" + } + }, + { + "op": "<", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 4, + 0, + 0 + ], + "str": "4.0.0" + } + } + ], + "extras": [], + "markers": null, + "name": "python", + "url": null + }, + { + "conditions": [ + { + "op": ">=", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 2, + 18, + 0 + ], + "str": "2.18.0" + } + }, + { + "op": "<", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 3, + 0, + 0 + ], + "str": "3.0.0" + } + } + ], + "extras": [], + "markers": null, + "name": "requests", + "url": null + }, + { + "conditions": [ + { + "op": ">=", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 0, + 9, + 1 + ], + "str": "0.9.1" + } + }, + { + "op": "<", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 0, + 11, + 0 + ], + "str": "0.11.0" + } + } + ], + "extras": [], + "markers": null, + "name": "requests-toolbelt", + "url": null + }, + { + "conditions": [ + { + "op": ">=", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 1, + 5, + 0 + ], + "str": "1.5.0" + } + }, + { + "op": "<", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 2, + 0, + 0 + ], + "str": "2.0.0" + } + } + ], + "extras": [], + "markers": null, + "name": "shellingham", + "url": null + }, + { + "conditions": [ + { + "op": ">=", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 2, + 0, + 1 + ], + "str": "2.0.1" + } + }, + { + "op": "<", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 3, + 0, + 0 + ], + "str": "3.0.0" + } + } + ], + "extras": [], + "markers": { + "lhs": { + "lhs": { + "type": "variable", + "value": "python_version" + }, + "op": "<", + "rhs": { + "type": "version", + "value": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 3, + 11 + ], + "str": "3.11" + } + }, + "type": "compare" + }, + "op": "and", + "rhs": { + "type": "bool", + "value": true + }, + "type": "boolOp" + }, + "name": "tomli", + "url": null + }, + { + "conditions": [ + { + "op": ">=", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 0, + 11, + 1 + ], + "str": "0.11.1" + } + }, + { + "op": "<", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 1, + 0, + 0 + ], + "str": "1.0.0" + } + }, + { + "op": "!=", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 0, + 11, + 2 + ], + "str": "0.11.2" + } + }, + { + "op": "!=", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 0, + 11, + 3 + ], + "str": "0.11.3" + } + } + ], + "extras": [], + "markers": null, + "name": "tomlkit", + "url": null + }, + { + "conditions": [ + { + "op": ">=", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 2022, + 5, + 19 + ], + "str": "2022.5.19" + } + } + ], + "extras": [], + "markers": null, + "name": "trove-classifiers", + "url": null + }, + { + "conditions": [ + { + "op": ">=", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 1, + 26, + 0 + ], + "str": "1.26.0" + } + }, + { + "op": "<", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 2, + 0, + 0 + ], + "str": "2.0.0" + } + } + ], + "extras": [], + "markers": null, + "name": "urllib3", + "url": null + }, + { + "conditions": [ + { + "op": ">=", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 20, + 4, + 3 + ], + "str": "20.4.3" + } + }, + { + "op": "<", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 21, + 0, + 0 + ], + "str": "21.0.0" + } + }, + { + "op": "!=", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 20, + 4, + 5 + ], + "str": "20.4.5" + } + }, + { + "op": "!=", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 20, + 4, + 6 + ], + "str": "20.4.6" + } + } + ], + "extras": [], + "markers": null, + "name": "virtualenv", + "url": null + }, + { + "conditions": [ + { + "op": "<", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 20, + 16, + 6 + ], + "str": "20.16.6" + } + } + ], + "extras": [], + "markers": { + "lhs": { + "lhs": { + "type": "variable", + "value": "sys_platform" + }, + "op": "==", + "rhs": { + "type": "string", + "value": "win32" + }, + "type": "compare" + }, + "op": "and", + "rhs": { + "lhs": { + "type": "variable", + "value": "python_version" + }, + "op": "==", + "rhs": { + "type": "version", + "value": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 3, + 9 + ], + "str": "3.9" + } + }, + "type": "compare" + }, + "type": "boolOp" + }, + "name": "virtualenv", + "url": null + }, + { + "conditions": [ + { + "op": ">=", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 0, + 10, + 0 + ], + "str": "0.10.0" + } + }, + { + "op": "<", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 0, + 11, + 0 + ], + "str": "0.11.0" + } + } + ], + "extras": [], + "markers": { + "lhs": { + "type": "variable", + "value": "sys_platform" + }, + "op": "==", + "rhs": { + "type": "string", + "value": "darwin" + }, + "type": "compare" + }, + "name": "xattr", + "url": null + } + ], + "extras": { + "dev": [ + { + "conditions": [ + { + "op": ">=", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 2, + 6, + 0 + ], + "str": "2.6.0" + } + }, + { + "op": "<", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 3, + 0, + 0 + ], + "str": "3.0.0" + } + } + ], + "extras": [], + "markers": null, + "name": "pre-commit", + "url": null + } + ], + "github-actions": [ + { + "conditions": [ + { + "op": ">=", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 0, + 1, + 7 + ], + "str": "0.1.7" + } + }, + { + "op": "<", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 0, + 2, + 0 + ], + "str": "0.2.0" + } + } + ], + "extras": [], + "markers": null, + "name": "pytest-github-actions-annotate-failures", + "url": null + } + ], + "test": [ + { + "conditions": [ + { + "op": "==", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 0, + 3, + 0 + ], + "str": "0.3.0" + } + } + ], + "extras": [], + "markers": null, + "name": "cachy", + "url": null + }, + { + "conditions": [ + { + "op": ">=", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 6, + 2, + 0 + ], + "str": "6.2.0" + } + }, + { + "op": "<", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 7, + 0, + 0 + ], + "str": "7.0.0" + } + } + ], + "extras": [], + "markers": null, + "name": "deepdiff", + "url": null + }, + { + "conditions": [ + { + "op": "<", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 6, + 2, + 3 + ], + "str": "6.2.3" + } + } + ], + "extras": [], + "markers": { + "lhs": { + "type": "variable", + "value": "platform_system" + }, + "op": "==", + "rhs": { + "type": "string", + "value": "FreeBSD" + }, + "type": "compare" + }, + "name": "deepdiff", + "url": null + }, + { + "conditions": [ + { + "op": ">=", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 1, + 0, + 0 + ], + "str": "1.0.0" + } + }, + { + "op": "<", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 2, + 0, + 0 + ], + "str": "2.0.0" + } + } + ], + "extras": [], + "markers": null, + "name": "httpretty", + "url": null + }, + { + "conditions": [ + { + "op": ">=", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 7, + 1, + 0 + ], + "str": "7.1.0" + } + }, + { + "op": "<", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 8, + 0, + 0 + ], + "str": "8.0.0" + } + } + ], + "extras": [], + "markers": null, + "name": "pytest", + "url": null + }, + { + "conditions": [ + { + "op": ">=", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 4, + 0, + 0 + ], + "str": "4.0.0" + } + }, + { + "op": "<", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 5, + 0, + 0 + ], + "str": "5.0.0" + } + } + ], + "extras": [], + "markers": null, + "name": "pytest-cov", + "url": null + }, + { + "conditions": [ + { + "op": ">=", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 3, + 9, + 0 + ], + "str": "3.9.0" + } + }, + { + "op": "<", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 4, + 0, + 0 + ], + "str": "4.0.0" + } + } + ], + "extras": [], + "markers": null, + "name": "pytest-mock", + "url": null + }, + { + "conditions": [ + { + "op": ">=", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 3, + 12, + 0 + ], + "str": "3.12.0" + } + }, + { + "op": "<", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 4, + 0, + 0 + ], + "str": "4.0.0" + } + } + ], + "extras": [], + "markers": null, + "name": "pytest-randomly", + "url": null + }, + { + "conditions": [ + { + "op": ">=", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 3, + 1, + 0 + ], + "str": "3.1.0" + } + }, + { + "op": "<", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 4, + 0, + 0 + ], + "str": "4.0.0" + } + } + ], + "extras": [ + "psutil" + ], + "markers": null, + "name": "pytest-xdist", + "url": null + }, + { + "conditions": [ + { + "op": ">=", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 3, + 4, + 0 + ], + "str": "3.4.0" + } + }, + { + "op": "<", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 4, + 0, + 0 + ], + "str": "4.0.0" + } + } + ], + "extras": [], + "markers": { + "lhs": { + "lhs": { + "type": "variable", + "value": "python_version" + }, + "op": "<", + "rhs": { + "type": "version", + "value": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 3, + 8 + ], + "str": "3.8" + } + }, + "type": "compare" + }, + "op": "and", + "rhs": { + "type": "bool", + "value": true + }, + "type": "boolOp" + }, + "name": "zipp", + "url": null + } + ], + "typing": [ + { + "conditions": [ + { + "op": ">=", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 1, + 0 + ], + "str": "1.0" + } + } + ], + "extras": [], + "markers": null, + "name": "mypy", + "url": null + }, + { + "conditions": [ + { + "op": ">=", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 1, + 1, + 9 + ], + "str": "1.1.9" + } + } + ], + "extras": [], + "markers": null, + "name": "types-html5lib", + "url": null + }, + { + "conditions": [ + { + "op": ">=", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 4, + 9, + 0 + ], + "str": "4.9.0" + } + } + ], + "extras": [], + "markers": null, + "name": "types-jsonschema", + "url": null + }, + { + "conditions": [ + { + "op": ">=", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 2, + 28, + 8 + ], + "str": "2.28.8" + } + } + ], + "extras": [], + "markers": null, + "name": "types-requests", + "url": null + }, + { + "conditions": [ + { + "op": ">=", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 4, + 0, + 0 + ], + "str": "4.0.0" + } + }, + { + "op": "<", + "version": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 5, + 0, + 0 + ], + "str": "5.0.0" + } + } + ], + "extras": [], + "markers": { + "lhs": { + "lhs": { + "type": "variable", + "value": "python_version" + }, + "op": "<", + "rhs": { + "type": "version", + "value": { + "dev": null, + "epoch": 0, + "local": null, + "post": null, + "pre": null, + "release": [ + 3, + 8 + ], + "str": "3.8" + } + }, + "type": "compare" + }, + "op": "and", + "rhs": { + "type": "bool", + "value": true + }, + "type": "boolOp" + }, + "name": "typing-extensions", + "url": null + } + ] + } +} diff --git a/lib/expected/project.loadPyprojectDynamic.testPoetry.json b/lib/expected/project.loadPyprojectDynamic.testPoetry.json new file mode 100644 index 0000000..cbb5c45 --- /dev/null +++ b/lib/expected/project.loadPyprojectDynamic.testPoetry.json @@ -0,0 +1,220 @@ +{ + "build-system": [ + { + "pname": "poetry-core", + "version": "1.9.0" + } + ], + "dependencies": [ + { + "pname": "build", + "version": "1.2.1" + }, + { + "pname": "cachecontrol", + "version": "0.14.0" + }, + { + "pname": "cleo", + "version": "2.1.0" + }, + { + "pname": "crashtest", + "version": "0.4.1" + }, + { + "pname": "dulwich", + "version": "0.22.1" + }, + { + "pname": "filelock", + "version": "3.15.1" + }, + { + "pname": "html5lib", + "version": "1.1" + }, + { + "pname": "importlib-metadata", + "version": "7.1.0" + }, + { + "pname": "installer", + "version": "0.7.0" + }, + { + "pname": "jsonschema", + "version": "4.22.0" + }, + { + "pname": "keyring", + "version": "25.3.0" + }, + { + "pname": "lockfile", + "version": "0.12.2" + }, + { + "pname": "packaging", + "version": "24.1" + }, + { + "pname": "pexpect", + "version": "4.9.0" + }, + { + "pname": "pkginfo", + "version": "1.11.1" + }, + { + "pname": "platformdirs", + "version": "4.2.2" + }, + { + "pname": "poetry-core", + "version": "1.9.0" + }, + { + "pname": "poetry-plugin-export", + "version": "1.4.0" + }, + { + "pname": "pyproject-hooks", + "version": "1.0.0" + }, + { + "pname": "python3", + "version": "3.12.5" + }, + { + "pname": "requests", + "version": "2.32.3" + }, + { + "pname": "requests-toolbelt", + "version": "1.0.0" + }, + { + "pname": "shellingham", + "version": "1.5.4" + }, + { + "pname": "tomli", + "version": "2.0.1" + }, + { + "pname": "tomlkit", + "version": "0.12.5" + }, + { + "pname": "trove-classifiers", + "version": "2024.7.2" + }, + { + "pname": "urllib3", + "version": "2.2.2" + }, + { + "pname": "virtualenv", + "version": "20.26.2" + }, + { + "pname": "pre-commit", + "version": "3.3.3" + } + ], + "meta": { + "description": "Python dependency management and packaging made easy.", + "license": { + "deprecated": false, + "free": true, + "fullName": "MIT License", + "redistributable": true, + "shortName": "mit", + "spdxId": "MIT", + "url": "https://spdx.org/licenses/MIT.html" + }, + "mainProgram": "poetry" + }, + "optional-dependencies": { + "dev": [ + { + "pname": "pre-commit", + "version": "3.3.3" + } + ], + "github-actions": [ + { + "pname": "pytest-github-actions-annotate-failures", + "version": "0.1.0" + } + ], + "test": [ + { + "pname": "cachy", + "version": "0.3.0" + }, + { + "pname": "deepdiff", + "version": "7.0.1" + }, + { + "pname": "deepdiff", + "version": "7.0.1" + }, + { + "pname": "httpretty", + "version": "1.1.4" + }, + { + "pname": "pytest", + "version": "8.3.2" + }, + { + "pname": "pytest-cov", + "version": "5.0.0" + }, + { + "pname": "pytest-mock", + "version": "3.14.0" + }, + { + "pname": "pytest-randomly", + "version": "3.13.0" + }, + { + "pname": "pytest-xdist", + "version": "3.6.1" + }, + { + "pname": "zipp", + "version": "3.19.2" + } + ], + "typing": [ + { + "pname": "mypy", + "version": "1.10.1" + }, + { + "pname": "types-html5lib", + "version": "1.1.11.20240806" + }, + { + "pname": "types-jsonschema", + "version": "0.1.0" + }, + { + "pname": "types-requests", + "version": "2.32.0.20240712" + }, + { + "pname": "typing-extensions", + "version": "4.12.2" + } + ] + }, + "pname": "poetry", + "pyproject": true, + "version": "1.4.2" +} diff --git a/lib/pep440.nix b/lib/pep440.nix index 5554881..e488fea 100644 --- a/lib/pep440.nix +++ b/lib/pep440.nix @@ -42,6 +42,7 @@ let post = null; pre = null; release = [ ]; + str = ""; }; # We consider some words to be alternate spellings of other words and @@ -164,11 +165,14 @@ fix (self: { # Split post345 into ["post" "345"] m = match "-?([^0-9]+)([0-9]+)" mod; in - assert m != null; - { - type = normalizedReleaseType (elemAt m 0); - value = toIntRelease (elemAt m 1); - } + if m == null then + throw "PEP-440 modifier segment invalid: ${mod}" + # assert m != null; + else + { + type = normalizedReleaseType (elemAt m 0); + value = toIntRelease (elemAt m 1); + } ) (filter (s: isString s && s != "") (split "\\." modifiersSegment)); in @@ -190,6 +194,11 @@ fix (self: { # Local releases needs to be treated specially. # The value isn't just a straight up number, but an arbitrary string. local = if local != "" then local else null; + + # Return the input verbatim for lexicographical comparisons such as those + # done for platform_release which is parsed as PEP-440 when compliant, + # but are compare lexicographically when the version string is non-compliant. + str = version; }; /* diff --git a/lib/pep508.nix b/lib/pep508.nix index c7322eb..0040313 100644 --- a/lib/pep508.nix +++ b/lib/pep508.nix @@ -23,6 +23,9 @@ let length isList any + isAttrs + tryEval + deepSeq ; inherit (lib) stringToCharacters @@ -42,6 +45,25 @@ let type = "version"; value = pep440.parseVersion value; }; + + emptyPlatformRelease = { + type = "platform_release"; + value = ""; + }; + + platform_release = + value: + if value == "" then + emptyPlatformRelease + else + let + parsed' = pep440.parseVersion value; + eval' = tryEval (deepSeq parsed' parsed'); + in + { + type = "platform_release"; + value = if eval'.success then eval'.value else value; + }; in { "implementation_name" = default; @@ -49,9 +71,9 @@ let "os_name" = default; "platform_machine" = default; "platform_python_implementation" = default; - "platform_release" = default; + "platform_release" = platform_release; "platform_system" = default; - "platform_version" = version; + "platform_version" = default; "python_full_version" = version; "python_version" = version; "sys_platform" = default; @@ -83,6 +105,31 @@ let "!=" = extras: extra: if typeOf extras == "list" then !(elem extra extras) else extras != extra; }; + # Platform_release parsing is more complicated than other fields. + # + # If both lhs and rhs were correctly parsed as PEP-440 versions run regular version comparison, + # otherwise compare lexicographically + # + # See: + # - https://github.com/pypa/packaging/issues/774 + # - https://github.com/astral-sh/uv/issues/3917#issuecomment-2141754917 + platformReleaseComparators = { + "==" = + a: b: if isAttrs a && isAttrs b then pep440.comparators."==" a b else (a.str or a) == (b.str or b); + "!=" = + a: b: if isAttrs a && isAttrs b then pep440.comparators."!=" a b else (a.str or a) != (b.str or b); + "<=" = + a: b: if isAttrs a && isAttrs b then pep440.comparators."<=" a b else (a.str or a) <= (b.str or b); + ">=" = + a: b: if isAttrs a && isAttrs b then pep440.comparators.">=" a b else (a.str or a) >= (b.str or b); + "<" = + a: b: if isAttrs a && isAttrs b then pep440.comparators."<" a b else (a.str or a) < (b.str or b); + + ">" = + a: b: if isAttrs a && isAttrs b then pep440.comparators.">" a b else (a.str or a) > (b.str or b); + "===" = a: b: a == b; + }; + boolOps = { "and" = x: y: x && y; "or" = x: y: x || y; @@ -637,7 +684,10 @@ in "PyPy" else throw "Unsupported implementation ${impl}"; - platform_release = ""; # Field not reproducible + # We have no reliable value to set platform_release to. + # In theory this could be set to linuxHeaders.version on Linux, but that's + # not correct + platform_release = ""; # Non-reproducible field. platform_system = if stdenv.isLinux then "Linux" @@ -675,8 +725,11 @@ in if value.type == "compare" then ( ( + # platform_release is being compared as foo + if value.lhs.type == "variable" && value.lhs.value == "platform_release" then + platformReleaseComparators.${value.op} # Version comparison - if value.lhs.type == "version" || value.rhs.type == "version" then + else if value.lhs.type == "version" || value.rhs.type == "version" then pep440.comparators.${value.op} # `Extra` environment marker comparison requires special casing because it's equality checks can # == can be considered a `"key" in set` comparison when multiple extras are activated for a dependency. @@ -694,7 +747,7 @@ in boolOps.${value.op} (evalMarkers environ value.lhs) (evalMarkers environ value.rhs) else if value.type == "variable" then (evalMarkers environ environ.${value.value}) - else if value.type == "version" || value.type == "extra" then + else if value.type == "version" || value.type == "extra" || value.type == "platform_release" then value.value else if elem value.type primitives then value.value diff --git a/lib/poetry.nix b/lib/poetry.nix index b78274a..cb6cf79 100644 --- a/lib/poetry.nix +++ b/lib/poetry.nix @@ -21,6 +21,7 @@ lib.fix ( length filter split + concatStringsSep ; inherit (lib) optionalAttrs concatLists; inherit (import ./util.nix { inherit lib; }) splitComma; @@ -269,7 +270,7 @@ lib.fix ( } { op = "<"; - version = version // { + version = version // rec { release = lib.imap0 ( i: tok: if i >= segments - 1 then @@ -279,6 +280,7 @@ lib.fix ( else tok ) version.release; + str = concatStringsSep "." (map toString release); # Overwrite with upper bounds }; } ] @@ -291,8 +293,9 @@ lib.fix ( } { op = "<"; - version = version // { + version = version // rec { release = rewriteCaretRhs version.release; + str = concatStringsSep "." (map toString release); # Overwrite with upper bounds }; } ] diff --git a/lib/test_pep440.nix b/lib/test_pep440.nix index b9b992d..b544dd3 100644 --- a/lib/test_pep440.nix +++ b/lib/test_pep440.nix @@ -26,6 +26,7 @@ in 0 0 ]; + str = "3.0.0"; }; }; @@ -45,6 +46,7 @@ in 0 0 ]; + str = "3.0.0post2"; }; }; @@ -64,6 +66,7 @@ in 0 0 ]; + str = "3.0.0rc1"; }; }; @@ -83,6 +86,7 @@ in 0 0 ]; + str = "3.0.0pre1"; }; }; @@ -102,6 +106,7 @@ in 0 0 ]; + str = "3.0.0-1"; }; }; @@ -121,6 +126,7 @@ in 2 0 ]; + str = "1.2.0dev21"; }; }; @@ -140,6 +146,7 @@ in 2 0 ]; + str = "1.2.0.dev21"; }; }; @@ -159,6 +166,7 @@ in 2 0 ]; + str = "1.2.0-dev21"; }; }; @@ -174,6 +182,7 @@ in 1 2 ]; + str = "1.2+4.3"; }; }; @@ -190,6 +199,7 @@ in 2 "*" ]; + str = "3.2.*"; }; }; @@ -214,6 +224,7 @@ in 1 0 ]; + str = "1.0b2.post345.dev456"; }; }; @@ -229,6 +240,7 @@ in 2 0 ]; + str = "1!2.0"; }; }; }; @@ -319,6 +331,7 @@ in 0 0 ]; + str = "3.0.0rc1"; }; }; }; @@ -334,6 +347,7 @@ in post = null; pre = null; release = [ "*" ]; + str = "*"; }; }; }; @@ -359,6 +373,7 @@ in 0 0 ]; + str = "3.0.0rc1"; }; } { @@ -373,6 +388,7 @@ in 4 0 ]; + str = "4.0"; }; } ]; diff --git a/lib/test_pep508.nix b/lib/test_pep508.nix index c9389b5..30dab5a 100644 --- a/lib/test_pep508.nix +++ b/lib/test_pep508.nix @@ -48,6 +48,7 @@ fix (self: { post = null; pre = null; release = [ 3 ]; + str = "3"; }; }; type = "compare"; @@ -76,6 +77,7 @@ fix (self: { post = null; pre = null; release = [ 3 ]; + str = "3"; }; }; type = "compare"; @@ -220,6 +222,7 @@ fix (self: { post = null; pre = null; release = [ 3 ]; + str = "3"; }; }; type = "compare"; @@ -259,6 +262,7 @@ fix (self: { post = null; pre = null; release = [ 3 ]; + str = "3"; }; }; type = "compare"; @@ -311,6 +315,7 @@ fix (self: { 3 0 ]; + str = "12.3.0"; }; } ]; @@ -348,6 +353,7 @@ fix (self: { 20 9 ]; + str = "20.9"; }; } { @@ -362,6 +368,7 @@ fix (self: { 22 0 ]; + str = "22.0"; }; } ]; @@ -389,6 +396,7 @@ fix (self: { 13 0 ]; + str = "0.13.0"; }; } ]; @@ -415,6 +423,7 @@ fix (self: { 1 0 ]; + str = "1.1.0"; }; } ]; @@ -436,6 +445,7 @@ fix (self: { 3 11 ]; + str = "3.11"; }; }; type = "compare"; @@ -490,6 +500,7 @@ fix (self: { 2 7 ]; + str = "2.7"; }; }; type = "compare"; @@ -586,6 +597,7 @@ fix (self: { 2 7 ]; + str = "2.7"; }; }; type = "compare"; @@ -598,15 +610,8 @@ fix (self: { }; op = "=="; rhs = { - type = "version"; - value = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ 2 ]; - }; + type = "string"; + value = "2"; }; type = "compare"; }; @@ -842,298 +847,56 @@ fix (self: { }; }; - mkEnviron = mapAttrs (_: case: case // { expr = pep508.mkEnviron case.input; }) { - testPython38Linux = { - input = mocks.cpythonLinux38; - expected = { - implementation_name = { - type = "string"; - value = "cpython"; - }; - implementation_version = { - type = "version"; - value = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 3 - 8 - 2 - ]; - }; - }; - os_name = { - type = "string"; - value = "posix"; - }; - platform_machine = { - type = "string"; - value = "x86_64"; - }; - platform_python_implementation = { - type = "string"; - value = "CPython"; - }; - platform_release = { - type = "string"; - value = ""; - }; - platform_system = { - type = "string"; - value = "Linux"; - }; - platform_version = { - type = "version"; - value = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ ]; - }; - }; - python_full_version = { - type = "version"; - value = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 3 - 8 - 2 - ]; - }; - }; - python_version = { - type = "version"; - value = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 3 - 8 - ]; - }; - }; - sys_platform = { - type = "string"; - value = "linux"; - }; - }; - }; - - testPython311Darwin = { - input = mocks.cpythonDarwin311; - expected = { - implementation_name = { - type = "string"; - value = "cpython"; - }; - implementation_version = { - type = "version"; - value = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 3 - 11 - 4 - ]; - }; - }; - os_name = { - type = "string"; - value = "posix"; - }; - platform_machine = { - type = "string"; - value = "x86_64"; - }; - platform_python_implementation = { - type = "string"; - value = "CPython"; - }; - platform_release = { - type = "string"; - value = ""; - }; - platform_system = { - type = "string"; - value = "Darwin"; - }; - platform_version = { - type = "version"; - value = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ ]; - }; - }; - python_full_version = { - type = "version"; - value = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 3 - 11 - 4 - ]; - }; - }; - python_version = { - type = "version"; - value = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 3 - 11 - ]; - }; - }; - sys_platform = { - type = "string"; - value = "darwin"; - }; - }; - }; - - testPython311DarwinAarch64 = { - input = mocks.cpythonDarwin311Aarch64; - expected = self.mkEnviron.testPython311Darwin.expected // { - platform_machine = { - type = "string"; - value = "arm64"; - }; - }; - }; - - testPypy3Linux = { - input = mocks.pypy39Linux; - expected = { - implementation_name = { - type = "string"; - value = "pypy"; - }; - implementation_version = { - type = "version"; - value = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 7 - 3 - 11 - ]; - }; - }; - os_name = { - type = "string"; - value = "posix"; - }; - platform_machine = { - type = "string"; - value = "x86_64"; - }; - platform_python_implementation = { - type = "string"; - value = "PyPy"; - }; - platform_release = { - type = "string"; - value = ""; - }; - platform_system = { - type = "string"; - value = "Linux"; - }; - platform_version = { - type = "version"; - value = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ ]; - }; - }; - python_full_version = { - type = "version"; - value = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 7 - 3 - 11 - ]; - }; - }; - python_version = { - type = "version"; - value = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 3 - 9 - ]; - }; - }; - sys_platform = { - type = "string"; - value = "linux"; - }; + mkEnviron = + mapAttrs + (name: case: { + expr = pep508.mkEnviron case; + expected = lib.importJSON ./expected/pep508.mkEnviron.${name}.json; + }) + { + testPython38Linux = mocks.cpythonLinux38; + testPython311Darwin = mocks.cpythonDarwin311; + testPython311DarwinAarch64 = mocks.cpythonDarwin311Aarch64; + testPypy3Linux = mocks.pypy39Linux; }; - }; - }; setEnviron = let environ = pep508.mkEnviron mocks.cpythonLinux38; in { - testSetString = { + testSetPlatformReleaseValidVersion = { expr = { inherit (setEnviron environ { platform_release = "5.10.65"; }) platform_release; }; expected = { platform_release = { - type = "string"; - value = "5.10.65"; + type = "platform_release"; + value = { + dev = null; + epoch = 0; + local = null; + post = null; + pre = null; + release = [ + 5 + 10 + 65 + ]; + str = "5.10.65"; + }; + }; + }; + }; + + testSetPlatformReleaseInvalidVersion = { + expr = { + inherit (setEnviron environ { platform_release = "5.10.65-1025-azure"; }) platform_release; + }; + expected = { + platform_release = { + type = "platform_release"; + value = "5.10.65-1025-azure"; }; }; }; @@ -1156,6 +919,7 @@ fix (self: { 0 0 ]; + str = "1.0.0"; }; }; }; @@ -1270,5 +1034,21 @@ fix (self: { expected = false; }; + testPlatformRelease = { + input = { + environ = self.mkEnviron.testPython38Linux.expected; + markers = pep508.parseMarkers "platform_release >= '20.0'"; + }; + expected = false; + }; + + testPlatformReleaseInvalidPep440 = { + input = { + environ = self.mkEnviron.testPython38Linux.expected; + markers = pep508.parseMarkers "platform_release >= '6.5.0-1025-azure'"; + }; + expected = false; + }; + }; }) diff --git a/lib/test_pep621/default.nix b/lib/test_pep621/default.nix index 92b0fe7..91da95d 100644 --- a/lib/test_pep621/default.nix +++ b/lib/test_pep621/default.nix @@ -54,6 +54,7 @@ fix (_self: { 3 9 ]; + str = "3.9"; }; } ]; @@ -74,6 +75,7 @@ fix (_self: { 3 7 ]; + str = "3.7"; }; } ]; diff --git a/lib/test_pep621/expected/parsedependencies-pandas.nix b/lib/test_pep621/expected/parsedependencies-pandas.nix index 69f778e..f5d92d7 100644 --- a/lib/test_pep621/expected/parsedependencies-pandas.nix +++ b/lib/test_pep621/expected/parsedependencies-pandas.nix @@ -15,6 +15,7 @@ 13 1 ]; + str = "0.13.1"; }; } ]; @@ -38,6 +39,7 @@ 0 1 ]; + str = "1.0.1"; }; } ]; @@ -68,6 +70,7 @@ 29 33 ]; + str = "0.29.33"; }; } { @@ -79,6 +82,7 @@ post = null; pre = null; release = [ 3 ]; + str = "3"; }; } ]; @@ -102,6 +106,7 @@ 8 16 ]; + str = "2022.8.16"; }; } ]; @@ -134,6 +139,7 @@ 21 6 ]; + str = "1.21.6"; }; } ]; @@ -156,6 +162,7 @@ 3 11 ]; + str = "3.11"; }; }; type = "compare"; @@ -178,6 +185,7 @@ 23 2 ]; + str = "1.23.2"; }; } ]; @@ -200,6 +208,7 @@ 3 11 ]; + str = "3.11"; }; }; type = "compare"; @@ -222,6 +231,7 @@ 8 2 ]; + str = "2.8.2"; }; } ]; @@ -244,6 +254,7 @@ 2020 1 ]; + str = "2020.1"; }; } ]; @@ -266,6 +277,7 @@ 2022 1 ]; + str = "2022.1"; }; } ]; @@ -292,6 +304,7 @@ 11 1 ]; + str = "4.11.1"; }; } ]; @@ -315,6 +328,7 @@ 3 4 ]; + str = "1.3.4"; }; } ]; @@ -338,6 +352,7 @@ 7 0 ]; + str = "0.7.0"; }; } ]; @@ -361,6 +376,7 @@ 8 1 ]; + str = "0.8.1"; }; } ]; @@ -384,6 +400,7 @@ 5 0 ]; + str = "2022.05.0"; }; } ]; @@ -407,6 +424,7 @@ 5 0 ]; + str = "2022.05.0"; }; } ]; @@ -429,6 +447,7 @@ 1 1 ]; + str = "1.1"; }; } ]; @@ -452,6 +471,7 @@ 46 1 ]; + str = "6.46.1"; }; } ]; @@ -475,6 +495,7 @@ 1 2 ]; + str = "3.1.2"; }; } ]; @@ -498,6 +519,7 @@ 8 0 ]; + str = "4.8.0"; }; } ]; @@ -521,6 +543,7 @@ 6 1 ]; + str = "3.6.1"; }; } ]; @@ -544,6 +567,7 @@ 55 2 ]; + str = "0.55.2"; }; } ]; @@ -567,6 +591,7 @@ 8 0 ]; + str = "2.8.0"; }; } ]; @@ -590,6 +615,7 @@ 4 1 ]; + str = "1.4.1"; }; } ]; @@ -613,6 +639,7 @@ 0 10 ]; + str = "3.0.10"; }; } ]; @@ -636,6 +663,7 @@ 17 5 ]; + str = "0.17.5"; }; } ]; @@ -659,6 +687,7 @@ 9 3 ]; + str = "2.9.3"; }; } ]; @@ -682,6 +711,7 @@ 0 0 ]; + str = "7.0.0"; }; } ]; @@ -705,6 +735,7 @@ 0 2 ]; + str = "1.0.2"; }; } ]; @@ -728,6 +759,7 @@ 15 6 ]; + str = "5.15.6"; }; } ]; @@ -751,6 +783,7 @@ 1 5 ]; + str = "1.1.5"; }; } ]; @@ -774,6 +807,7 @@ 3 2 ]; + str = "7.3.2"; }; } ]; @@ -797,6 +831,7 @@ 2 0 ]; + str = "2.2.0"; }; } ]; @@ -820,6 +855,7 @@ 17 0 ]; + str = "0.17.0"; }; } ]; @@ -843,6 +879,7 @@ 6 1 ]; + str = "0.6.1"; }; } ]; @@ -866,6 +903,7 @@ 0 9 ]; + str = "1.0.9"; }; } ]; @@ -889,6 +927,7 @@ 2 0 ]; + str = "2.2.0"; }; } ]; @@ -912,6 +951,7 @@ 8 1 ]; + str = "1.8.1"; }; } ]; @@ -935,6 +975,7 @@ 5 0 ]; + str = "2022.05.0"; }; } ]; @@ -958,6 +999,7 @@ 4 36 ]; + str = "1.4.36"; }; } ]; @@ -981,6 +1023,7 @@ 7 0 ]; + str = "3.7.0"; }; } ]; @@ -1004,6 +1047,7 @@ 8 10 ]; + str = "0.8.10"; }; } ]; @@ -1027,6 +1071,7 @@ 3 0 ]; + str = "2022.03.0"; }; } ]; @@ -1050,6 +1095,7 @@ 0 1 ]; + str = "2.0.1"; }; } ]; @@ -1073,6 +1119,7 @@ 0 3 ]; + str = "3.0.3"; }; } ]; @@ -1096,6 +1143,7 @@ 17 0 ]; + str = "0.17.0"; }; } ]; @@ -1121,6 +1169,7 @@ 5 0 ]; + str = "2022.05.0"; }; } ]; @@ -1146,6 +1195,7 @@ 15 6 ]; + str = "5.15.6"; }; } ]; @@ -1169,6 +1219,7 @@ 2 0 ]; + str = "2.2.0"; }; } ]; @@ -1194,6 +1245,7 @@ 7 0 ]; + str = "0.7.0"; }; } ]; @@ -1217,6 +1269,7 @@ 6 1 ]; + str = "0.6.1"; }; } ]; @@ -1240,6 +1293,7 @@ 17 0 ]; + str = "0.17.0"; }; } ]; @@ -1265,6 +1319,7 @@ 8 1 ]; + str = "1.8.1"; }; } ]; @@ -1288,6 +1343,7 @@ 3 0 ]; + str = "2022.03.0"; }; } ]; @@ -1313,6 +1369,7 @@ 4 1 ]; + str = "1.4.1"; }; } ]; @@ -1336,6 +1393,7 @@ 0 10 ]; + str = "3.0.10"; }; } ]; @@ -1359,6 +1417,7 @@ 0 9 ]; + str = "1.0.9"; }; } ]; @@ -1382,6 +1441,7 @@ 0 1 ]; + str = "2.0.1"; }; } ]; @@ -1405,6 +1465,7 @@ 0 3 ]; + str = "3.0.3"; }; } ]; @@ -1430,6 +1491,7 @@ 0 0 ]; + str = "7.0.0"; }; } ]; @@ -1455,6 +1517,7 @@ 5 0 ]; + str = "2022.05.0"; }; } ]; @@ -1480,6 +1543,7 @@ 5 0 ]; + str = "2022.05.0"; }; } ]; @@ -1503,6 +1567,7 @@ 17 5 ]; + str = "0.17.5"; }; } ]; @@ -1528,6 +1593,7 @@ 7 0 ]; + str = "3.7.0"; }; } ]; @@ -1553,6 +1619,7 @@ 11 1 ]; + str = "4.11.1"; }; } ]; @@ -1575,6 +1642,7 @@ 1 1 ]; + str = "1.1"; }; } ]; @@ -1598,6 +1666,7 @@ 8 0 ]; + str = "4.8.0"; }; } ]; @@ -1623,6 +1692,7 @@ 4 36 ]; + str = "1.4.36"; }; } ]; @@ -1646,6 +1716,7 @@ 0 2 ]; + str = "1.0.2"; }; } ]; @@ -1671,6 +1742,7 @@ 1 2 ]; + str = "3.1.2"; }; } ]; @@ -1694,6 +1766,7 @@ 8 10 ]; + str = "0.8.10"; }; } ]; @@ -1719,6 +1792,7 @@ 0 0 ]; + str = "7.0.0"; }; } ]; @@ -1744,6 +1818,7 @@ 3 4 ]; + str = "1.3.4"; }; } ]; @@ -1767,6 +1842,7 @@ 55 2 ]; + str = "0.55.2"; }; } ]; @@ -1790,6 +1866,7 @@ 8 0 ]; + str = "2.8.0"; }; } ]; @@ -1815,6 +1892,7 @@ 6 1 ]; + str = "3.6.1"; }; } ]; @@ -1840,6 +1918,7 @@ 4 36 ]; + str = "1.4.36"; }; } ]; @@ -1863,6 +1942,7 @@ 9 3 ]; + str = "2.9.3"; }; } ]; @@ -1888,6 +1968,7 @@ 1 5 ]; + str = "1.1.5"; }; } ]; @@ -1913,6 +1994,7 @@ 4 36 ]; + str = "1.4.36"; }; } ]; @@ -1938,6 +2020,7 @@ 46 1 ]; + str = "6.46.1"; }; } ]; @@ -1961,6 +2044,7 @@ 3 2 ]; + str = "7.3.2"; }; } ]; @@ -1984,6 +2068,7 @@ 2 0 ]; + str = "2.2.0"; }; } ]; @@ -2007,6 +2092,7 @@ 17 0 ]; + str = "0.17.0"; }; } ]; @@ -2032,6 +2118,7 @@ 8 0 ]; + str = "4.8.0"; }; } ]; diff --git a/lib/test_pep621/expected/parsedependencies-pdm.nix b/lib/test_pep621/expected/parsedependencies-pdm.nix index 2c247f5..84431d0 100644 --- a/lib/test_pep621/expected/parsedependencies-pdm.nix +++ b/lib/test_pep621/expected/parsedependencies-pdm.nix @@ -37,6 +37,7 @@ 20 9 ]; + str = "20.9"; }; } { @@ -51,6 +52,7 @@ 22 0 ]; + str = "22.0"; }; } ]; @@ -81,6 +83,7 @@ 3 0 ]; + str = "12.3.0"; }; } ]; @@ -100,6 +103,7 @@ post = null; pre = null; release = [ 20 ]; + str = "20"; }; } ]; @@ -137,6 +141,7 @@ 10 0 ]; + str = "0.10.0"; }; } ]; @@ -160,6 +165,7 @@ 3 0 ]; + str = "0.3.0"; }; } { @@ -178,6 +184,7 @@ 0 0 ]; + str = "1.0.0a0"; }; } ]; @@ -201,6 +208,7 @@ 11 1 ]; + str = "0.11.1"; }; } { @@ -212,6 +220,7 @@ post = null; pre = null; release = [ 1 ]; + str = "1"; }; } ]; @@ -235,6 +244,7 @@ 3 2 ]; + str = "1.3.2"; }; } ]; @@ -257,6 +267,7 @@ 0 15 ]; + str = "0.15"; }; } ]; @@ -280,6 +291,7 @@ 0 1 ]; + str = "1.0.1"; }; } ]; @@ -302,6 +314,7 @@ 0 8 ]; + str = "0.8"; }; } { @@ -316,6 +329,7 @@ 0 7 ]; + str = "0.7"; }; } ]; @@ -339,6 +353,7 @@ 13 0 ]; + str = "0.13.0"; }; } ]; @@ -362,6 +377,7 @@ 1 0 ]; + str = "1.1.0"; }; } ]; @@ -384,6 +400,7 @@ 3 11 ]; + str = "3.11"; }; }; type = "compare"; @@ -402,6 +419,7 @@ post = null; pre = null; release = [ 5 ]; + str = "5"; }; } ]; @@ -424,6 +442,7 @@ 3 9 ]; + str = "3.9"; }; }; type = "compare"; @@ -445,6 +464,7 @@ 3 6 ]; + str = "3.6"; }; } ]; @@ -467,6 +487,7 @@ 3 10 ]; + str = "3.10"; }; }; type = "compare"; @@ -566,6 +587,7 @@ 3 10 ]; + str = "3.10"; }; }; type = "compare"; diff --git a/lib/test_pip.nix b/lib/test_pip.nix index 8428203..4b30b29 100644 --- a/lib/test_pip.nix +++ b/lib/test_pip.nix @@ -35,6 +35,7 @@ in 1 2 ]; + str = "1.2"; }; } ]; @@ -63,6 +64,7 @@ in 3 2 ]; + str = "3.2"; }; } ]; @@ -95,6 +97,7 @@ in 1 0 ]; + str = "10.1.0"; }; } ]; @@ -121,6 +124,7 @@ in 31 0 ]; + str = "2.31.0"; }; } ]; diff --git a/lib/test_poetry.nix b/lib/test_poetry.nix index f7398c2..250decb 100644 --- a/lib/test_poetry.nix +++ b/lib/test_poetry.nix @@ -1,5 +1,11 @@ -{ fixtures, poetry, ... }: +{ + lib, + fixtures, + poetry, + ... +}: let + inherit (lib) importJSON; inherit (poetry) translatePoetryProject parseDependencies @@ -97,6 +103,7 @@ in 2 1 ]; + str = "3.2.1"; }; } { @@ -112,6 +119,7 @@ in 3 0 ]; + str = "3.3.0"; }; } ]; @@ -134,6 +142,7 @@ in 2 1 ]; + str = "3.2.1"; }; } ]; @@ -155,6 +164,7 @@ in 2 1 ]; + str = "3.2.1"; }; } { @@ -170,6 +180,7 @@ in 0 0 ]; + str = "4.0.0"; }; } ]; @@ -193,6 +204,7 @@ in 2 1 ]; + str = "3.2.1"; }; } { @@ -208,6 +220,7 @@ in 0 0 ]; + str = "4.0.0"; }; } { @@ -223,6 +236,7 @@ in 2 1 ]; + str = "3.2.1"; }; } { @@ -238,6 +252,7 @@ in 3 0 ]; + str = "3.3.0"; }; } ]; @@ -247,1965 +262,7 @@ in parseDependencies = { testParseDeps = { expr = parseDependencies fixtures."poetry.toml"; - expected = { - build-systems = [ - { - conditions = [ - { - op = ">="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 1 - 1 - 0 - ]; - }; - } - ]; - extras = [ ]; - markers = null; - name = "poetry-core"; - url = null; - } - ]; - dependencies = [ - { - conditions = [ - { - op = ">="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 1 - 0 - 2 - ]; - }; - } - { - op = "<"; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 2 - 0 - 0 - ]; - }; - } - ]; - extras = [ ]; - markers = { - lhs = { - lhs = { - type = "variable"; - value = "python_version"; - }; - op = "<"; - rhs = { - type = "version"; - value = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 3 - 8 - ]; - }; - }; - type = "compare"; - }; - op = "and"; - rhs = { - type = "bool"; - value = true; - }; - type = "boolOp"; - }; - name = "backports.cached-property"; - url = null; - } - { - conditions = [ - { - op = ">="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 0 - 10 - 0 - ]; - }; - } - { - op = "<"; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 0 - 11 - 0 - ]; - }; - } - ]; - extras = [ ]; - markers = null; - name = "build"; - url = null; - } - { - conditions = [ - { - op = ">="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 0 - 12 - 9 - ]; - }; - } - { - op = "<"; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 0 - 13 - 0 - ]; - }; - } - ]; - extras = [ "filecache" ]; - markers = null; - name = "cachecontrol"; - url = null; - } - { - conditions = [ - { - op = ">="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 2 - 0 - 0 - ]; - }; - } - { - op = "<"; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 3 - 0 - 0 - ]; - }; - } - ]; - extras = [ ]; - markers = null; - name = "cleo"; - url = null; - } - { - conditions = [ - { - op = ">="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 0 - 4 - 1 - ]; - }; - } - { - op = "<"; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 0 - 5 - 0 - ]; - }; - } - ]; - extras = [ ]; - markers = null; - name = "crashtest"; - url = null; - } - { - conditions = [ - { - op = ">="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 0 - 21 - 2 - ]; - }; - } - { - op = "<"; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 0 - 22 - 0 - ]; - }; - } - ]; - extras = [ ]; - markers = null; - name = "dulwich"; - url = null; - } - { - conditions = [ - { - op = ">="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 3 - 8 - 0 - ]; - }; - } - { - op = "<"; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 4 - 0 - 0 - ]; - }; - } - ]; - extras = [ ]; - markers = null; - name = "filelock"; - url = null; - } - { - conditions = [ - { - op = ">="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 1 - 0 - 0 - ]; - }; - } - { - op = "<"; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 2 - 0 - 0 - ]; - }; - } - ]; - extras = [ ]; - markers = null; - name = "html5lib"; - url = null; - } - { - conditions = [ - { - op = ">="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 4 - 4 - ]; - }; - } - ]; - extras = [ ]; - markers = { - lhs = { - lhs = { - type = "variable"; - value = "python_version"; - }; - op = "<"; - rhs = { - type = "version"; - value = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 3 - 10 - ]; - }; - }; - type = "compare"; - }; - op = "and"; - rhs = { - type = "bool"; - value = true; - }; - type = "boolOp"; - }; - name = "importlib-metadata"; - url = null; - } - { - conditions = [ - { - op = ">="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 0 - 7 - 0 - ]; - }; - } - { - op = "<"; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 0 - 8 - 0 - ]; - }; - } - ]; - extras = [ ]; - markers = null; - name = "installer"; - url = null; - } - { - conditions = [ - { - op = ">="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 4 - 10 - 0 - ]; - }; - } - { - op = "<"; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 5 - 0 - 0 - ]; - }; - } - ]; - extras = [ ]; - markers = null; - name = "jsonschema"; - url = null; - } - { - conditions = [ - { - op = ">="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 23 - 9 - 0 - ]; - }; - } - { - op = "<"; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 24 - 0 - 0 - ]; - }; - } - ]; - extras = [ ]; - markers = null; - name = "keyring"; - url = null; - } - { - conditions = [ - { - op = ">="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 0 - 12 - 2 - ]; - }; - } - { - op = "<"; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 0 - 13 - 0 - ]; - }; - } - ]; - extras = [ ]; - markers = null; - name = "lockfile"; - url = null; - } - { - conditions = [ - { - op = ">="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 20 - 4 - ]; - }; - } - ]; - extras = [ ]; - markers = null; - name = "packaging"; - url = null; - } - { - conditions = [ - { - op = ">="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 4 - 7 - 0 - ]; - }; - } - { - op = "<"; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 5 - 0 - 0 - ]; - }; - } - ]; - extras = [ ]; - markers = null; - name = "pexpect"; - url = null; - } - { - conditions = [ - { - op = ">="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 1 - 9 - 4 - ]; - }; - } - { - op = "<"; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 2 - 0 - 0 - ]; - }; - } - ]; - extras = [ ]; - markers = null; - name = "pkginfo"; - url = null; - } - { - conditions = [ - { - op = ">="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 2 - 5 - 2 - ]; - }; - } - { - op = "<"; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 3 - 0 - 0 - ]; - }; - } - ]; - extras = [ ]; - markers = null; - name = "platformdirs"; - url = null; - } - { - conditions = [ - { - op = "=="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 1 - 5 - 2 - ]; - }; - } - ]; - extras = [ ]; - markers = null; - name = "poetry-core"; - url = null; - } - { - conditions = [ - { - op = ">="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 1 - 3 - 0 - ]; - }; - } - { - op = "<"; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 2 - 0 - 0 - ]; - }; - } - ]; - extras = [ ]; - markers = null; - name = "poetry-plugin-export"; - url = null; - } - { - conditions = [ - { - op = ">="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 1 - 0 - 0 - ]; - }; - } - { - op = "<"; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 2 - 0 - 0 - ]; - }; - } - ]; - extras = [ ]; - markers = null; - name = "pyproject-hooks"; - url = null; - } - { - conditions = [ - { - op = ">="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 3 - 7 - 0 - ]; - }; - } - { - op = "<"; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 4 - 0 - 0 - ]; - }; - } - ]; - extras = [ ]; - markers = null; - name = "python"; - url = null; - } - { - conditions = [ - { - op = ">="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 2 - 18 - 0 - ]; - }; - } - { - op = "<"; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 3 - 0 - 0 - ]; - }; - } - ]; - extras = [ ]; - markers = null; - name = "requests"; - url = null; - } - { - conditions = [ - { - op = ">="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 0 - 9 - 1 - ]; - }; - } - { - op = "<"; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 0 - 11 - 0 - ]; - }; - } - ]; - extras = [ ]; - markers = null; - name = "requests-toolbelt"; - url = null; - } - { - conditions = [ - { - op = ">="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 1 - 5 - 0 - ]; - }; - } - { - op = "<"; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 2 - 0 - 0 - ]; - }; - } - ]; - extras = [ ]; - markers = null; - name = "shellingham"; - url = null; - } - { - conditions = [ - { - op = ">="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 2 - 0 - 1 - ]; - }; - } - { - op = "<"; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 3 - 0 - 0 - ]; - }; - } - ]; - extras = [ ]; - markers = { - lhs = { - lhs = { - type = "variable"; - value = "python_version"; - }; - op = "<"; - rhs = { - type = "version"; - value = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 3 - 11 - ]; - }; - }; - type = "compare"; - }; - op = "and"; - rhs = { - type = "bool"; - value = true; - }; - type = "boolOp"; - }; - name = "tomli"; - url = null; - } - { - conditions = [ - { - op = ">="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 0 - 11 - 1 - ]; - }; - } - { - op = "<"; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 1 - 0 - 0 - ]; - }; - } - { - op = "!="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 0 - 11 - 2 - ]; - }; - } - { - op = "!="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 0 - 11 - 3 - ]; - }; - } - ]; - extras = [ ]; - markers = null; - name = "tomlkit"; - url = null; - } - { - conditions = [ - { - op = ">="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 2022 - 5 - 19 - ]; - }; - } - ]; - extras = [ ]; - markers = null; - name = "trove-classifiers"; - url = null; - } - { - conditions = [ - { - op = ">="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 1 - 26 - 0 - ]; - }; - } - { - op = "<"; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 2 - 0 - 0 - ]; - }; - } - ]; - extras = [ ]; - markers = null; - name = "urllib3"; - url = null; - } - { - conditions = [ - { - op = ">="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 20 - 4 - 3 - ]; - }; - } - { - op = "<"; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 21 - 0 - 0 - ]; - }; - } - { - op = "!="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 20 - 4 - 5 - ]; - }; - } - { - op = "!="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 20 - 4 - 6 - ]; - }; - } - ]; - extras = [ ]; - markers = null; - name = "virtualenv"; - url = null; - } - { - conditions = [ - { - op = "<"; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 20 - 16 - 6 - ]; - }; - } - ]; - extras = [ ]; - markers = { - lhs = { - lhs = { - type = "variable"; - value = "sys_platform"; - }; - op = "=="; - rhs = { - type = "string"; - value = "win32"; - }; - type = "compare"; - }; - op = "and"; - rhs = { - lhs = { - type = "variable"; - value = "python_version"; - }; - op = "=="; - rhs = { - type = "version"; - value = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 3 - 9 - ]; - }; - }; - type = "compare"; - }; - type = "boolOp"; - }; - name = "virtualenv"; - url = null; - } - { - conditions = [ - { - op = ">="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 0 - 10 - 0 - ]; - }; - } - { - op = "<"; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 0 - 11 - 0 - ]; - }; - } - ]; - extras = [ ]; - markers = { - lhs = { - type = "variable"; - value = "sys_platform"; - }; - op = "=="; - rhs = { - type = "string"; - value = "darwin"; - }; - type = "compare"; - }; - name = "xattr"; - url = null; - } - ]; - extras = { - dev = [ - { - conditions = [ - { - op = ">="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 2 - 6 - 0 - ]; - }; - } - { - op = "<"; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 3 - 0 - 0 - ]; - }; - } - ]; - extras = [ ]; - markers = null; - name = "pre-commit"; - url = null; - } - ]; - github-actions = [ - { - conditions = [ - { - op = ">="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 0 - 1 - 7 - ]; - }; - } - { - op = "<"; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 0 - 2 - 0 - ]; - }; - } - ]; - extras = [ ]; - markers = null; - name = "pytest-github-actions-annotate-failures"; - url = null; - } - ]; - test = [ - { - conditions = [ - { - op = "=="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 0 - 3 - 0 - ]; - }; - } - ]; - extras = [ ]; - markers = null; - name = "cachy"; - url = null; - } - { - conditions = [ - { - op = ">="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 6 - 2 - 0 - ]; - }; - } - { - op = "<"; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 7 - 0 - 0 - ]; - }; - } - ]; - extras = [ ]; - markers = null; - name = "deepdiff"; - url = null; - } - { - conditions = [ - { - op = "<"; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 6 - 2 - 3 - ]; - }; - } - ]; - extras = [ ]; - markers = { - lhs = { - type = "variable"; - value = "platform_system"; - }; - op = "=="; - rhs = { - type = "string"; - value = "FreeBSD"; - }; - type = "compare"; - }; - name = "deepdiff"; - url = null; - } - { - conditions = [ - { - op = ">="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 1 - 0 - 0 - ]; - }; - } - { - op = "<"; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 2 - 0 - 0 - ]; - }; - } - ]; - extras = [ ]; - markers = null; - name = "httpretty"; - url = null; - } - { - conditions = [ - { - op = ">="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 7 - 1 - 0 - ]; - }; - } - { - op = "<"; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 8 - 0 - 0 - ]; - }; - } - ]; - extras = [ ]; - markers = null; - name = "pytest"; - url = null; - } - { - conditions = [ - { - op = ">="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 4 - 0 - 0 - ]; - }; - } - { - op = "<"; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 5 - 0 - 0 - ]; - }; - } - ]; - extras = [ ]; - markers = null; - name = "pytest-cov"; - url = null; - } - { - conditions = [ - { - op = ">="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 3 - 9 - 0 - ]; - }; - } - { - op = "<"; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 4 - 0 - 0 - ]; - }; - } - ]; - extras = [ ]; - markers = null; - name = "pytest-mock"; - url = null; - } - { - conditions = [ - { - op = ">="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 3 - 12 - 0 - ]; - }; - } - { - op = "<"; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 4 - 0 - 0 - ]; - }; - } - ]; - extras = [ ]; - markers = null; - name = "pytest-randomly"; - url = null; - } - { - conditions = [ - { - op = ">="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 3 - 1 - 0 - ]; - }; - } - { - op = "<"; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 4 - 0 - 0 - ]; - }; - } - ]; - extras = [ "psutil" ]; - markers = null; - name = "pytest-xdist"; - url = null; - } - { - conditions = [ - { - op = ">="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 3 - 4 - 0 - ]; - }; - } - { - op = "<"; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 4 - 0 - 0 - ]; - }; - } - ]; - extras = [ ]; - markers = { - lhs = { - lhs = { - type = "variable"; - value = "python_version"; - }; - op = "<"; - rhs = { - type = "version"; - value = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 3 - 8 - ]; - }; - }; - type = "compare"; - }; - op = "and"; - rhs = { - type = "bool"; - value = true; - }; - type = "boolOp"; - }; - name = "zipp"; - url = null; - } - ]; - typing = [ - { - conditions = [ - { - op = ">="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 1 - 0 - ]; - }; - } - ]; - extras = [ ]; - markers = null; - name = "mypy"; - url = null; - } - { - conditions = [ - { - op = ">="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 1 - 1 - 9 - ]; - }; - } - ]; - extras = [ ]; - markers = null; - name = "types-html5lib"; - url = null; - } - { - conditions = [ - { - op = ">="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 4 - 9 - 0 - ]; - }; - } - ]; - extras = [ ]; - markers = null; - name = "types-jsonschema"; - url = null; - } - { - conditions = [ - { - op = ">="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 2 - 28 - 8 - ]; - }; - } - ]; - extras = [ ]; - markers = null; - name = "types-requests"; - url = null; - } - { - conditions = [ - { - op = ">="; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 4 - 0 - 0 - ]; - }; - } - { - op = "<"; - version = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 5 - 0 - 0 - ]; - }; - } - ]; - extras = [ ]; - markers = { - lhs = { - lhs = { - type = "variable"; - value = "python_version"; - }; - op = "<"; - rhs = { - type = "version"; - value = { - dev = null; - epoch = 0; - local = null; - post = null; - pre = null; - release = [ - 3 - 8 - ]; - }; - }; - type = "compare"; - }; - op = "and"; - rhs = { - type = "bool"; - value = true; - }; - type = "boolOp"; - }; - name = "typing-extensions"; - url = null; - } - ]; - }; - }; + expected = importJSON ./expected/poetry.parseDependencies.testParseDeps.json; }; }; } diff --git a/lib/test_project.nix b/lib/test_project.nix index 30aba26..2290ba1 100644 --- a/lib/test_project.nix +++ b/lib/test_project.nix @@ -413,6 +413,7 @@ lib.fix (self: { 1 0 ]; + str = "10.1.0"; }; } ]; @@ -436,6 +437,7 @@ lib.fix (self: { 31 0 ]; + str = "2.31.0"; }; } ]; diff --git a/lib/test_validators.nix b/lib/test_validators.nix index ad7d827..35468fa 100644 --- a/lib/test_validators.nix +++ b/lib/test_validators.nix @@ -40,6 +40,7 @@ in 0 1 ]; + str = "1.0.1"; }; } ]; @@ -60,6 +61,7 @@ in 10 0 ]; + str = "0.10.0"; }; } ];