diff options
author | adisbladis <adisbladis@gmail.com> | 2020-01-10 13:08:46 +0000 |
---|---|---|
committer | adisbladis <adisbladis@gmail.com> | 2020-01-10 13:35:44 +0000 |
commit | 9dbedf02002c4ac4fcaadc973b443c5cac8f5b49 (patch) | |
tree | 993709ab0e2b7aae255ad9b1affddfe2cf2c88fb /pkgs/development/tools | |
parent | 7fb6e4af36a1c1cf7fba1d3784ba06e0faa808c2 (diff) | |
download | nixpkgs-9dbedf02002c4ac4fcaadc973b443c5cac8f5b49.tar nixpkgs-9dbedf02002c4ac4fcaadc973b443c5cac8f5b49.tar.gz nixpkgs-9dbedf02002c4ac4fcaadc973b443c5cac8f5b49.tar.bz2 nixpkgs-9dbedf02002c4ac4fcaadc973b443c5cac8f5b49.tar.lz nixpkgs-9dbedf02002c4ac4fcaadc973b443c5cac8f5b49.tar.xz nixpkgs-9dbedf02002c4ac4fcaadc973b443c5cac8f5b49.tar.zst nixpkgs-9dbedf02002c4ac4fcaadc973b443c5cac8f5b49.zip |
poetry2nix: 1.1.0 -> 1.2.0
Diffstat (limited to 'pkgs/development/tools')
7 files changed, 64 insertions, 75 deletions
diff --git a/pkgs/development/tools/poetry2nix/poetry2nix/default.nix b/pkgs/development/tools/poetry2nix/poetry2nix/default.nix index 967f0d666cb..8e0e861fab3 100644 --- a/pkgs/development/tools/poetry2nix/poetry2nix/default.nix +++ b/pkgs/development/tools/poetry2nix/poetry2nix/default.nix @@ -14,7 +14,7 @@ let defaultPoetryOverrides = (import ./overrides.nix { inherit pkgs lib; }); mkEvalPep508 = import ./pep508.nix { - inherit lib; + inherit lib poetryLib; stdenv = pkgs.stdenv; }; @@ -247,6 +247,7 @@ in overrideOverlay = fn: self: super: let defaultSet = defaultPoetryOverrides self super; customSet = fn self super; - in defaultSet // customSet; + in + defaultSet // customSet; }; } diff --git a/pkgs/development/tools/poetry2nix/poetry2nix/extensions.json b/pkgs/development/tools/poetry2nix/poetry2nix/extensions.json index 2cce8e2ea08..33052efe296 100644 --- a/pkgs/development/tools/poetry2nix/poetry2nix/extensions.json +++ b/pkgs/development/tools/poetry2nix/poetry2nix/extensions.json @@ -1,4 +1,5 @@ [ + "egg", "tar", "tar.bz2", "tar.gz", @@ -11,4 +12,4 @@ "txz", "whl", "zip" -] \ No newline at end of file +] diff --git a/pkgs/development/tools/poetry2nix/poetry2nix/lib.nix b/pkgs/development/tools/poetry2nix/poetry2nix/lib.nix index 9ec76defb7d..3d0b80c4c5a 100644 --- a/pkgs/development/tools/poetry2nix/poetry2nix/lib.nix +++ b/pkgs/development/tools/poetry2nix/poetry2nix/lib.nix @@ -1,6 +1,12 @@ { lib, pkgs }: let - inherit (import ./semver.nix { inherit lib; }) satisfiesSemver; + inherit (import ./semver.nix { inherit lib ireplace; }) satisfiesSemver; + inherit (builtins) genList length; + + # Replace a list entry at defined index with set value + ireplace = idx: value: list: ( + genList (i: if i == idx then value else (builtins.elemAt list i)) (length list) + ); # Returns true if pythonVersion matches with the expression in pythonVersions isCompatible = pythonVersion: pythonVersions: diff --git a/pkgs/development/tools/poetry2nix/poetry2nix/mk-poetry-dep.nix b/pkgs/development/tools/poetry2nix/poetry2nix/mk-poetry-dep.nix index 3631cbd228e..256e2d90daa 100644 --- a/pkgs/development/tools/poetry2nix/poetry2nix/mk-poetry-dep.nix +++ b/pkgs/development/tools/poetry2nix/poetry2nix/mk-poetry-dep.nix @@ -30,8 +30,9 @@ supportedRegex = ("^.*?(" + builtins.concatStringsSep "|" supportedExtensions + ")"); matchesVersion = fname: builtins.match ("^.*" + builtins.replaceStrings [ "." ] [ "\\." ] version + ".*$") fname != null; hasSupportedExtension = fname: builtins.match supportedRegex fname != null; + isCompatibleEgg = fname: ! lib.strings.hasSuffix ".egg" fname || lib.strings.hasSuffix "py${python.pythonVersion}.egg" fname; in - builtins.filter (f: matchesVersion f.file && hasSupportedExtension f.file) files; + builtins.filter (f: matchesVersion f.file && hasSupportedExtension f.file && isCompatibleEgg f.file) files; toPath = s: pwd + "/${s}"; @@ -48,19 +49,35 @@ fileInfo = let isBdist = f: lib.strings.hasSuffix "whl" f.file; - isSdist = f: ! isBdist f; + isSdist = f: ! isBdist f && ! isEgg f; + isEgg = f: lib.strings.hasSuffix ".egg" f.file; + binaryDist = selectWheel fileCandidates; sourceDist = builtins.filter isSdist fileCandidates; - lockFileEntry = if (builtins.length sourceDist) > 0 then builtins.head sourceDist else builtins.head binaryDist; + eggs = builtins.filter isEgg fileCandidates; + + lockFileEntry = builtins.head (sourceDist ++ binaryDist ++ eggs); + + _isEgg = isEgg lockFileEntry; + in rec { inherit (lockFileEntry) file hash; name = file; - format = if lib.strings.hasSuffix ".whl" name then "wheel" else "setuptools"; - kind = if format == "setuptools" then "source" else (builtins.elemAt (lib.strings.splitString "-" name) 2); + format = + if _isEgg then "egg" + else if lib.strings.hasSuffix ".whl" name then "wheel" + else "setuptools"; + kind = + if _isEgg then python.pythonVersion + else if format == "setuptools" then "source" + else (builtins.elemAt (lib.strings.splitString "-" name) 2); }; + baseBuildInputs = lib.optional (name != "setuptools_scm" && name != "setuptools-scm") pythonPackages.setuptools_scm; + in + buildPythonPackage { pname = name; version = version; @@ -70,7 +87,7 @@ buildPythonPackage { format = if isLocal then "pyproject" else if isGit then "setuptools" else fileInfo.format; nativeBuildInputs = if (!isSource && (getManyLinuxDeps fileInfo.name).str != null) then [ autoPatchelfHook ] else []; - buildInputs = if !isSource then (getManyLinuxDeps fileInfo.name).pkg else []; + buildInputs = baseBuildInputs ++ (if !isSource then (getManyLinuxDeps fileInfo.name).pkg else []); propagatedBuildInputs = let diff --git a/pkgs/development/tools/poetry2nix/poetry2nix/overrides.nix b/pkgs/development/tools/poetry2nix/poetry2nix/overrides.nix index 84d77cef3b5..207841fd005 100644 --- a/pkgs/development/tools/poetry2nix/poetry2nix/overrides.nix +++ b/pkgs/development/tools/poetry2nix/poetry2nix/overrides.nix @@ -7,14 +7,6 @@ self: super: let - addSetupTools = drv: if drv == null then null else drv.overrideAttrs ( - old: { - buildInputs = old.buildInputs ++ [ - self.setuptools_scm - ]; - } - ); - getAttrDefault = attribute: set: default: if builtins.hasAttr attribute set then builtins.getAttr attribute set @@ -22,15 +14,6 @@ let in { - - asciimatics = super.asciimatics.overrideAttrs ( - old: { - buildInputs = old.buildInputs ++ [ - self.setuptools_scm - ]; - } - ); - av = super.av.overrideAttrs ( old: { nativeBuildInputs = old.nativeBuildInputs ++ [ @@ -60,10 +43,6 @@ in } ); - configparser = addSetupTools super.configparser; - - cbor2 = addSetupTools super.cbor2; - cryptography = super.cryptography.overrideAttrs ( old: { buildInputs = old.buildInputs ++ [ pkgs.openssl ]; @@ -106,22 +85,6 @@ in } ); - hypothesis = addSetupTools super.hypothesis; - - importlib-metadata = addSetupTools super.importlib-metadata; - - inflect = super.inflect.overrideAttrs ( - old: { - buildInputs = old.buildInputs ++ [ - self.setuptools_scm - ]; - } - ); - - jsonschema = addSetupTools super.jsonschema; - - keyring = addSetupTools super.keyring; - lap = super.lap.overrideAttrs ( old: { propagatedBuildInputs = old.propagatedBuildInputs ++ [ @@ -243,7 +206,7 @@ in in { nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.gfortran ]; - buildInputs = old.buildInputs ++ [ blas ]; + buildInputs = old.buildInputs ++ [ blas self.cython ]; enableParallelBuilding = true; preBuild = '' ln -s ${cfg} site.cfg @@ -262,8 +225,6 @@ in } ); - pluggy = addSetupTools super.pluggy; - psycopg2 = super.psycopg2.overrideAttrs ( old: { nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.postgresql ]; @@ -276,8 +237,6 @@ in } ); - py = addSetupTools super.py; - pyarrow = super.pyarrow.overrideAttrs ( old: { buildInputs = old.buildInputs ++ [ @@ -334,16 +293,9 @@ in } ); - pytest = addSetupTools super.pytest; - - pytest-mock = addSetupTools super.pytest-mock; - - python-dateutil = addSetupTools super.python-dateutil; - python-prctl = super.python-prctl.overrideAttrs ( old: { buildInputs = old.buildInputs ++ [ - self.setuptools_scm pkgs.libcap ]; } @@ -380,8 +332,6 @@ in } ); - six = addSetupTools super.six; - urwidtrees = super.urwidtrees.overrideAttrs ( old: { propagatedBuildInputs = old.propagatedBuildInputs ++ [ @@ -390,7 +340,7 @@ in } ); - # TODO: Figure out getting rid of this hack + # Stop infinite recursion by using bootstrapped pkg from nixpkgs wheel = ( pkgs.python3.pkgs.override { python = self.python; @@ -401,5 +351,4 @@ in } ); - zipp = addSetupTools super.zipp; } diff --git a/pkgs/development/tools/poetry2nix/poetry2nix/pep508.nix b/pkgs/development/tools/poetry2nix/poetry2nix/pep508.nix index bf1893931cd..93a395326eb 100644 --- a/pkgs/development/tools/poetry2nix/poetry2nix/pep508.nix +++ b/pkgs/development/tools/poetry2nix/poetry2nix/pep508.nix @@ -1,6 +1,7 @@ -{ lib, stdenv }: python: +{ lib, stdenv, poetryLib }: python: let + inherit (poetryLib) ireplace; # Like builtins.substring but with stop being offset instead of length substr = start: stop: s: builtins.substring start (stop - start) s; @@ -142,7 +143,6 @@ let else builtins.fromJSON v ); hasElem = needle: haystack: builtins.elem needle (builtins.filter (x: builtins.typeOf x == "string") (builtins.split " " haystack)); - # TODO: Implement all operators op = { "<=" = x: y: (unmarshal x) <= (unmarshal y); "<" = x: y: (unmarshal x) < (unmarshal y); @@ -150,8 +150,16 @@ let "==" = x: y: x == y; ">=" = x: y: (unmarshal x) >= (unmarshal y); ">" = x: y: (unmarshal x) > (unmarshal y); - "~=" = null; - "===" = null; + "~=" = v: c: let + parts = builtins.splitVersion c; + pruned = lib.take ((builtins.length parts) - 1) parts; + upper = builtins.toString ( + (lib.toInt (builtins.elemAt pruned (builtins.length pruned - 1))) + 1 + ); + upperConstraint = builtins.concatStringsSep "." (ireplace (builtins.length pruned - 1) upper pruned); + in + op.">=" v c && op."<" v upperConstraint; + "===" = x: y: x == y; "in" = x: y: let values = builtins.filter (x: builtins.typeOf x == "string") (builtins.split " " (unmarshal y)); in diff --git a/pkgs/development/tools/poetry2nix/poetry2nix/semver.nix b/pkgs/development/tools/poetry2nix/poetry2nix/semver.nix index 620bb25ad97..784589a4ca4 100644 --- a/pkgs/development/tools/poetry2nix/poetry2nix/semver.nix +++ b/pkgs/development/tools/poetry2nix/poetry2nix/semver.nix @@ -1,14 +1,8 @@ -{ lib }: +{ lib, ireplace }: let inherit (builtins) elemAt match; - # Replace a list entry at defined index with set value - ireplace = idx: value: list: let - inherit (builtins) genList length; - in - genList (i: if i == idx then value else (elemAt list i)) (length list); - operators = let matchWildCard = s: match "([^\*])(\.[\*])" s; mkComparison = ret: version: v: builtins.compareVersions version v == ret; @@ -37,10 +31,23 @@ let ">=" = v: c: operators."==" v c || operators.">" v c; "<=" = v: c: operators."==" v c || operators."<" v c; # Semver specific operators - "~" = mkIdxComparison 1; # + "~" = mkIdxComparison 1; "^" = mkIdxComparison 0; + "~=" = v: c: let + # Prune constraint + parts = builtins.splitVersion c; + pruned = lib.take ((builtins.length parts) - 1) parts; + upper = builtins.toString ( + (lib.toInt (builtins.elemAt pruned (builtins.length pruned - 1))) + 1 + ); + upperConstraint = builtins.concatStringsSep "." (ireplace (builtins.length pruned - 1) upper pruned); + in + operators.">=" v c && operators."<" v upperConstraint; # Infix operators "-" = version: v: operators.">=" version v.vl && operators."<=" version v.vu; + # Arbitrary equality clause, just run simple comparison + "===" = v: c: v == c; + # }; re = { |