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: fix buildEnv passthru when using .override #77978

Closed
wants to merge 1 commit into from

Conversation

bennofs
Copy link
Contributor

@bennofs bennofs commented Jan 18, 2020

Motivation for this change

Before this change, python3.override { ... }.buildEnv would take the
un-overriden python interpreter as basis for the buildEnv. With this
commit, we compute self inside the argument passed to callPackage so the
buildEnv will always reference the python interpreter it belongs to.

As an example where this matters, python3Full is defined as
python3.override { x11Support = true; }. python3Full.buildEnv didn't get that override:

nix-shell -p 'with (import ./. {}); python3Full.buildEnv' --command 'python3 -c "import tkinter"'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File
"/nix/store/s7vw8y02cqzx8bnjxl4bkhlnwvz6ws1s-python3-3.7.6/lib/python3.7/tkinter/__init__.py",
line 36, in <module>
    import _tkinter # If this fails your Python may not be configured
for Tk
ModuleNotFoundError: No module named '_tkinter'

With this commit, that example now works.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

Before this commit, `python3.override { ... }.buildEnv` would take the
un-overriden python interpreter as basis for the buildEnv. With this
commit, we compute self inside the argument passed to callPackage so the
buildEnv will always reference the python interpreter it belongs to.

As an example where this matters, `python3Full` is defined as
`python3.override { x11Support = true; }`. Before this commit,
`python3Full.buildEnv` didn't get that override:

```
nix-shell -p 'with (import ./. {}); python3Full.buildEnv' --command 'python3 -c "import tkinter"'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File
"/nix/store/s7vw8y02cqzx8bnjxl4bkhlnwvz6ws1s-python3-3.7.6/lib/python3.7/tkinter/__init__.py",
line 36, in <module>
    import _tkinter # If this fails your Python may not be configured
for Tk
ModuleNotFoundError: No module named '_tkinter'
```

With this commit, that example now works.
@bennofs
Copy link
Contributor Author

bennofs commented Jan 18, 2020

Seems this doesn't work because packages rely on self.override being available :(

@bennofs bennofs closed this Jan 18, 2020
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

1 participant