I think we are nearly there since your latest additions to the hook.py. However, cythonization still requires to patch hooks.py to enable it and makes packaging more complicated than it probably should (need to carry a separate patch to enable cythonization).
from distutils.core import setup
from distutils.extension import Extension
USE_CYTHON = ... # command line option, try-import, ...
ext = '.pyx' if USE_CYTHON else '.c'
extensions = [Extension("example", ["example"+ext])]
if USE_CYTHON:
from Cython.Build import cythonize
extensions = cythonize(extensions)
setup(
ext_modules = extensions
)
USE_CYTHON can be either user-defined as a command line option, or automatically set using a try catch block surrounding an import on Cython. I personally prefer the latter.
I can work on a pull-request for this if you see no objections.
Yeah you're right, that's better to have a try catch block in hooks.py to set the default value for hooks.RECOMPILE_CYTHON to True if the Cython import works. Go ahead with the pull request.
I think we are nearly there since your latest additions to the hook.py. However, cythonization still requires to patch hooks.py to enable it and makes packaging more complicated than it probably should (need to carry a separate patch to enable cythonization).
Using the following code snippet from http://docs.cython.org/src/reference/compilation.html
USE_CYTHON can be either user-defined as a command line option, or automatically set using a try catch block surrounding an import on Cython. I personally prefer the latter.
I can work on a pull-request for this if you see no objections.