Numpy headers not included when building extensions (OSX)
When I try to build kwant using pip (either from pypi or git) the numpy headers are not properly included when building extensions. Namely
$ sudo pip3 install git+https://gitlab.kwant-project.org/kwant/kwant.git --log log.out
...
running build_ext
building 'kwant._system' extension
creating build/temp.macosx-10.11-x86_64-3.5
creating build/temp.macosx-10.11-x86_64-3.5/kwant
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Ikwant/graph -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/include/python3.5m -c kwant/_system.c -o build/temp.macosx-10.11-x86_64-3.5/kwant/_system.o
kwant/_system.c:288:10: fatal error: 'numpy/arrayobject.h' file not found
#include "numpy/arrayobject.h"
^
1 error generated.
************************************ Error ************************************
The compilation of Kwant has failed. Please examine the error message
above and consult the installation instructions in README.rst.
You might have to customize build.conf.
Build configuration was:
Default LAPACK and BLAS
No MUMPS support
*******************************************************************************
error: command 'clang' failed with exit status 1
----------------------------------------
Command "/usr/local/opt/python3/bin/python3.5 -u -c "import setuptools, tokenize;__file__='/tmp/pip-glxp49gu-build/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-isnpqpom-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-glxp49gu-build
Unsure if I have something improperly installed (everything was installed using brew/pip), but I managed to fix it by adding numpy.get_include()
to include_dirs
for each of the extensions in setup.py
. It's a bit hacky; there's probably a better way (add a compiler flag?).
Running OSX El Capitan (10.11.6)
$ python3 -c "import numpy; print(numpy.version.version)"
1.11.1
$ python3 --version
Python 3.5.1
$ pip3 --version
pip 8.0.2 from /usr/local/lib/python3.5/site-packages (python 3.5)
No MUMPS (I had to update kwant.lapack.linalg
as well)