summary refs log tree commit diff
path: root/pkgs/top-level
diff options
context:
space:
mode:
authorFrederik Rietdijk <freddyrietdijk@fridh.nl>2017-12-11 09:46:15 +0100
committerGitHub <noreply@github.com>2017-12-11 09:46:15 +0100
commit35ccdb86323c6a43ed3281e43cb32a723700eab9 (patch)
tree5c59b904ad28c2e9a0624197585febbbfbd6d03d /pkgs/top-level
parent44f46a32930b08fcdf42e3670d5c476e191be1a5 (diff)
parentc86b19cb20f68e6b65af6ac884940ea125e4a8f8 (diff)
downloadnixlib-35ccdb86323c6a43ed3281e43cb32a723700eab9.tar
nixlib-35ccdb86323c6a43ed3281e43cb32a723700eab9.tar.gz
nixlib-35ccdb86323c6a43ed3281e43cb32a723700eab9.tar.bz2
nixlib-35ccdb86323c6a43ed3281e43cb32a723700eab9.tar.lz
nixlib-35ccdb86323c6a43ed3281e43cb32a723700eab9.tar.xz
nixlib-35ccdb86323c6a43ed3281e43cb32a723700eab9.tar.zst
nixlib-35ccdb86323c6a43ed3281e43cb32a723700eab9.zip
Merge pull request #32544 from FRidh/pythonmodule
Python: rewrite requiredPythonModules to prevent stack overflows
Diffstat (limited to 'pkgs/top-level')
-rw-r--r--pkgs/top-level/python-packages.nix17
1 files changed, 7 insertions, 10 deletions
diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix
index 5b10697deb43..d47d95aee90e 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";
@@ -87,15 +87,12 @@ let
     in fetcher (builtins.removeAttrs attrs ["format"]) );
 
   # Check whether a derivation provides a Python module.
-  hasPythonModule = drv: (hasAttr "pythonModule" drv) && ( (getAttr "pythonModule" drv) == python);
+  hasPythonModule = drv: drv?pythonModule && drv.pythonModule == python;
 
   # 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)));
+    modules = filter hasPythonModule 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 +103,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;
       };
     });
 
@@ -129,7 +126,7 @@ in {
 
   recursivePthLoader = callPackage ../development/python-modules/recursive-pth-loader { };
 
-  setuptools = callPackage ../development/python-modules/setuptools { };
+  setuptools = toPythonModule (callPackage ../development/python-modules/setuptools { });
 
   vowpalwabbit = callPackage ../development/python-modules/vowpalwabbit {
     pythonPackages = self;