mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-07-20 23:51:03 +00:00
buildPython*: allow stdenv customization through <function>.override
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
lib,
|
||||
config,
|
||||
python,
|
||||
# Allow passing in a custom stdenv to buildPython*.override
|
||||
stdenv,
|
||||
wrapPython,
|
||||
unzip,
|
||||
ensureNewerSourcesForZipFilesHook,
|
||||
@@ -192,9 +194,6 @@ in
|
||||
|
||||
doCheck ? true,
|
||||
|
||||
# Allow passing in a custom stdenv to buildPython*
|
||||
stdenv ? python.stdenv,
|
||||
|
||||
...
|
||||
}@attrs:
|
||||
|
||||
|
||||
@@ -45,21 +45,42 @@ let
|
||||
override = lib.mirrorFunctionArgs f.override (fdrv: makeOverridablePythonPackage (f.override fdrv));
|
||||
};
|
||||
|
||||
overrideStdenvCompat =
|
||||
f:
|
||||
lib.setFunctionArgs (
|
||||
args:
|
||||
if !(lib.isFunction args) && (args ? stdenv) then
|
||||
# TODO: warn that `args ? stdenv` is deprecated (once in-tree usage is migrated)
|
||||
f.override { stdenv = args.stdenv; } args
|
||||
else
|
||||
f args
|
||||
) (removeAttrs (lib.functionArgs f) [ "stdenv" ])
|
||||
// {
|
||||
# Intentionally drop the effect of overrideStdenvCompat when calling `buildPython*.override`.
|
||||
inherit (f) override;
|
||||
};
|
||||
|
||||
mkPythonDerivation =
|
||||
if python.isPy3k then ./mk-python-derivation.nix else ./python2/mk-python-derivation.nix;
|
||||
|
||||
buildPythonPackage = makeOverridablePythonPackage (
|
||||
callPackage mkPythonDerivation {
|
||||
inherit namePrefix; # We want Python libraries to be named like e.g. "python3.6-${name}"
|
||||
inherit toPythonModule; # Libraries provide modules
|
||||
}
|
||||
overrideStdenvCompat (
|
||||
callPackage mkPythonDerivation {
|
||||
inherit namePrefix; # We want Python libraries to be named like e.g. "python3.6-${name}"
|
||||
inherit toPythonModule; # Libraries provide modules
|
||||
inherit (python) stdenv;
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
buildPythonApplication = makeOverridablePythonPackage (
|
||||
callPackage mkPythonDerivation {
|
||||
namePrefix = ""; # Python applications should not have any prefix
|
||||
toPythonModule = x: x; # Application does not provide modules.
|
||||
}
|
||||
overrideStdenvCompat (
|
||||
callPackage mkPythonDerivation {
|
||||
namePrefix = ""; # Python applications should not have any prefix
|
||||
toPythonModule = x: x; # Application does not provide modules.
|
||||
inherit (python) stdenv;
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
# Check whether a derivation provides a Python module.
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
lib,
|
||||
config,
|
||||
python,
|
||||
# Allow passing in a custom stdenv to buildPython*.override
|
||||
stdenv,
|
||||
wrapPython,
|
||||
unzip,
|
||||
ensureNewerSourcesForZipFilesHook,
|
||||
@@ -101,8 +103,6 @@
|
||||
}@attrs:
|
||||
|
||||
let
|
||||
inherit (python) stdenv;
|
||||
|
||||
withDistOutput = lib.elem format [
|
||||
"pyproject"
|
||||
"setuptools"
|
||||
|
||||
Reference in New Issue
Block a user