I am packaging a project involving cython extensions inside a namespace package. My folder structure looks as follows
.
├── namespace_package
│ └── package
| ├── extension.pxd
| ├── extension.pyx
│ └── __init__.py
└── setup.py
My setup script looks as follows:
from setuptools import setup
from setuptools.extension import Extension
# factory function
def my_build_ext(pars):
# import delayed:
from setuptools.command.build_ext import build_ext as _build_ext
# include_dirs adjusted:
class build_ext(_build_ext):
def finalize_options(self):
_build_ext.finalize_options(self)
# Prevent numpy from thinking it is still in its setup process:
__builtins__.__NUMPY_SETUP__ = False
import numpy
self.include_dirs.append(numpy.get_include())
#object returned:
return build_ext(pars)
extensions = [Extension(namespace_package.package.extension, ['namespace_package\\package\\extension.pyx']]
setup(
cmdclass={'build_ext' : my_build_ext},
setup_requires=['cython', 'numpy'],
install_requires=['cython', 'numpy'],
packages=['namespace_package.package'],
ext_modules=extensions
)
Here, I used the tricks to delay the import of numpy
and cython
as described here, and my solution is inspired by this solution.
The problem is that extension.pxd
is not found or processed. That is, declarations made in extension.pxd
are not available and I get the corresponding errors.
How do I do the setup properly so that all files are found and processed?