Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python: add buildPythonPackage.overridePythonPackage method. #24155

Closed
wants to merge 4 commits into from

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.

@@ -3,7 +3,7 @@
## User Guide

Several versions of Python are available on Nix as well as a high amount of
packages. The default interpreter is CPython 3.5.
packages. The default interpreter is CPython 2.7.
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)

Versions 2.6, 2.7, 3.3, 3.4 and 3.5 of the CPython interpreter are available as respectively
`python26`, `python27`, `python33`, `python34` and `python35`. The PyPy interpreter
Versions 2.7, 3.3, 3.4, 3.5 and 3.6 of the CPython interpreter are available as
respectively `python27`, `python33`, `python34`, `python35` and `python36`. The PyPy interpreter
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.

(let
python = let
packageOverrides = self: super: {
pandas = super.pandas.overridePythonPackage(old: {name="foo";});
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.

@@ -27,7 +27,27 @@ let

mkPythonDerivation = makeOverridable( callPackage ../development/interpreters/python/mk-python-derivation.nix {
});
buildPythonPackage = makeOverridable (callPackage ../development/interpreters/python/build-python-package.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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants