[python-win32] PYTHONPATH and .pth files under Windows XP

Chris Rock warbands at mac.com
Wed Dec 20 03:06:43 CET 2006


PYTHONPATH and .pth files under Windows XP

No matter what my PYTHONPATH is set to as a Enivorment Variable under Windows XP, the only time a .pth file is actually being read and used is when I dump it into my site-packages directory off my install location.

lets say I have the following directory structure:

c:\dev\Python
                     .\Lib
                            .\Database
                            .\String

Now lets say I have a module named Database.py sitting in the directory c:\dev\Python\Lib\Database\

I would like to have PYTHONPATH set to c:\dev\Python\Lib
I would then like to have a Lib.pth file that has relative directory locations in the file: such as "Database\", "String\" and so on for all the major Module Directories.

So in my main python program I would like to have the call:

import Database

Then use my module like:

Database.Method()

Ultimately we would like to control which work tree we would use, so that we have a "c:\dev" area, and we may have a "m:\release" area. By tuning our PYTHONPATH to reflect which tree we would like to use as a base this should be fairly doable, and works great for our Mel development.

....


So the question is, the only way this works is by hand placing my Lib.pth under my python install directory's site-packages directory, and I have to use a full path reference.
So what I am doing wrong, or forgetting?

I have been constantly checking my path via sys.path, and it only reflects the .pth file when it is in the site-packages directory.

Using the site-packages directory is NOT GOING TO WORK for our usage.

I eagerly await any thoughts on this, thanks in advance.

- Rock


More information about the Python-win32 mailing list