What is the most conventional way to integrate C code into a Python library using distutils?
The shared libraries are the right way to go in this case. The distutils
have ability to build the static libraries as follows:
from distutils.ccompiler import new_compilerfrom distutils import sysconfigc = new_compiler()workdir = "."c.add_include_dir( sysconfig.get_python_inc() )c.add_include_dir("./include")objects = c.compile(["file1.c", "file2.c"])c.link_shared_lib(objects, "mylibrary", output_dir=workdir)
This will generate the .so
library in the working directory.
For example how it's used in real setup
see the following example