summary refs log tree commit diff
path: root/pkgs/top-level
diff options
context:
space:
mode:
authorFrederik Rietdijk <fridh@fridh.nl>2017-12-10 14:20:38 +0100
committerFrederik Rietdijk <fridh@fridh.nl>2017-12-10 20:40:34 +0100
commita3349304909aee736bc9a9ad1c35d698a27df23d (patch)
tree3c931d919c248e6c275cca44c0d5d283d3e95a19 /pkgs/top-level
parent87317bab0a796b3c8301f27acfbf48a782d5dde0 (diff)
downloadnixlib-a3349304909aee736bc9a9ad1c35d698a27df23d.tar
nixlib-a3349304909aee736bc9a9ad1c35d698a27df23d.tar.gz
nixlib-a3349304909aee736bc9a9ad1c35d698a27df23d.tar.bz2
nixlib-a3349304909aee736bc9a9ad1c35d698a27df23d.tar.lz
nixlib-a3349304909aee736bc9a9ad1c35d698a27df23d.tar.xz
nixlib-a3349304909aee736bc9a9ad1c35d698a27df23d.tar.zst
nixlib-a3349304909aee736bc9a9ad1c35d698a27df23d.zip
Python: rewrite requiredPythonModules. Add requiredPythonModules attribute to derivation
Diffstat (limited to 'pkgs/top-level')
-rw-r--r--pkgs/top-level/python-packages.nix14
1 files changed, 6 insertions, 8 deletions
diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix
index b4e4e274893e..7068ccedb73a 100644
--- a/pkgs/top-level/python-packages.nix
+++ b/pkgs/top-level/python-packages.nix
@@ -56,14 +56,14 @@ let
     flit = self.flit;
     # We want Python libraries to be named like e.g. "python3.6-${name}"
     inherit namePrefix;
-    pythonModule = python;
+    inherit toPythonModule;
   }));
 
   buildPythonApplication = makeOverridablePythonPackage ( makeOverridable (callPackage ../development/interpreters/python/build-python-package.nix {
     inherit bootstrapped-pip;
     flit = self.flit;
     namePrefix = "";
-    pythonModule = false;
+    toPythonModule = x: x; # Application does not provide modules.
   }));
 
   graphiteVersion = "1.0.2";
@@ -91,11 +91,9 @@ let
 
   # Get list of required Python modules given a list of derivations.
   requiredPythonModules = drvs: let
-    filterNull = list: filter (x: !isNull x) list;
-    conditionalGetRecurse = attr: condition: drv: let f = conditionalGetRecurse attr condition; in
-      (if (condition drv) then unique [drv]++(concatMap f (filterNull(getAttr attr drv))) else []);
-    _required = drv: conditionalGetRecurse "propagatedBuildInputs" hasPythonModule drv;
-  in [python] ++ (unique (concatMap _required (filterNull drvs)));
+    removeNull = list: filter (x: !isNull x) list;
+    modules = filter hasPythonModule (removeNull drvs);
+  in unique ([python] ++ modules ++ concatLists (catAttrs "requiredPythonModules" modules));
 
   # Create a PYTHONPATH from a list of derivations. This function recurses into the items to find derivations
   # providing Python modules.
@@ -106,9 +104,9 @@ let
     drv.overrideAttrs( oldAttrs: {
       # Use passthru in order to prevent rebuilds when possible.
       passthru = (oldAttrs.passthru or {})// {
-        name = namePrefix + oldAttrs.name;
         pythonModule = python;
         pythonPath = [ ]; # Deprecated, for compatibility.
+        requiredPythonModules = requiredPythonModules drv.propagatedBuildInputs;
       };
     });