Jump to content

Python discussion: Difference between revisions

From NixOS Wiki
imported>Fadenb
m update url to wayback machine url
 
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Outdated|also, this article describes discussions from old days}}
== python basics ==
== python basics ==
* '''*.pth''' files
* '''*.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.
: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
* 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 typcially looks like this on a Nix system: /nix/store/fxpfc2hyw5qbxly8xwrxzai8lny4pcq2-ipython-0.11/lib/python2.7/site-packages/ipython-0.11-py2.7.egg
: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
* PYTHONUSERBASE
:?
:?
Line 22: Line 23:


=== packaging virt-manager ===
=== packaging virt-manager ===
see '''problem 2''' in [http://permalink.gmane.org/gmane.linux.distributions.nixos/8732]
see '''problem 2''' in [https://web.archive.org/web/20150406220317/https://permalink.gmane.org/gmane.linux.distributions.nixos/8732]


=== python-gudev ===
=== python-gudev ===
i have problems packaging python-gudev:
i have problems packaging python-gudev:
  gudevmodule.c:19:23: fatal error: pygobject.h: No such file or directory
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:
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
  -I/nix/store/lqsihhkhl7rhr18x7qiviihyp2byc5gw-pygobject-2.27.0/include


but in that folder there is only pygtk-2.0 folder:
but in that folder there is only pygtk-2.0 folder:
  ls -la /nix/store/lqsihhkhl7rhr18x7qiviihyp2byc5gw-pygobject-2.27.0/include
ls -la /nix/store/lqsihhkhl7rhr18x7qiviihyp2byc5gw-pygobject-2.27.0/include
  pygtk-2.0/
pygtk-2.0/


so in that folder i find:
so in that folder i find:
  ls -la /nix/store/lqsihhkhl7rhr18x7qiviihyp2byc5gw-pygobject-2.27.0/include/pygtk-2.0/
ls -la /nix/store/lqsihhkhl7rhr18x7qiviihyp2byc5gw-pygobject-2.27.0/include/pygtk-2.0/
  pyglib.h  pygobject.h
pyglib.h  pygobject.h


=== the problem ===
=== the problem ===
as discussed in [http://old.nabble.com/Python-3-to22076291.html#a22119842] and quoting [https://nixos.org/repos/nix/nixpkgs/trunk/pkgs/development/python-modules/pygobject/default.nix]
as discussed in [http://old.nabble.com/Python-3-to22076291.html#a22119842] and quoting [https://nixos.org/repos/nix/nixpkgs/trunk/pkgs/development/python-modules/pygobject/default.nix]
    # All python code is installed into a "gtk-2.0" sub-directory. That
# All python code is installed into a "gtk-2.0" sub-directory. That
    # sub-directory may be useful on systems which share several library
# 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
# 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
# is useless. Furthermore, its existence makes it very hard to guess a
    # proper $PYTHONPATH that allows "import gtk" to succeed.
# 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 [https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/python-modules/python-gudev/default.nix]
so how should i package python-gudev then? the source for python-gudev (which produces the above error) can be found at [https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/python-modules/python-gudev/default.nix]

Latest revision as of 04:01, 14 September 2024

⏲︎︎
This article or section is outdated. also, this article describes discussions from old days Further information might be found in the corresponding discussion. Please remove this notice once the information has been updated.

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]