[Numpy-discussion] Recommended way to add Cython extension using numpy.distutils?

Kevin Jacobs <jacobs@bioinformed.com> bioinformed@gmail....
Wed Apr 28 12:20:00 CDT 2010

On Tue, Apr 27, 2010 at 8:09 PM, Matthew Brett <matthew.brett@gmail.com>wrote:

> Hi,
> We (neuroimaging.scipy.org) are using numpy.distutils, and we have
> .pyx files that we build with Cython.
> I wanted to add these in our current setup.py scripts, with something like:
> def configuration(parent_package='',top_path=None):
>    from numpy.distutils.misc_util import Configuration
>    config = Configuration('statistics', parent_package, top_path)
>    config.add_extension('intvol',
>                         ['intvol.pyx'], include_dirs = [np.get_include()])
>    return config
> but of course numpy only knows about Pyrex, and returns:
> error: Pyrex required for compiling
> 'nipy/algorithms/statistics/intvol.pyx' but notavailable
> Is there a recommended way to plumb Cython into the numpy build
> machinery?  Should I try and patch numpy distutils to use Cython if
> present?
Here is the monkey-patch I'm using in my project:

def evil_numpy_monkey_patch():
  from   numpy.distutils.command import build_src
  import Cython
  import Cython.Compiler.Main
  build_src.Pyrex = Cython
  build_src.have_pyrex = True
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20100428/e5f3e379/attachment.html 

More information about the NumPy-Discussion mailing list