[Numpy-discussion] cython and f2py

Geoffrey Ely gely@usc....
Mon Jul 5 16:31:10 CDT 2010


On Jul 2, 2010, at 1:07 PM, Matthew Brett wrote:

>> Can numpy.distutils be directed to process *.pyx with Cython rather than Pyrex?
> 
> Yes, but at the moment I believe you have to monkey-patch numpy
> distutils : see the top of
> 
> http://github.com/matthew-brett/nipy/blob/master/setup.py
> 
> and "generate_a_pyrex_source" around line 289 of:
> 
> http://github.com/matthew-brett/nipy/blob/master/build_helpers.py
> 
> for how we've done it - there may be a better way - please post if you find it!

Thanks Matthew.  I don't know enough about distutils to quite follow everything that you have done.  So I think I will get by for now by calling setup separately as in the code below.  It seems to be working for installing from source, which is my main goal.  Anyone know if this is a bad idea?

-Geoff

# Cython extension
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
setup(
    ext_modules = [Extension( 'cext', ['cext.pyx'] )],
    cmdclass = {'build_ext': build_ext},
    script_args = ['build_ext', '--inplace'],
)

# Fortran extension
from numpy.distutils.core import setup, Extension
setup(
    ext_modules = [Extension( 'fext', ['fext.f90'] )],
)



More information about the NumPy-Discussion mailing list