-
-
Notifications
You must be signed in to change notification settings - Fork 15.1k
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
Conversation
doc/languages-frameworks/python.md
Outdated
@@ -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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
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)
doc/languages-frameworks/python.md
Outdated
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 |
There was a problem hiding this comment.
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";}); |
There was a problem hiding this comment.
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";
};
});
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
.
pkgs/top-level/python-packages.nix
Outdated
@@ -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 { | |||
|
There was a problem hiding this comment.
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 ```
because they're only supposed to be used in `buildPythonPackage`
This doesn't function. I'll have a look at it later. |
This allows one to always override the call to
buildPythonPackage
.The following example renamed
pandas
tofoo
:Motivation for this change
Things done
(nix.useSandbox on NixOS,
or option
build-use-sandbox
innix.conf
on non-NixOS)
nix-shell -p nox --run "nox-review wip"
./result/bin/
)Closes #24154.