It took me a few hours to figure this out.
For people creating Cython packages, if you notice that this:
$ python setup.py build_ext -i
works fine, while this:
$ pip install .
breaks with "gcc: error: hello.c: No such file or directory", you have two options:
1. Install the 'distribute' package, or
2. Include the following magic in your setup.py:
# Needed to fix pip
# See
https://pypi.python.org/pypi/setuptools_cython/,
#
http://mail.python.org/pipermail/distutils-sig/2007-September/thread.html#8204 import sys
if 'setuptools.extension' in sys.modules:
m = sys.modules['setuptools.extension']
m.Extension.__dict__ = m._Extension.__dict__
The reason is that Cython and setup.py use "distutils", the oldest python packaging system. However, easy_install and pip use "setuptools", a slightly newer but still old packaging system that monkeypatched support for Pyrex .pyx files. Setuptools will go through all the Extension()s and replace ".pyx" files with ".c" files without compiling them. The newer "distribute" package *reimplements* setuptools without breaking cython, which is why pip/easy_install mysteriously work if you happen to have distribute installed.
I'm not sure if this is a bug or what's happening here...
Just figured I'd post this for others who are having the same issue.