3.2 Building a Dynamically Loadable Module

Since there are three styles of dynamic loading, there are also three groups of instructions for building a dynamically loadable module. Instructions common for all three styles are given first. Assuming your module is called spam, the source filename must be "spammodule.c", so the object name is "spammodule.o". The module must be written as a normal Python extension module (as described earlier).

Note that in all cases you will have to create your own Makefile that compiles your module file(s). This Makefile will have to pass two "-I" arguments to the C compiler which will make it find the Python header files. If the Make variable PYTHONTOP points to the toplevel Python directory, your CFLAGS Make variable should contain the options "-I$(PYTHONTOP) -I$(PYTHONTOP)/Include". (Most header files are in the "Include/" subdirectory, but the "config.h" header lives in the toplevel directory.)



guido@python.org