linux & users' python-extensions

John J. Lee phrxy at csv.warwick.ac.uk
Wed Apr 11 17:23:33 EDT 2001


On 11 Apr 2001, [iso-8859-2] Pawe³ Sto³owski wrote:
[...]
> OK, I've this:
> PYTHONPATH=~/lib/python2.0:/usr/local/lib/python2.0
> PYTHONHOME=~
>
> Now, when I put spam.py in ~/lib/python2.0, it works. But what should I
> do to make visible an extension module to the system (without cluttering
> global configuration)?. There are some Setup.* files in
> /usr/local/lib/python2.0/config/ (main python files) that list
> dependencies beetwen .py and extension modules; do I have to make a copy
> of it in my home dir and add my module there? I've tried to do so, but
> nothing happened. Did i miss something?

Don't have a copy here to check, but if those 'Setup.*' files are setup.py
scripts, then no, you don't have to copy them anywhere -- see the
Distutils docs in the standard distribution of Python.  If they're
something else, that I know not about, wait for somebody else to answer
the question. :)  You don't need to copy them anywhere to make your
modules visible, though.

For an extension module to be visible, it just has to be in sys.path.
/usr/local/lib/python2.0/site-packages should already be in there (IIRC
that's set in site.py).  One way of adding paths to sys.path is to put a
foo.pth file in, now, is it /usr/local/lib/python2.0, or
/usr/local/lib/python2.0/site-packages, or either?  I've been using
windows for a while, can't remember.  The contents of foo.pth should be a
relative directory path that you want to add to sys.path.  For full
details, try Guido's essay about the 'new' module import system, on
http://www.python.org/ somewhere in the docs section.  Otherwise, just get
your users (or yourself) to add directories to PYTHONPATH in whatever
shell scripts are appropriate.


John




More information about the Python-list mailing list