Next: Calling Python functions Up: Extending Python with Previous: The module's function

Compilation and linkage

There are two more things to do before you can use your new extension module: compiling and linking it with the Python system. If you use dynamic loading, the details depend on the style of dynamic loading your system uses; see the chapter on Dynamic Loading for more info about this.

If you can't use dynamic loading, or if you want to make your module a permanent part of the Python interpreter, you will have to change the configuration setup and rebuild the interpreter. Luckily, in the 1.0 release this is very simple: just place your file (named `foomodule.c' for example) in the `Modules' directory, add a line to the file `Modules/Setup' describing your file:


    foo foomodule.o

and rebuild the interpreter by running make in the toplevel directory. You can also run make in the `Modules' subdirectory, but then you must first rebuilt the `Makefile' there by running make Makefile. (This is necessary each time you change the `Setup' file.)


guido@cwi.nl