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: withPackages and overrides does not result in correct passthru #64334

Closed
adisbladis opened this issue Jul 5, 2019 · 6 comments
Closed

Comments

@adisbladis
Copy link
Member

Issue description

Using withPackages together with overrides currently does not work as expected.
Overrides does not propagate to withPackages.

Steps to reproduce

We can demonstrate this easily in the repl:

This works exactly as expected

nix-repl> (python3.override { packageOverrides=(self: super: { requests="hello"; }); }).passthru.pkgs.requests  
"hello"

This does not:

nix-repl> ((python3.override { packageOverrides=(self: super: { requests="hello"; }); }).withPackages(ps: [ps.requests])).passthru.pkgs.requests
«derivation /nix/store/qfnz62wvq8xbmf6zldxqfa205rklhwmv-python3.7-requests-2.21.0.drv»

I would expect the second case to also evaluate to my overriden package.

Technical details

Please run nix-shell -p nix-info --run "nix-info -m" and paste the
results.

cc @FRidh

@FRidh FRidh added 0.kind: regression Something that worked before working no longer 6.topic: python 0.kind: bug and removed 0.kind: regression Something that worked before working no longer labels Jul 5, 2019
@FRidh
Copy link
Member

FRidh commented Jul 5, 2019

See "9.14.2.2.1.2. Overriding Python packages" in the Nixpkgs manual, rewritten as

with import <nixpkgs> {};

(let
  python = let
    packageOverrides = self: super: {
      foo = super.numpy.overridePythonAttrs(old: rec {
        name = "foo";
      });
    };
  in pkgs.python3.override {inherit packageOverrides;};

in python.withPackages(ps: [ps.foo])).env

The composition does function, however, the passthru seems to be incorrect. Just replace .env with .passthru.pkgs.foo .

@FRidh FRidh changed the title Python: withPackages and overrides does not compose Python: withPackages and overrides does not result in correct passthru Jul 5, 2019
@FRidh
Copy link
Member

FRidh commented Jul 5, 2019

Using the following solves the issue:

with import <nixpkgs> {};

(let
  python = let
    packageOverrides = self: super: {
      foo = super.numpy.overridePythonAttrs(old: rec {
        name = "foo";
      });
    };
  in pkgs.python3.override {inherit packageOverrides; self = python;};

in python.withPackages(ps: [ps.foo])).passthru.pkgs.foo

Note the self = python.

@FRidh
Copy link
Member

FRidh commented Jul 5, 2019

I've updated the example in f1ff85e. There's not much else I think we can do here.

@FRidh FRidh removed the 0.kind: bug label Jul 5, 2019
vdemeester pushed a commit to vdemeester/nixpkgs that referenced this issue Jul 5, 2019
Not passing in the newly created interpreter as `self` results in an
incorrect `passthru`. Solves NixOS#64334.
@adisbladis
Copy link
Member Author

Ok, updating the example is good enough :)
Thanks

FRidh added a commit that referenced this issue Jul 5, 2019
Not passing in the newly created interpreter as `self` results in an
incorrect `passthru`. Solves #64334.

(cherry picked from commit f1ff85e)
@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/python3-override-for-bluezsupport-not-working/36042/7

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/python3-override-for-bluezsupport-not-working/36042/8

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

No branches or pull requests

3 participants