poetry2nix: 1.1.0 -> 1.2.0

This commit is contained in:
adisbladis 2020-01-10 13:08:46 +00:00
parent 7fb6e4af36
commit 9dbedf0200
No known key found for this signature in database
GPG Key ID: 110BFAD44C6249B7
7 changed files with 64 additions and 75 deletions

View File

@ -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;
};
}

View File

@ -1,4 +1,5 @@
[
"egg",
"tar",
"tar.bz2",
"tar.gz",
@ -11,4 +12,4 @@
"txz",
"whl",
"zip"
]
]

View File

@ -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:

View File

@ -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

View File

@ -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;
}

View File

@ -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

View File

@ -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 = {