Extending Python

To make a module loadable from regular (non-embedded) Python, you must build a shared library
(sometimes called a 'DSO' in Unix, or 'DLL' in Windows)

The code must include an init function, which is called when the module is loaded

If the module is named foo, then the init function is initfoo()
For example:

  void initcrypto(void)
      {
      (void) Py_InitModule("crypto", newMethods);
      }

In Unix, compile a DSO like this:

  cc -I/usr/include/python -O -shared -o crypto.so crypto.c

The location of the module may need to be added to your PYTHONPATH environment variable; e.g.:

  setenv PYTHONPATH ~/python

next