diff options
author | Alyssa Ross <hi@alyssa.is> | 2020-01-26 22:39:25 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2020-01-26 22:39:25 +0000 |
commit | bd2ad77e38991af0d7a3a5d82bd3f41a077ce401 (patch) | |
tree | d1e26d039eb5004eb7c836aafff259cc198626d4 /pkgs/development/tools/poetry2nix/poetry2nix/pep508.nix | |
parent | e5d8381542a8d084371d26013fab199f52474be7 (diff) | |
parent | ad3f0d9829119b611350a9be1c226fb625f1f310 (diff) | |
download | nixpkgs-bd2ad77e38991af0d7a3a5d82bd3f41a077ce401.tar nixpkgs-bd2ad77e38991af0d7a3a5d82bd3f41a077ce401.tar.gz nixpkgs-bd2ad77e38991af0d7a3a5d82bd3f41a077ce401.tar.bz2 nixpkgs-bd2ad77e38991af0d7a3a5d82bd3f41a077ce401.tar.lz nixpkgs-bd2ad77e38991af0d7a3a5d82bd3f41a077ce401.tar.xz nixpkgs-bd2ad77e38991af0d7a3a5d82bd3f41a077ce401.tar.zst nixpkgs-bd2ad77e38991af0d7a3a5d82bd3f41a077ce401.zip |
Merge remote-tracking branch 'nixpkgs/master' into master
Diffstat (limited to 'pkgs/development/tools/poetry2nix/poetry2nix/pep508.nix')
-rw-r--r-- | pkgs/development/tools/poetry2nix/poetry2nix/pep508.nix | 16 |
1 files changed, 12 insertions, 4 deletions
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 |