The goal is to have a universal directory where I can add packages on the network that are automatically added to sys.path
without needing to run site.addsitedir
or sys.path.append
each time I import said packages. Is there a way to do this?
Background: I have a small network of users who all need access to the same scripts. Every time I want to add a new package for them to use, I add the path to their PYTHONPATH
environment variable. The user base has started to grow, and so have the number of packages.
If I could set up a master.pth
on the network that is loaded when they start any of the scripts (without requiring extra code in all of them), I'd be very grateful. It appears, though, that you can't nest .pth
files, so simply adding a pointer .pth
to the master.pth
directory doesn't seem to work.
Edit: Regarding Comments from @S.Lott (was a little big for a comment): Take, for example, wxPython. Three objects are placed into the site-packages directory: wxversion.py, a directory called wx-2.8-msw-unicode, and a .pth
file. The .pth
file points to that directory, which contains all of the importable packages (wx, wxPython, etc.). I currently have three other packages that are structured in a similar way, one of which has several base modules. I would need to move all of the importable modules into the same directory to get the desired result.
If, however, .pth
files could be "nested", I could add all of these directories to master.pth
, keeping a relatively clean folder. I hope that makes sense, and thanks for your help!