Adding your own site directories cleanly and supportedly?

Tim Bradshaw tfb+google at tfeb.org
Wed May 26 10:33:28 EDT 2004


We have a situation where, on our production machines, we will
probably have a standard Python installation which is installed with
the system build, and which we want to use for various possible
applications.  These applications will probably have different library
requirements, and may have conflicting requirements.  We don't *know*
they will, but they may do and we don't want to have to worry about
it, basically.

As an example, my application uses Numeric.  I suspect that no-one
else does, but I don't want to find out that they do, and they use an
incompatible version.  Of course, we should really establish a
standard version and install the centrally and so on, but we probably
don't have time for that.  Different versions of the application might
also need different versions of Numeric, and they need to be able to
coexist painlessly.

This looks easy to solve: Numeric uses distutils, so we can just have
per-application site directories, where applications put the things
they need with no fear of interference.

Ah, but.  How do I add an application-specific site directory, and do
all the .pth file searching?  It looks like I can call
site.addsitedir() to add a directory of my choosing, and this will all
work.  This is all fine.

The question is: is this the right way to do this?  The documentation
for site doesn't describe any functions it exports, so I'm not sure if
I'm relying on something that might change or go away at some point. 
It seems to me that there *should* be a standard way of doing this,
because it must be a common need (mustn't it?): perhaps I'm missing
something, or this function should be documented?

Thanks

--tim



More information about the Python-list mailing list