From b9c2b0c218d8e7858f57dbc9e580d4d36c3ec46c Mon Sep 17 00:00:00 2001 From: Bas Nijholt <basnijholt@gmail.com> Date: Mon, 13 Nov 2017 20:54:24 +0100 Subject: [PATCH] add numpy includes later in the extension config Previously, the numpy 'include_dirs' would be shadowed by any 'include_dirs' provided in 'build.conf'. We want to avoid burdening people with remembering to specify the numpy 'include_dirs' every time, and if custom numpy headers is the desired behaviour, these can still be specified in 'build.conf', and will take precedence. --- setup.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/setup.py b/setup.py index 4060f6ca..2be55da1 100755 --- a/setup.py +++ b/setup.py @@ -505,6 +505,20 @@ def maybe_cythonize(exts): return result +def maybe_add_numpy_include(exts): + # Add NumPy header path to include_dirs of all the extensions. + try: + import numpy + except ImportError: + print(banner(' Caution '), 'NumPy header directory cannot be determined' + ' ("import numpy" failed).', banner(), sep='\n', file=sys.stderr) + else: + numpy_include = numpy.get_include() + for ext in exts.values(): + ext.setdefault('include_dirs', []).append(numpy_include) + return exts + + def main(): check_python_version((3, 5)) check_versions() @@ -540,17 +554,6 @@ def main(): dict(sources=['kwant/linalg/_mumps.pyx'], depends=['kwant/linalg/cmumps.pxd']))]) - # Add NumPy header path to include_dirs of all the extensions. - try: - import numpy - except ImportError: - print(banner(' Caution '), 'NumPy header directory cannot be determined' - ' ("import numpy" failed).', banner(), sep='\n', file=sys.stderr) - else: - numpy_include = numpy.get_include() - for ext in exts.values(): - ext.setdefault('include_dirs', []).append(numpy_include) - aliases = [('mumps', 'kwant.linalg._mumps')] init_cython() @@ -559,6 +562,7 @@ def main(): build_summary = [] exts = configure_extensions(exts, aliases, build_summary) exts = configure_special_extensions(exts, build_summary) + exts = maybe_add_numpy_include(exts) exts = maybe_cythonize(exts) classifiers = """\ -- GitLab