Python discussion
From NixOS Wiki
python basics
- *.pth files
- Python supports *.pth files which contain the paths to the parent directories of your python modules one per line. Those files are placed in site-packages and are typically generated by python package managers such as easy_install.
- PYTHONPATH
- The other way is to set additional paths for the required modules before running python. This is done by setting the python paths in the environment variable PYTHONPATH. A path typically looks like this on a Nix system: /nix/store/fxpfc2hyw5qbxly8xwrxzai8lny4pcq2-ipython-0.11/lib/python2.7/site-packages/ipython-0.11-py2.7.egg
- PYTHONUSERBASE
- ?
in general see [1]
general python integration into nixos
requirements
- mix python 2.x and 3.x in the same profile
- marcweber and qknight vote against that. it makes packaging complicated: to mix python2 and python3? We could introduce NIX_PYTHON_SITES_2 and NIX_PYTHON_SITES_3 or such. a better way is to use load-env-whatever (see [2] )
- pyLibA (python wrapper for a library) is used by pyLibB: nix expressions must be able to use either
proposed nixos environment variables
- NIX_PYTHON_SITES
qknight's problems
packaging virt-manager
see problem 2 in [3]
python-gudev
i have problems packaging python-gudev:
gudevmodule.c:19:23: fatal error: pygobject.h: No such file or directory
but looking at the exports (nix-env -i python-gudev -K; source env-vars) i can see:
-I/nix/store/lqsihhkhl7rhr18x7qiviihyp2byc5gw-pygobject-2.27.0/include
but in that folder there is only pygtk-2.0 folder:
ls -la /nix/store/lqsihhkhl7rhr18x7qiviihyp2byc5gw-pygobject-2.27.0/include pygtk-2.0/
so in that folder i find:
ls -la /nix/store/lqsihhkhl7rhr18x7qiviihyp2byc5gw-pygobject-2.27.0/include/pygtk-2.0/ pyglib.h pygobject.h
the problem
as discussed in [4] and quoting [5]
# All python code is installed into a "gtk-2.0" sub-directory. That # sub-directory may be useful on systems which share several library # versions in the same prefix, i.e. /usr/local, but on Nix that directory # is useless. Furthermore, its existence makes it very hard to guess a # proper $PYTHONPATH that allows "import gtk" to succeed.
so how should i package python-gudev then? the source for python-gudev (which produces the above error) can be found at [6]