.pth files in working directory

Peter Hansen peter at engcorp.com
Wed Aug 31 14:15:40 CEST 2005

Peter Maas wrote:
> My goal is to have the top level of a directory tree in the Python
> path without touching anything outside the directory. I tried to
> create .pth files with the top level path in every subdirectory
> but this doesn't work despite working directory being part of the
> Python path.
> Creating the pth file in .../site-packages works but I prefer to
> have everything inside the directory tree so that removing the tree
> is sufficient for a complete uninstall. Any hints are appreciated,
> thanks.

Not sure from the above description exactly what it is you want, but 
generally such non-standard sys.path and .pth manipulations are best 
handled by a sitecustomize.py file, possibly which makes its own calls 
to site.addsitedir() and such.  Try "help(site)" for more.

In this case, I think you'd have a sitecustomize.py which looks for .pth 
files in the current directory and calls site.addsitedir(), but I'm not 
sure.  Maybe if this doesn't work, an example would clarify things.


More information about the Python-list mailing list