[Numpy-discussion] problem with numpy.distutils and Cython

Lisandro Dalcin dalcinl at gmail.com
Sun Aug 23 18:30:59 EDT 2009


The monkeypatching below in your setup.py could work. This way, you
just have to use numpy.distutils, but you will not be able to pass
many options to Cython (like C++ code generation?)

from numpy.distutils.command import build_src
import Cython
import Cython.Compiler.Main
build_src.Pyrex = Cython
build_src.have_pyrex = True


On Sun, Aug 23, 2009 at 4:34 AM, Robert Kern<robert.kern at gmail.com> wrote:
> On Sun, Aug 23, 2009 at 00:27, Nicolas Pinto<nicolas.pinto at gmail.com> wrote:
>> Hello,
>>
>> I'm trying to use numpy.distutils and Cython in a setup.py but I'm running
>> into some problems.
>>
>> The following code raises a "AttributeError: fcompiler" when I run "python
>> setup.py install" (it runs smoothly with "python setup.py build_ext
>> --inplace"):
>>
>> from numpy.distutils.core import setup, Extension
>> from Cython.Distutils import build_ext
>> ext_modules = [Extension("test", ["test.pyx"])]
>> setup(cmdclass = {'build_ext': build_ext}, ext_modules = ext_modules)
>>
>> Whereas the following works in both cases:
>>
>> from distutils.core import setup, Extension
>> from Cython.Distutils import build_ext
>> ext_modules = [Extension("test", ["test.pyx"])]
>> setup(cmdclass = {'build_ext': build_ext}, ext_modules = ext_modules)
>>
>> Am I missing something?
>
> numpy.distutils needs its own build_ext, which you are overriding with
> Cython's. You need one build_ext that does both things.
>
> --
> Robert Kern
>
> "I have come to believe that the whole world is an enigma, a harmless
> enigma that is made terrible by our own mad attempt to interpret it as
> though it had an underlying truth."
>  -- Umberto Eco
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>



-- 
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594



More information about the NumPy-Discussion mailing list