How to build a Python C Extension so I can import it from a module
Just change
Extension('c_extension', ...)
to
Extension('foo.bar.c_extension', ...)
You will need __init__.py
files in each of the foo
and bar
directories, as usual. To have these packaged with the module in your setup.py, you need to add
packages = ['foo', 'foo.bar'],
to your setup() call, and you will need the directory structure
setup.pyfoo/ __init__.py bar/ __init__.py
in your source directory.