mirror of
https://github.com/vale981/poetry2nix
synced 2025-03-04 16:51:40 -05:00
Fix semver pythonVersion checks
We're only looking at the major.minor currently. We need to look major.minor.patch instead. This is made slighty problematic non-cpython where the patch version doesn't match. If major.minor is the same for both the Python version & the derivation version we default to derivation.version otherwise we set the pythonVersion to pythonVersion major.minor.0.
This commit is contained in:
parent
8d7d705aa0
commit
e164fdd78a
3 changed files with 13 additions and 3 deletions
|
@ -180,7 +180,7 @@ let
|
|||
# Get dependencies and filter out depending on interpreter version
|
||||
getDeps = depAttr:
|
||||
let
|
||||
compat = isCompatible py.pythonVersion;
|
||||
compat = isCompatible (poetryLib.getPythonVersion py);
|
||||
deps = pyProject.tool.poetry.${depAttr} or {};
|
||||
depAttrs = builtins.map (d: lib.toLower d) (builtins.attrNames deps);
|
||||
in
|
||||
|
|
10
lib.nix
10
lib.nix
|
@ -11,6 +11,15 @@ let
|
|||
# Do some canonicalisation of module names
|
||||
moduleName = name: lib.toLower (lib.replaceStrings [ "_" "." ] [ "-" "-" ] name);
|
||||
|
||||
# Get a full semver pythonVersion from a python derivation
|
||||
getPythonVersion = python: let
|
||||
pyVer = lib.splitVersion python.pythonVersion ++ [ "0" ];
|
||||
ver = lib.splitVersion python.version;
|
||||
major = l: lib.elemAt l 0;
|
||||
minor = l: lib.elemAt l 1;
|
||||
joinVersion = v: lib.concatStringsSep "." v;
|
||||
in joinVersion (if major pyVer == major ver && minor pyVer == minor ver then ver else pyVer);
|
||||
|
||||
# Compare a semver expression with a version
|
||||
isCompatible = version:
|
||||
let
|
||||
|
@ -145,5 +154,6 @@ in
|
|||
satisfiesSemver
|
||||
cleanPythonSources
|
||||
moduleName
|
||||
getPythonVersion
|
||||
;
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@ pythonPackages.callPackage (
|
|||
);
|
||||
|
||||
propagatedBuildInputs = let
|
||||
compat = isCompatible python.pythonVersion;
|
||||
compat = isCompatible (poetryLib.getPythonVersion python);
|
||||
deps = lib.filterAttrs (n: v: v) (
|
||||
lib.mapAttrs (
|
||||
n: v:
|
||||
|
@ -132,7 +132,7 @@ pythonPackages.callPackage (
|
|||
builtins.map (n: pythonPackages.${moduleName n}) depAttrs;
|
||||
|
||||
meta = {
|
||||
broken = ! isCompatible python.pythonVersion python-versions;
|
||||
broken = ! isCompatible (poetryLib.getPythonVersion python) python-versions;
|
||||
license = [];
|
||||
inherit (python.meta) platforms;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue