guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Python ignores pth files?


From: Ricardo Wurmus
Subject: Re: Python ignores pth files?
Date: Sun, 01 Mar 2015 23:14:08 +0100

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)"))

~~ Ricardo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]