Skip to content

Python: add buildPythonPackage.overridePythonPackage method.#24155

Closed
FRidh wants to merge 4 commits intoNixOS:stagingfrom
FRidh:override
Closed

Python: add buildPythonPackage.overridePythonPackage method.#24155
FRidh wants to merge 4 commits intoNixOS:stagingfrom
FRidh:override

Conversation

@FRidh
Copy link
Member

@FRidh FRidh commented Mar 21, 2017

This allows one to always override the call to buildPythonPackage.

The following example renamed pandas to foo:

with import <nixpkgs> {};

(let
python = let
    packageOverrides = self: super: {
      pandas = super.pandas.overridePythonPackage(old: {name="foo";});
    };
in pkgs.python35.override {inherit packageOverrides;};

in python.withPackages(ps: [ps.pandas])).env
Motivation for this change
Things done
  • Tested using sandboxing
    (nix.useSandbox on NixOS,
    or option build-use-sandbox in nix.conf
    on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • Linux
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

Closes #24154.

@mention-bot
Copy link

@FRidh, thanks for your PR! By analyzing the history of the files in this pull request, we identified @FRidh to be a potential reviewer.

@FRidh FRidh added 0.kind: enhancement Add something new or improve an existing system. 6.topic: python Python is a high-level, general-purpose programming language. 9.needs: documentation This needs to be documented well. labels Mar 21, 2017
@FRidh FRidh added this to the 17.03 milestone Mar 21, 2017
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would back port this commit.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely!
Actually, I would like to get all of them in 17.03 :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Which is why I kept them together now)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would back port this commit.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A more practical example:

pandas = super.pandas.overridePythonPackage(old: rec {
  version = "0.19.1";
  src =  super.fetchPypi {
    pname = "pandas";
    inherit version;
    sha256 = "08blshqj9zj1wyjhhw3kl2vas75vhhicvv72flvf1z3jvapgw295";
  };
});

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I thought my example (and yours) was working but now it doesn't...
Did you try it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can use .overridePythonPackage inside say python-packages.nix but not in a separate shell.nix.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this is basically a copy of lib.makeOverrable.

This allows one to always override the call to `buildPythonPackage`.

The following example renamed `pandas` to `foo`:

```
with import <nixpkgs> {};

(let
python = let
    packageOverrides = self: super: {
      pandas = super.pandas.overridePythonPackage(old: {name="foo";});
    };
in pkgs.python35.override {inherit packageOverrides;};

in python.withPackages(ps: [ps.pandas])).env
```
@FRidh FRidh changed the base branch from master to staging March 22, 2017 11:58
@FRidh
Copy link
Member Author

FRidh commented Mar 26, 2017

This doesn't function. I'll have a look at it later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

0.kind: enhancement Add something new or improve an existing system. 6.topic: python Python is a high-level, general-purpose programming language. 9.needs: documentation This needs to be documented well.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants