From mboxrd@z Thu Jan 1 00:00:00 1970 From: Federico Beffa Subject: Re: Python ignores pth files? Date: Mon, 2 Mar 2015 09:18:42 +0100 Message-ID: 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]:38539) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YSLYq-00018y-ME for guix-devel@gnu.org; Mon, 02 Mar 2015 03:18:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YSLYp-00061I-Fh for guix-devel@gnu.org; Mon, 02 Mar 2015 03:18:44 -0500 Received: from mail-la0-x231.google.com ([2a00:1450:4010:c03::231]:43425) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YSLYp-000613-6f for guix-devel@gnu.org; Mon, 02 Mar 2015 03:18:43 -0500 Received: by labgf13 with SMTP id gf13so4065763lab.10 for ; Mon, 02 Mar 2015 00:18:42 -0800 (PST) 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: rekado@elephly.net Cc: Guix-devel Ricardo Wurmus writes: > Ricardo Wurmus writes: > >> 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 insid= e >>>> 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 .pt= h >>> 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)")) > As you have found out, the .pth files are not handled by python natively. Instead, they are part of setuptools/easy_install. See https://lists.gnu.org/archive/html/guix-devel/2014-12/msg00306.html and http://pythonhosted.org//setuptools/easy_install.html#reference-manual Regards, Fede