I have a python package (python 2.7) that includes some optimized functions written in cython. My setup.py handles the pure-python files and the installed package uses the un-optimized pure python functions.
I'm trying to understand what is the best way to setup the project for distributing the C extension.
Right now I have a specific setup.py
in the extension folder that can be used to compile the extension with:
python setup.py build_ext --inplace
But I want the package installation to also handle the C extension. Possibly with a single:
python setup.py
I was thinking of merging the specific setup.py in the project-wide setup.py. However, to compile the extension, I need to import numpy. But I know that importing anything outside the standard lib in setup.py is discouraged.
What are the best practices for python packages including a simple cython extensions that only uses numpy and no other external libs?
For now I settled on the following solution that requires importing numpy. It does not cause problems so far.
setup.py