From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ricardo Wurmus Subject: Re: Python ignores pth files? Date: Sun, 01 Mar 2015 23:14:08 +0100 Message-ID: <877fv09xhr.fsf@mango.localdomain> References: <87a8zwa2er.fsf@mango.localdomain> <878ufgh2xd.fsf@taylan.uni.cx> <878ufga0za.fsf@mango.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:34411) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YSC7y-0003SW-GW for guix-devel@gnu.org; Sun, 01 Mar 2015 17:14:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YSC7s-000077-To for guix-devel@gnu.org; Sun, 01 Mar 2015 17:14:22 -0500 Received: from sender1.zohomail.com ([74.201.84.155]:29507) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YSC7s-000073-Md for guix-devel@gnu.org; Sun, 01 Mar 2015 17:14:16 -0500 In-reply-to: <878ufga0za.fsf@mango.localdomain> 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 Ricardo Wurmus writes: > Taylan Ulrich Bayırlı/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: > [...] > > 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. I'm now patching the sources to add all site-packages directories, which causes their pth files to be interpreted: (substitute* "run-solfege.py" (("import os") "import os, site for path in [path for path in sys.path if 'site-packages' in path]: site.addsitedir(path)")) ~~ Ricardo