.pth in current directory: Why doesn't it work as the documentation says?

Philipp Hagemeister phihag at phihag.de
Mon May 18 15:40:11 CEST 2009

David Lyon wrote:
> On Mon, 18 May 2009 14:34:33 +0200, Philipp Hagemeister <phihag at phihag.de>
> wrote:
>> Yes, but that processing will add /example/ to sys.path, right?
> It actually works the other way around. The directories listed in
> sys.path are scanned for .pth files.

No, they are not. That's exactly my point. According to Christian
Heimes, *some* of the directories listed in sys.path are scanned. "" is
in sys.path, but is not scanned.

> You can add packages by listing them inside a .PTH.
>> I'm expecting .pth files in the current directory to be be processed,
>> according to docs/install/. Christian Heimes already pointed out this is
>> not the case; so I'm wondering whether this is a mistake in the
>> documentation or just my faulty logic.
> Perphaps you don't understand them yet.
> .PTH files are for adding run-time packages.
> May I ask why you are playing with .PTH files? they are a fairly
> advanced sort of concept for describing where packages are located
> to the python interpreter.
> If you are using .PTH files... you should be using "import .." 
> inside your code..

I know that, and I want to use them for an application consisting of
multiple scripts, like so:

   mylib.pth (contains '../mylib/')
   mylib.pth (contains '../mylib/')

If you want, you can change the final point in my original post to:

1&3&5 => 6) echo /example/ > test.pth;touch /example/libfoo.py; python
-c 'import libfoo'



-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 204 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20090518/d43b309f/attachment.sig>

More information about the Python-list mailing list