guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Python ignores pth files?


From: Ricardo Wurmus
Subject: Re: Python ignores pth files?
Date: Sun, 01 Mar 2015 21:58:49 +0100

Taylan Ulrich Bayırlı/Kammer writes:

> Ricardo Wurmus <address@hidden> writes:
>
>> pygtk and pygobject both come with .pth files that instruct Python to
>> check out the "gtk-2.0" subdirectory, yet these files are seemingly
>> ignored as (according to strace) Python makes no attempt to look inside
>> the declared subdirectories when Solfege starts up.
>
> I had the same experience trying to package nmap (still lying around in
> a branch).  The #python IRC channel on Freenode told me that indeed .pth
> files in PYTHONPATH aren't used, only those in some system paths.  I
> can't remember the details, but Python's documentation should tell.

Apparently, it is possible to add the paths declared by pth files by
explicitly adding the parent site-packages directory as a site dir:

~~~~~~~~~~~~~~~~~~~~~~~~~~~
~/dev/guix $ export 
PYTHONPATH="/gnu/store/jk9aaqb563mxbydj5rbpmav37ia3pcf7-libxml2-2.9.0/lib/python2.7/site-packages:/gnu/store/l1ay93rj4v9dczm23s9qm1258qig5ywq-python-2.7.6/lib/python2.7/site-packages:/gnu/store/qb8jh3l0nmwc13gpjsp082w1iqxhqv9a-python2-pygtk-2.24.0/lib/python2.7/site-packages:/gnu/store/rkra74amwxbghv80xcxvnhm5jmhs5n3r-python2-pygobject-2.28.6/lib/python2.7/site-packages:/gnu/store/s23gjyn966zwsq9wvfc713d5c60jbb12-python2-py2cairo-1.10.0/lib/python2.7/site-packages"
~/dev/guix $ python
Python 2.7.6 (default, Feb 10 2015, 20:41:43) 
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print sys.path
['', 
'/gnu/store/jk9aaqb563mxbydj5rbpmav37ia3pcf7-libxml2-2.9.0/lib/python2.7/site-packages',
 
'/gnu/store/l1ay93rj4v9dczm23s9qm1258qig5ywq-python-2.7.6/lib/python2.7/site-packages',
 
'/gnu/store/qb8jh3l0nmwc13gpjsp082w1iqxhqv9a-python2-pygtk-2.24.0/lib/python2.7/site-packages',
 
'/gnu/store/rkra74amwxbghv80xcxvnhm5jmhs5n3r-python2-pygobject-2.28.6/lib/python2.7/site-packages',
 
'/gnu/store/s23gjyn966zwsq9wvfc713d5c60jbb12-python2-py2cairo-1.10.0/lib/python2.7/site-packages',
 '/gnu/store/c4lw432zk1makv5681jnzi6lnsphism8-python-2.7.6/lib/python27.zip', 
'/gnu/store/c4lw432zk1makv5681jnzi6lnsphism8-python-2.7.6/lib/python2.7', 
'/gnu/store/c4lw432zk1makv5681jnzi6lnsphism8-python-2.7.6/lib/python2.7/plat-linux2',
 
'/gnu/store/c4lw432zk1makv5681jnzi6lnsphism8-python-2.7.6/lib/python2.7/lib-tk',
 
'/gnu/store/c4lw432zk1makv5681jnzi6lnsphism8-python-2.7.6/lib/python2.7/lib-old',
 
'/gnu/store/c4lw432zk1makv5681jnzi6lnsphism8-python-2.7.6/lib/python2.7/lib-dynload',
 
'/gnu/store/c4lw432zk1makv5681jnzi6lnsphism8-python-2.7.6/lib/python2.7/site-packages']
>>> import site
>>> site.addsitedir('/gnu/store/qb8jh3l0nmwc13gpjsp082w1iqxhqv9a-python2-pygtk-2.24.0/lib/python2.7/site-packages')
>>> print sys.path
['', 
'/gnu/store/jk9aaqb563mxbydj5rbpmav37ia3pcf7-libxml2-2.9.0/lib/python2.7/site-packages',
 
'/gnu/store/l1ay93rj4v9dczm23s9qm1258qig5ywq-python-2.7.6/lib/python2.7/site-packages',
 
'/gnu/store/qb8jh3l0nmwc13gpjsp082w1iqxhqv9a-python2-pygtk-2.24.0/lib/python2.7/site-packages',
 
'/gnu/store/rkra74amwxbghv80xcxvnhm5jmhs5n3r-python2-pygobject-2.28.6/lib/python2.7/site-packages',
 
'/gnu/store/s23gjyn966zwsq9wvfc713d5c60jbb12-python2-py2cairo-1.10.0/lib/python2.7/site-packages',
 '/gnu/store/c4lw432zk1makv5681jnzi6lnsphism8-python-2.7.6/lib/python27.zip', 
'/gnu/store/c4lw432zk1makv5681jnzi6lnsphism8-python-2.7.6/lib/python2.7', 
'/gnu/store/c4lw432zk1makv5681jnzi6lnsphism8-python-2.7.6/lib/python2.7/plat-linux2',
 
'/gnu/store/c4lw432zk1makv5681jnzi6lnsphism8-python-2.7.6/lib/python2.7/lib-tk',
 
'/gnu/store/c4lw432zk1makv5681jnzi6lnsphism8-python-2.7.6/lib/python2.7/lib-old',
 
'/gnu/store/c4lw432zk1makv5681jnzi6lnsphism8-python-2.7.6/lib/python2.7/lib-dynload',
 
'/gnu/store/c4lw432zk1makv5681jnzi6lnsphism8-python-2.7.6/lib/python2.7/site-packages',
 
'/gnu/store/qb8jh3l0nmwc13gpjsp082w1iqxhqv9a-python2-pygtk-2.24.0/lib/python2.7/site-packages/gtk-2.0']
~~~~~~~~~~~~~~~~~~~~~~~~~~~

Note that site.addsitedir added the subdirectory as declared by
"pygtk.pth".  I wonder if this means that I'll have to patch the
executable to run site.addsitedir over all elements in PYTHONPATH until
sys.path no longer changes.

~~ Ricardo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]