Local user modules?

Donn Cave donn at u.washington.edu
Thu Jul 27 15:39:32 EDT 2000


Quoth Steve Juranich <sjuranic at condor.ee.washington.edu>:
| Without further ado, here's my question: Is it possible for a user to write
| a module in C/C++ and make that available to the Python interpreter
| *without* needing to edit systemfiles like
| ${PYTHON_HOME}/Modules/Setup.local?

Yes.

| Is is possible for me to add NumPy to my Python path without actually
| sticking it in the main Python system path?

I assume so.

| So far, this has been my biggest frustration with Python.  If there is
| somewhere where I could RTFM, please let me know.  I would be more than
| happy to do this, but I must know how to get around this problem.

To generalize, I would divide this into three steps.

1. Compile dynamically loadable, or "shared", modules.
2. Pick your place for them.
3. Arrange to set sys.path accordingly.

(1) is most of the work.  It sounds like you may have that under
    control, though.  The end result to make "import spud" work
    would a file named "spudmodule.so", with one external entry
    point "void initspud()".  Python can take it from there.
(2) would be a non-issue, except that you may very well have only
    NFS mounted disk space at your disposal.  Most platforms can
    handle loading from NFS, but there are some weird issues that
    come up with dynamically loaded modules.  If in the end you
    must use NFS, test the modules first out of /tmp or something,
    and then when you have moved to NFS, look out for the possibility
    that you are running an older version of the module you just
    rebuilt.
(3) you already know how to do.  

	Donn Cave, University Computing Services, University of Washington
	donn at u.washington.edu



More information about the Python-list mailing list