How To Package A Python C Extension Such That It Is A Submodule Of A Normal Python Module?
I wrote a python library with two parts: A Python C extension A Python wrapper for the Python C extension I would like to be able to package it in such a way that the Python wrap
Solution 1:
As mentioned in the linked question, the solution is simply to change _foo
to foo._foo
:
from distutils.coreimport setup, Extensionmodule = Extension('foo._foo',
sources=['foo.c'])
setup(name='foo', packages=['foo'], ext_modules=[module])
My issue was that I was running my tests.py
from the same directory as the foo
module was located in.
I fixed this by bringing it into its own directory:
/foo
/foo
__init__.py
foo.c
setup.py
/tests
test.py
Post a Comment for "How To Package A Python C Extension Such That It Is A Submodule Of A Normal Python Module?"