Merge pull request #271597 from adisbladis/python-runtime-build-time-sep
python3.pkgs.buildPythonPackage: Separate runtime & build time dependencies
This commit is contained in:
@@ -45,6 +45,14 @@
|
||||
# C can import package A propagated by B
|
||||
, propagatedBuildInputs ? []
|
||||
|
||||
# Python module dependencies.
|
||||
# These are named after PEP-621.
|
||||
, dependencies ? []
|
||||
, optional-dependencies ? {}
|
||||
|
||||
# Python PEP-517 build systems.
|
||||
, build-system ? []
|
||||
|
||||
# DEPRECATED: use propagatedBuildInputs
|
||||
, pythonPath ? []
|
||||
|
||||
@@ -97,8 +105,6 @@
|
||||
|
||||
, meta ? {}
|
||||
|
||||
, passthru ? {}
|
||||
|
||||
, doCheck ? config.doCheckByDefault or false
|
||||
|
||||
, disabledTestPaths ? []
|
||||
@@ -193,10 +199,28 @@ let
|
||||
"setuptools" "wheel"
|
||||
];
|
||||
|
||||
passthru =
|
||||
attrs.passthru or { }
|
||||
// {
|
||||
updateScript = let
|
||||
filename = builtins.head (lib.splitString ":" self.meta.position);
|
||||
in attrs.passthru.updateScript or [ update-python-libraries filename ];
|
||||
}
|
||||
// lib.optionalAttrs (dependencies != []) {
|
||||
inherit dependencies;
|
||||
}
|
||||
// lib.optionalAttrs (optional-dependencies != {}) {
|
||||
inherit optional-dependencies;
|
||||
}
|
||||
// lib.optionalAttrs (build-system != []) {
|
||||
inherit build-system;
|
||||
};
|
||||
|
||||
# Keep extra attributes from `attrs`, e.g., `patchPhase', etc.
|
||||
self = toPythonModule (stdenv.mkDerivation ((builtins.removeAttrs attrs [
|
||||
"disabled" "checkPhase" "checkInputs" "nativeCheckInputs" "doCheck" "doInstallCheck" "dontWrapPythonPrograms" "catchConflicts" "pyproject" "format"
|
||||
"disabledTestPaths" "outputs" "stdenv"
|
||||
"dependencies" "optional-dependencies" "build-system"
|
||||
]) // {
|
||||
|
||||
name = namePrefix + name_;
|
||||
@@ -256,11 +280,11 @@ let
|
||||
pythonNamespacesHook
|
||||
] ++ lib.optionals withDistOutput [
|
||||
pythonOutputDistHook
|
||||
] ++ nativeBuildInputs;
|
||||
] ++ nativeBuildInputs ++ build-system;
|
||||
|
||||
buildInputs = validatePythonMatches "buildInputs" (buildInputs ++ pythonPath);
|
||||
|
||||
propagatedBuildInputs = validatePythonMatches "propagatedBuildInputs" (propagatedBuildInputs ++ [
|
||||
propagatedBuildInputs = validatePythonMatches "propagatedBuildInputs" (propagatedBuildInputs ++ dependencies ++ [
|
||||
# we propagate python even for packages transformed with 'toPythonApplication'
|
||||
# this pollutes the PATH but avoids rebuilds
|
||||
# see https://github.com/NixOS/nixpkgs/issues/170887 for more context
|
||||
@@ -292,6 +316,8 @@ let
|
||||
|
||||
outputs = outputs ++ lib.optional withDistOutput "dist";
|
||||
|
||||
inherit passthru;
|
||||
|
||||
meta = {
|
||||
# default to python's platforms
|
||||
platforms = python.meta.platforms;
|
||||
@@ -305,13 +331,7 @@ let
|
||||
disabledTestPaths = lib.escapeShellArgs disabledTestPaths;
|
||||
}));
|
||||
|
||||
passthru.updateScript = let
|
||||
filename = builtins.head (lib.splitString ":" self.meta.position);
|
||||
in attrs.passthru.updateScript or [ update-python-libraries filename ];
|
||||
in
|
||||
if disabled then
|
||||
throw "${name} not supported for interpreter ${python.executable}"
|
||||
else
|
||||
self.overrideAttrs (attrs: {
|
||||
passthru = lib.recursiveUpdate passthru attrs.passthru;
|
||||
})
|
||||
in lib.extendDerivation
|
||||
(disabled -> throw "${name} not supported for interpreter ${python.executable}")
|
||||
passthru
|
||||
self
|
||||
|
||||
Reference in New Issue
Block a user