In my installation, numpy\'s arrayobject.h is located at …/site-packages/numpy/core/include/numpy/arrayobject.h. I wrote a trivial Cython script t
For anyone not using Cython, a slight modification of R_Beagrie's solution without that dependency is if you simply import build_ext from distutils.command.build_ext instead of Cython.
from distutils.core import setup
from distutils.extension import Extension
from distutils.command.build_ext import build_ext
class CustomBuildExtCommand(build_ext):
"""build_ext command for use when numpy headers are needed."""
def run(self):
# Import numpy here, only when headers are needed
import numpy
# Add numpy headers to include_dirs
self.include_dirs.append(numpy.get_include())
# Call original build_ext command
build_ext.run(self)
ext_modules = [Extension("hello", ["hello.c"])]
setup(
name = 'Hello world app',
cmdclass = {'build_ext': CustomBuildExtCommand},
install_requires=['numpy'],
ext_modules = ext_modules
)