Skip to content Skip to sidebar Skip to footer

Python Setuptools: How Can I Install Package With Cython Submodules?

I have a python package named pytools. It contains a cython-based submodule nms. When I install the root package pytools with sudo python -H setup.py, the root package seems to be

Solution 1:

You don't need the setup script in a subpackage. Just build the extension in the root setup script:

exts = [Extension(name='pytools.nms',
                  sources=["pytools/nms/_nms.pyx", "pytools/nms/nms.c"],
                  include_dirs=[numpy.get_include()])]

setup(
    ...
    packages=['pytools'],
    ext_modules=cythonize(exts)
)

Note that I wrap cythonized extension in cythonize() and use the full module name + full paths to extension sources. Also, since nms is a module in pytools package, including pytools.nms in packages has no effect.

Post a Comment for "Python Setuptools: How Can I Install Package With Cython Submodules?"