From 9ddd860267a4bf12a3b7389192bed692a78ca39a Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Fri, 7 Jun 2019 16:36:14 -0400 Subject: [PATCH] fix installation for users who don't already have numpy --- setup.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/setup.py b/setup.py index 89c3133f..d7b2d12b 100755 --- a/setup.py +++ b/setup.py @@ -11,6 +11,7 @@ from setuptools import setup, Extension, find_packages from distutils.command.sdist import sdist from distutils.command.build_py import build_py +from distutils.command.build_ext import build_ext from hyperion.testing.helper import HyperionTest from hyperion.version import __version__, __dev__ @@ -35,10 +36,19 @@ def run(self): if not self.unstable: open(version_file, 'w').write(content) + +class NumpyBuildExt(build_ext): + def run(self): + import numpy + self.include_dirs.append(numpy.get_include()) + build_ext.run(self) + + cmdclass = {} cmdclass['build_py'] = build_py cmdclass['test'] = HyperionTest cmdclass['sdist'] = custom_sdist +cmdclass['build_ext'] = NumpyBuildExt if 'egg_info' in sys.argv: @@ -46,20 +56,14 @@ def run(self): else: - from numpy import get_include as get_numpy_include - numpy_includes = get_numpy_include() - ext_modules = [Extension("hyperion.util._integrate_core", ['hyperion/util/_integrate_core.c'], - include_dirs=[numpy_includes], extra_compile_args=['-Wno-error=declaration-after-statement']), Extension("hyperion.util._interpolate_core", ['hyperion/util/_interpolate_core.c'], - include_dirs=[numpy_includes], extra_compile_args=['-Wno-error=declaration-after-statement']), Extension("hyperion.importers._discretize_sph", ['hyperion/importers/_discretize_sph.c'], - include_dirs=[numpy_includes], extra_compile_args=['-Wno-error=declaration-after-statement']), Extension("hyperion.grid._voronoi_core", ['hyperion/grid/_voronoi_core.c', @@ -75,8 +79,7 @@ def run(self): 'hyperion/grid/voro++/v_compute.cc', 'hyperion/grid/voro++/wall.cc'], extra_compile_args = ['-O2', '-Wno-error=declaration-after-statement'], - extra_link_args=['-lstdc++'], - include_dirs=[numpy_includes])] + extra_link_args=['-lstdc++'])] scripts = ['hyperion', 'hyperion2fits']