From 9dbedf02002c4ac4fcaadc973b443c5cac8f5b49 Mon Sep 17 00:00:00 2001 From: adisbladis Date: Fri, 10 Jan 2020 13:08:46 +0000 Subject: poetry2nix: 1.1.0 -> 1.2.0 --- pkgs/development/tools/poetry2nix/poetry2nix/pep508.nix | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'pkgs/development/tools/poetry2nix/poetry2nix/pep508.nix') 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 -- cgit 1.4.1