C shared object files

Konrad Hinsen hinsen at cnrs-orleans.fr
Mon Jul 5 04:52:38 EDT 1999


Martin Casado <casado at ogl.llnl.gov> writes:

>    I am trying to get python to dynamically load a C object module, and 
> first off I can't figure out how to compile myCollProggy.c into a 
> shareable object file, and secondly I was curios if there is a way to check
> at runtime if a module is on the system or not.  

The answer to the first question can be found in section 2 (Building C
and C++ Extensions on Unix) of "Extending and Embedding the Python
Interpreter", available at www.python.org and many other places that
have the standard Python documentation. Assuming of course that you
are using Unix, for other systems the procedure is different and
probably compiler dependent.

As for the second question, the simplest solution is a test import:

  try:
     from foo import bar
  except ImportError:
     print "Sorry, module 'foo' is not available."

-- 
-------------------------------------------------------------------------------
Konrad Hinsen                            | E-Mail: hinsen at cnrs-orleans.fr
Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.55.69
Rue Charles Sadron                       | Fax:  +33-2.38.63.15.17
45071 Orleans Cedex 2                    | Deutsch/Esperanto/English/
France                                   | Nederlands/Francais
-------------------------------------------------------------------------------




More information about the Python-list mailing list