[Numpy-discussion] cython and f2py

Geoffrey Ely gely@usc....
Fri Jul 2 14:53:35 CDT 2010

Hi All,

Sorry if this has been documented or discussed already, but my searches have come up short. Can someone please recommend a way to setup both Cython and Fortran extensions in a single package with numpy.distutils (or something else)? E.g.:

from numpy.distutils.core import setup, Extension
ext_modules = [
    Extension( 'cext', ['cext.pyx'] ),
    Extension( 'fext', ['fext.f90'] ),
    name = 'test',
    ext_modules = ext_modules,

Can numpy.distutils be directed to process *.pyx with Cython rather than Pyrex?

Is is kosher to call setup twice in the same script, once for Fortran, and once for Cython using Cython.Distutils.build_ext, or would that do bad things?

I guess I could just pre-process the Cython stuff, and have distutils work with the generated C, but I don't like that as much.

I am using numpy version 1.4.0, but can update to the development version if that helps.


More information about the NumPy-Discussion mailing list