Skip to content

Commit

Permalink
python-packages-base: use extends instead of //
Browse files Browse the repository at this point in the history
// shouldn't be used when overrideAttrs is available

here we can use extends instead of overrideAttrs for performance
  • Loading branch information
Artturin committed Jan 20, 2023
1 parent 5b2f597 commit b94fa2c
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions pkgs/development/interpreters/python/python-packages-base.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,22 @@ let
# This function introduces `overridePythonAttrs` and it overrides the call to `buildPythonPackage`.
makeOverridablePythonPackage = f: origArgs:
let
ff = f origArgs;
overrideWith = newArgs: origArgs // (if pkgs.lib.isFunction newArgs then newArgs origArgs else newArgs);
args = lib.fix (lib.extends
(_: previousAttrs: {
passthru = (previousAttrs.passthru or { }) // {
overridePythonAttrs = newArgs: makeOverridablePythonPackage f (overrideWith newArgs);
};
})
(_: origArgs));
result = f args;
overrideWith = newArgs: args // (if pkgs.lib.isFunction newArgs then newArgs args else newArgs);
in
if builtins.isAttrs ff then (ff // {
if builtins.isAttrs result then result
else if builtins.isFunction result then {
overridePythonAttrs = newArgs: makeOverridablePythonPackage f (overrideWith newArgs);
})
else if builtins.isFunction ff then {
overridePythonAttrs = newArgs: makeOverridablePythonPackage f (overrideWith newArgs);
__functor = self: ff;
__functor = self: result;
}
else ff;
else result;

buildPythonPackage = makeOverridablePythonPackage (lib.makeOverridable (callPackage ./mk-python-derivation.nix {
inherit namePrefix; # We want Python libraries to be named like e.g. "python3.6-${name}"
Expand Down

0 comments on commit b94fa2c

Please sign in to comment.