Python: rewrite requiredPythonModules. Add requiredPythonModules attribute to derivation

This commit is contained in:
Frederik Rietdijk 2017-12-10 14:20:38 +01:00
parent 87317bab0a
commit a334930490
3 changed files with 11 additions and 18 deletions

View File

@ -7,7 +7,7 @@
, setuptools , setuptools
, unzip , unzip
, ensureNewerSourcesHook , ensureNewerSourcesHook
, pythonModule , toPythonModule
, namePrefix , namePrefix
, bootstrapped-pip , bootstrapped-pip
, flit , flit
@ -19,7 +19,7 @@ let
wheel-specific = import ./build-python-package-wheel.nix { }; wheel-specific = import ./build-python-package-wheel.nix { };
common = import ./build-python-package-common.nix { inherit python bootstrapped-pip; }; common = import ./build-python-package-common.nix { inherit python bootstrapped-pip; };
mkPythonDerivation = import ./mk-python-derivation.nix { 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 in

View File

@ -7,7 +7,7 @@
, unzip , unzip
, ensureNewerSourcesHook , ensureNewerSourcesHook
# Whether the derivation provides a Python module or not. # Whether the derivation provides a Python module or not.
, pythonModule , toPythonModule
, namePrefix , namePrefix
}: }:
@ -54,7 +54,7 @@ if disabled
then throw "${name} not supported for interpreter ${python.executable}" then throw "${name} not supported for interpreter ${python.executable}"
else else
python.stdenv.mkDerivation (builtins.removeAttrs attrs [ toPythonModule (python.stdenv.mkDerivation (builtins.removeAttrs attrs [
"disabled" "checkInputs" "doCheck" "doInstallCheck" "dontWrapPythonPrograms" "catchConflicts" "disabled" "checkInputs" "doCheck" "doInstallCheck" "dontWrapPythonPrograms" "catchConflicts"
] // { ] // {
@ -84,14 +84,9 @@ python.stdenv.mkDerivation (builtins.removeAttrs attrs [
${python.interpreter} ${./catch_conflicts}/catch_conflicts.py ${python.interpreter} ${./catch_conflicts}/catch_conflicts.py
'' + attrs.postFixup or ''''; '' + attrs.postFixup or '''';
passthru = {
inherit python; # The python interpreter
inherit pythonModule;
} // passthru;
meta = { meta = {
# default to python's platforms # default to python's platforms
platforms = python.meta.platforms; platforms = python.meta.platforms;
isBuildPythonPackage = python.meta.platforms; isBuildPythonPackage = python.meta.platforms;
} // meta; } // meta;
}) }))

View File

@ -56,14 +56,14 @@ let
flit = self.flit; flit = self.flit;
# We want Python libraries to be named like e.g. "python3.6-${name}" # We want Python libraries to be named like e.g. "python3.6-${name}"
inherit namePrefix; inherit namePrefix;
pythonModule = python; inherit toPythonModule;
})); }));
buildPythonApplication = makeOverridablePythonPackage ( makeOverridable (callPackage ../development/interpreters/python/build-python-package.nix { buildPythonApplication = makeOverridablePythonPackage ( makeOverridable (callPackage ../development/interpreters/python/build-python-package.nix {
inherit bootstrapped-pip; inherit bootstrapped-pip;
flit = self.flit; flit = self.flit;
namePrefix = ""; namePrefix = "";
pythonModule = false; toPythonModule = x: x; # Application does not provide modules.
})); }));
graphiteVersion = "1.0.2"; graphiteVersion = "1.0.2";
@ -91,11 +91,9 @@ let
# Get list of required Python modules given a list of derivations. # Get list of required Python modules given a list of derivations.
requiredPythonModules = drvs: let requiredPythonModules = drvs: let
filterNull = list: filter (x: !isNull x) list; removeNull = list: filter (x: !isNull x) list;
conditionalGetRecurse = attr: condition: drv: let f = conditionalGetRecurse attr condition; in modules = filter hasPythonModule (removeNull drvs);
(if (condition drv) then unique [drv]++(concatMap f (filterNull(getAttr attr drv))) else []); in unique ([python] ++ modules ++ concatLists (catAttrs "requiredPythonModules" modules));
_required = drv: conditionalGetRecurse "propagatedBuildInputs" hasPythonModule drv;
in [python] ++ (unique (concatMap _required (filterNull drvs)));
# Create a PYTHONPATH from a list of derivations. This function recurses into the items to find derivations # Create a PYTHONPATH from a list of derivations. This function recurses into the items to find derivations
# providing Python modules. # providing Python modules.
@ -106,9 +104,9 @@ let
drv.overrideAttrs( oldAttrs: { drv.overrideAttrs( oldAttrs: {
# Use passthru in order to prevent rebuilds when possible. # Use passthru in order to prevent rebuilds when possible.
passthru = (oldAttrs.passthru or {})// { passthru = (oldAttrs.passthru or {})// {
name = namePrefix + oldAttrs.name;
pythonModule = python; pythonModule = python;
pythonPath = [ ]; # Deprecated, for compatibility. pythonPath = [ ]; # Deprecated, for compatibility.
requiredPythonModules = requiredPythonModules drv.propagatedBuildInputs;
}; };
}); });