[Tutor] search path

Christian Tismer tismer@appliedbiometrics.com
Sat, 27 Mar 1999 16:37:08 +0100

bas pels wrote:
> a small question about search paths.
> i have downloaded two so-called site-packages that both contain
> x.pth files in their directories (so-called path configuration files).
> from the reference manual  (p.57) i learnt that the site module uses
> these files to modify the sys.path list.
> it seems to me that the path configuration files need to be in
> a specific directory (given by sys.prefix or sys.exec_prefix) to be
> read. however, to put them there i need to be root.
> is there a way to test the packages (and to make use of their path
> configuration files) without travelling around as root?

Yes. I believe the easiest way is to manually adjust the 
startup a little and test the packages.
If you have a look into site.py, you will see that function
addsitedir(path) does what you want.
I would start my testing script this way:

#from here
from site import addsitedir
del addsitedir
# assuming a package "superpackage" in newstuff
from superpackage import tester
#to here

Makes sense? ciao - chris

Christian Tismer             :^)   <mailto:tismer@appliedbiometrics.com>
Applied Biometrics GmbH      :     Have a break! Take a ride on Python's
Kaiserin-Augusta-Allee 101   :    *Starship* http://starship.python.net
10553 Berlin                 :     PGP key -> http://wwwkeys.pgp.net
PGP Fingerprint       E182 71C7 1A9D 66E9 9D15  D3CC D4D7 93E2 1FAE F6DF
     we're tired of banana software - shipped green, ripens at home