-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
Description
Steps to reproduce
Example:
nix-shell -p python2Packages.pycairo
echo $PYTHONPATH
# empty
exit
nix-shell -p python2Packages.pycairo python2
echo $PYTHONPATH
# <snip>:/nix/store/*-python2.7-pycairo-1.10.0/lib/python2.7/site-packages
Technical details
It's the setup-hook of the python package that set PYTHONPATH. If a package doesn't propagate (propagatedBuildInputs) python, the envHook wont run and the package wont be usable from the shell. (unless python is explicitly added also)
I talked to @domenkozar on IRC, and the policy is that all python packages should be usable without explicitly specifying python too.
I've created a script that finds packages that might break this principle.
The script isn't perfect so the candidates must be checked manually.
I've identified the following python 2 packages so far: [1] (attribute names under python2Packages)
- PyXML
- PyXAPI
- bsddb
- crypt
- curses_panel
- dbus
- gdbm
- gst-python
- libvirt
- notify
- pyblock
- pycairo
- pygobject
- pygobject3
- pygtksourceview
- pyside
- pysvn
- pywebkitgtk
- qscintilla
- recursivePthLoader
- sip
- sip_4_16
- readline (*)
- curses (*)
- sqlite3 (*)
(*) These are importable without PYTHONPATH (native modules?), but with --pure the python interpreter is not available
To prevent this error in the future a note should be added to the nixpkgs manual? Something like:
Python packages should propagate python (through
propagatedBuildInputssuch thatnix-shell -p pkgworks.buildPythonPackagesdoes this automatically.
Maybe it's even possible to add a test?
- System: NixOS: 16.03.948.a96c308 (Emu)
- Nix version: nix-env (Nix) 1.11.2
- Nixpkgs version: "16.09pre88185.52a875f" (not my system, but the version I ran my detection script against)
[1] by doing (against nixos stable though, so some might have been fixed in master in a way that "fools" my script, and I've omitted the master-only candidates)
check() {
nix-shell --run "echo $PYTHONPATH" -p python2Package.$1
nix-shell --run "echo $PYTHONPATH" -p python2Package.$1 python2
}