I'm using the basic "hello world" demo straight out of the Cython documentation. It works fine unless I try to import py2app in the same setup.py file:
import py2app
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
setup(
cmdclass = {'build_ext': build_ext},
ext_modules = [Extension("helloworld", ["helloworld.pyx"])]
)
Py2app itself works fine as long as I pre-generate the .c
files for my Cython modules. But if I haven't, then build_ext
fails with:
running build_ext
gcc-4.2 not found, using clang instead
building 'helloworld' extension
clang -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -g -O2 -DNDEBUG -g -O3 -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c helloworld.c -o build/temp.macosx-10.6-intel-2.7/helloworld.o
clang: error: no such file or directory: 'helloworld.c'
clang: error: no input files
error: command 'clang' failed with exit status 1
If I comment out import py2app
in setup.py, build_ext
works fine and I get the missing intermediate step in my compilation:
...
gcc-4.2 not found, using clang instead
cythoning helloworld/helloworld.pyx to helloworld/helloworld.c
building 'helloworld' extension
...
So what is it about py2app that breaks Cython? And what can I do about it? I'd like to have just one setup.py for my project, obviously.
I have Cython 0.18 and py2app 0.7.2, installed from PyPI. I'm using Mac OS X 10.8 with the python.org Python 2.7.3, not Apple's build.
The build fails because py2app uses setuptools, and older versions of setuptools (and distribute) are not compatible with Cython.
The solution is to install a newer version of setuptools or distribute.