Extending Python dynamically
nemeth at iqsoft.hu
Thu Nov 4 14:08:32 EST 1999
ScherBi at BAM.com wrote:
> > I have downloaded DCOracle extension. I have RH6.0, and (at
> > least until now) I have not installed the source distribution of Python. I
> > installed only the binary RPMs. I unpacked DCOracle in a directory and
> > managed to build the so files (Buffer.so and oci_.so).
> > How to install then this DCOracle package? I have been trying
> > to figure out but no success.
> Create a directory somewhere in your pythonpath (import sys; print
> sys.path), call it DCOracle.
> In this directory put the two .so files, and all the .py files that came in
> the DCOracle package.
> Then you may import DCOracle.
> Let me know if you need more help.
> Bill Scherer
Thank you for your help. The method you suggested works perfectly!
However, I do not understand completely how the Python interpreter finds out
that it has to load an so file. Normally -- I believed -- when Python sees an
"import xxx" statement it looks for a xxx.py, xxx.pyc or xxx.pyo file in the
$PYTHONPATH directories or an xxx subdirectory having an __init__.py file, but
not an xxx.so file. This means that if I add the current directory to the
$PYTHONPATH (such as export PYTHONPATH='.' Python will find any arbitrary so
file in the $PWD?
Anyway, I am very happy that I do not have to recompile Python every time I add
a new extension library (ie. an so file) :-).
More information about the Python-list