From: Ricardo Wurmus <rekado@elephly.net>
To: "Taylan Ulrich Bayırlı/Kammer" <taylanbayirli@gmail.com>
Cc: Guix-devel <guix-devel@gnu.org>
Subject: Re: Python ignores pth files?
Date: Sun, 01 Mar 2015 21:58:49 +0100 [thread overview]
Message-ID: <878ufga0za.fsf@mango.localdomain> (raw)
In-Reply-To: <878ufgh2xd.fsf@taylan.uni.cx>
Taylan Ulrich Bayırlı/Kammer writes:
> Ricardo Wurmus <rekado@elephly.net> 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
next prev parent reply other threads:[~2015-03-01 20:59 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-01 20:27 Python ignores pth files? Ricardo Wurmus
2015-03-01 20:34 ` Taylan Ulrich Bayırlı/Kammer
2015-03-01 20:58 ` Ricardo Wurmus [this message]
2015-03-01 22:14 ` Ricardo Wurmus
-- strict thread matches above, loose matches on Subject: below --
2015-03-02 8:18 Federico Beffa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=878ufga0za.fsf@mango.localdomain \
--to=rekado@elephly.net \
--cc=guix-devel@gnu.org \
--cc=taylanbayirli@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).