Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 20 additions & 15 deletions pkgs/development/interpreters/python/python-packages-base.nix
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,30 @@ let
// {
# Support overriding `f` itself, e.g. `buildPythonPackage.override { }`.
# Ensure `makeOverridablePythonPackage` is applied to the result.
override = lib.mirrorFunctionArgs f.override (fdrv: makeOverridablePythonPackage (f.override fdrv));
override = lib.mirrorFunctionArgs f.override (
newArgs: makeOverridablePythonPackage (f.override newArgs)
);
};

overrideStdenvCompat =
f:
lib.setFunctionArgs (
args:
if !(lib.isFunction args) && (args ? stdenv) then
lib.warnIf (lib.oldestSupportedReleaseIsAtLeast 2511) ''
Passing `stdenv` directly to `buildPythonPackage` or `buildPythonApplication` is deprecated. You should use their `.override` function instead, e.g:
buildPythonPackage.override { stdenv = customStdenv; } { }
'' (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;
};
lib.fix (
f':
lib.mirrorFunctionArgs f (
args:
if !(lib.isFunction args) && (args ? stdenv) then
lib.warnIf (lib.oldestSupportedReleaseIsAtLeast 2511) ''
Passing `stdenv` directly to `buildPythonPackage` or `buildPythonApplication` is deprecated. You should use their `.override` function instead, e.g:
buildPythonPackage.override { stdenv = customStdenv; } { }
'' (f'.override { inherit (args) stdenv; } (removeAttrs args [ "stdenv" ]))
else
f args
)
// {
# Preserve the effect of overrideStdenvCompat when calling `buildPython*.override`.
override = lib.mirrorFunctionArgs f.override (newArgs: overrideStdenvCompat (f.override newArgs));
}
);

mkPythonDerivation =
if python.isPy3k then ./mk-python-derivation.nix else ./python2/mk-python-derivation.nix;
Expand Down
7 changes: 7 additions & 0 deletions pkgs/test/overriding.nix
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,13 @@ let
})).stdenv;
expected = pkgs.clangStdenv;
};
overridePythonAttrs-override-clangStdenv-deprecated-nested = {
expr =
(package-stub-gcc.overridePythonAttrs {
stdenv = pkgs.clangStdenv;
}).stdenv;
expected = pkgs.clangStdenv;
};

overridePythonAttrs = {
expr = (applyOverridePythonAttrs package-stub).overridePythonAttrsFlag;
Expand Down
Loading