[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Python ignores pth files?
From: |
Federico Beffa |
Subject: |
Re: Python ignores pth files? |
Date: |
Mon, 2 Mar 2015 09:18:42 +0100 |
Ricardo Wurmus <address@hidden> writes:
> Ricardo Wurmus writes:
>
>> 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:
>>
> [...]
>>
>> 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