The setuptools / distutils extension options are what you need.
The documentation contains additional information , in a nutshell setup.py example, to do the above will look below
from setuptools import setup, find_packages, Extension extensions = [Extension("my_package.ext_library", ["src/library.c"], depends=["src/library.h"], include_dirs=["src"], ), ] setup(<..>, ext_modules=extensions, )
When you build the .so module, setup.py is automatically created. If it needs to link to other libraries, you can provide a list of libraries arguments for extension. See the documents ( 1 ) for more details.
Since this is built into the setuptools functions, it works great with pip and can be distributed (only as source code) to pypi. All source files referenced by Extension must be present in the distributed pypi archive.
If you want to create distribution binaries, including native code, see manylinux .
danny
source share