From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ricardo Wurmus Subject: Re: Python ignores pth files? Date: Sun, 01 Mar 2015 21:58:49 +0100 Message-ID: <878ufga0za.fsf@mango.localdomain> References: <87a8zwa2er.fsf@mango.localdomain> <878ufgh2xd.fsf@taylan.uni.cx> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53183) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YSAx8-0001w6-LX for guix-devel@gnu.org; Sun, 01 Mar 2015 15:59:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YSAx3-0003l1-RW for guix-devel@gnu.org; Sun, 01 Mar 2015 15:59:06 -0500 Received: from sender1.zohomail.com ([74.201.84.155]:29830) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YSAx3-0003kj-J9 for guix-devel@gnu.org; Sun, 01 Mar 2015 15:59:01 -0500 In-reply-to: <878ufgh2xd.fsf@taylan.uni.cx> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: Taylan Ulrich =?utf-8?Q?Bay=C4=B1rl=C4=B1=2FKammer?= Cc: Guix-devel Taylan Ulrich Bay=C4=B1rl=C4=B1/Kammer writes: > Ricardo Wurmus 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=3D"/gnu/store/jk9aaqb563mxbydj5rbpmav37ia3pc= f7-libxml2-2.9.0/lib/python2.7/site-packages:/gnu/store/l1ay93rj4v9dczm23s9= qm1258qig5ywq-python-2.7.6/lib/python2.7/site-packages:/gnu/store/qb8jh3l0n= mwc13gpjsp082w1iqxhqv9a-python2-pygtk-2.24.0/lib/python2.7/site-packages:/g= nu/store/rkra74amwxbghv80xcxvnhm5jmhs5n3r-python2-pygobject-2.28.6/lib/pyth= on2.7/site-packages:/gnu/store/s23gjyn966zwsq9wvfc713d5c60jbb12-python2-py2= cairo-1.10.0/lib/python2.7/site-packages" ~/dev/guix $ python Python 2.7.6 (default, Feb 10 2015, 20:41:43)=20 [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/qb8jh3l0nmwc13gpjsp082w1iqxhqv9= a-python2-pygtk-2.24.0/lib/python2.7/site-packages', '/gnu/store/rkra74amwx= bghv80xcxvnhm5jmhs5n3r-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-pyt= hon-2.7.6/lib/python27.zip', '/gnu/store/c4lw432zk1makv5681jnzi6lnsphism8-p= ython-2.7.6/lib/python2.7', '/gnu/store/c4lw432zk1makv5681jnzi6lnsphism8-py= thon-2.7.6/lib/python2.7/plat-linux2', '/gnu/store/c4lw432zk1makv5681jnzi6l= nsphism8-python-2.7.6/lib/python2.7/lib-tk', '/gnu/store/c4lw432zk1makv5681= jnzi6lnsphism8-python-2.7.6/lib/python2.7/lib-old', '/gnu/store/c4lw432zk1m= akv5681jnzi6lnsphism8-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-py= gtk-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/qb8jh3l0nmwc13gpjsp082w1iqxhqv9= a-python2-pygtk-2.24.0/lib/python2.7/site-packages', '/gnu/store/rkra74amwx= bghv80xcxvnhm5jmhs5n3r-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-pyt= hon-2.7.6/lib/python27.zip', '/gnu/store/c4lw432zk1makv5681jnzi6lnsphism8-p= ython-2.7.6/lib/python2.7', '/gnu/store/c4lw432zk1makv5681jnzi6lnsphism8-py= thon-2.7.6/lib/python2.7/plat-linux2', '/gnu/store/c4lw432zk1makv5681jnzi6l= nsphism8-python-2.7.6/lib/python2.7/lib-tk', '/gnu/store/c4lw432zk1makv5681= jnzi6lnsphism8-python-2.7.6/lib/python2.7/lib-old', '/gnu/store/c4lw432zk1m= akv5681jnzi6lnsphism8-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/pyth= on2.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