diff --git a/pkgs/development/interpreters/python/build-python-package.nix b/pkgs/development/interpreters/python/build-python-package.nix index 982542c1fc3..12d17b2e832 100644 --- a/pkgs/development/interpreters/python/build-python-package.nix +++ b/pkgs/development/interpreters/python/build-python-package.nix @@ -7,7 +7,7 @@ , setuptools , unzip , ensureNewerSourcesHook -, pythonModule +, toPythonModule , namePrefix , bootstrapped-pip , flit @@ -19,7 +19,7 @@ let wheel-specific = import ./build-python-package-wheel.nix { }; common = import ./build-python-package-common.nix { inherit python bootstrapped-pip; }; mkPythonDerivation = import ./mk-python-derivation.nix { - inherit lib python wrapPython setuptools unzip ensureNewerSourcesHook pythonModule namePrefix; + inherit lib python wrapPython setuptools unzip ensureNewerSourcesHook toPythonModule namePrefix; }; in diff --git a/pkgs/development/interpreters/python/mk-python-derivation.nix b/pkgs/development/interpreters/python/mk-python-derivation.nix index 1fd6745093b..5f7348ac825 100644 --- a/pkgs/development/interpreters/python/mk-python-derivation.nix +++ b/pkgs/development/interpreters/python/mk-python-derivation.nix @@ -7,7 +7,7 @@ , unzip , ensureNewerSourcesHook # Whether the derivation provides a Python module or not. -, pythonModule +, toPythonModule , namePrefix }: @@ -60,7 +60,7 @@ if disabled then throw "${name} not supported for interpreter ${python.executable}" else -python.stdenv.mkDerivation (builtins.removeAttrs attrs [ +toPythonModule (python.stdenv.mkDerivation (builtins.removeAttrs attrs [ "disabled" "checkInputs" "doCheck" "doInstallCheck" "dontWrapPythonPrograms" "catchConflicts" ] // { @@ -95,14 +95,9 @@ python.stdenv.mkDerivation (builtins.removeAttrs attrs [ ${python.interpreter} ${./catch_conflicts}/catch_conflicts.py '' + attrs.postFixup or ''''; - passthru = { - inherit python; # The python interpreter - inherit pythonModule; - } // passthru; - meta = { # default to python's platforms platforms = python.meta.platforms; isBuildPythonPackage = python.meta.platforms; } // meta; -}) +})) diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 5b10697deb4..d47d95aee90 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;