Skip to content

Commit

Permalink
fix: use pep508.parseString for requiredPkgs parsing
Browse files Browse the repository at this point in the history
PEP508 supports `requires` lines that have leading/trailing spaces, such
as:

    requires = ["poetry-core >=1.7.0"]

Poetry apparently handles this fine, but poetry2nix doesn't. This commit
uses proper parsing with the pep508 library.
  • Loading branch information
seirl authored and adisbladis committed Nov 14, 2023
1 parent 4b23549 commit c454b6f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib.nix
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ let
missingBuildBackendError = "No build-system.build-backend section in pyproject.toml. "
+ "Add such a section as described in https://python-poetry.org/docs/pyproject/#poetry-and-pep-517";
requires = lib.attrByPath [ "build-system" "requires" ] (throw missingBuildBackendError) pyProject;
requiredPkgs = builtins.map (n: lib.elemAt (builtins.match "([^!=<>~[]+).*" n) 0) requires;
requiredPkgs = builtins.map (n: (pyproject-nix.lib.pep508.parseString n).name) requires;
in
builtins.map (drvAttr: pythonPackages.${drvAttr} or (throw "unsupported build system requirement ${drvAttr}")) requiredPkgs;

Expand Down

0 comments on commit c454b6f

Please sign in to comment.