From f55d9573a602b7e91b37623fbe14e05455328f5d Mon Sep 17 00:00:00 2001 From: Brendan Smithyman Date: Sun, 24 Apr 2016 13:21:49 -0400 Subject: [PATCH] Installation (i.e., setup.py) is no longer dependent on Numpy already being present. --- setup.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index 3383c7f7..5308db47 100644 --- a/setup.py +++ b/setup.py @@ -5,16 +5,17 @@ SimPEG is a python package for simulation and gradient based parameter estimation in the context of geophysical applications. """ -import numpy as np - import os import sys import subprocess from distutils.core import setup +from distutils.command.build_ext import build_ext from setuptools import find_packages from distutils.extension import Extension + + CLASSIFIERS = [ 'Development Status :: 4 - Beta', 'Intended Audience :: Developers', @@ -51,11 +52,16 @@ if args.count("build_ext") > 0 and args.count("--inplace") == 0: try: from Cython.Build import cythonize from Cython.Distutils import build_ext - cythonKwargs = dict(cmdclass={'build_ext': build_ext}) USE_CYTHON = True except Exception, e: USE_CYTHON = False - cythonKwargs = dict() + +class NumpyBuild(build_ext): + def finalize_options(self): + build_ext.finalize_options(self) + __builtins__.__NUMPY_SETUP__ = False + import numpy + self.include_dirs.append(numpy.get_include()) ext = '.pyx' if USE_CYTHON else '.c' @@ -94,8 +100,8 @@ setup( classifiers=CLASSIFIERS, platforms = ["Windows", "Linux", "Solaris", "Mac OS-X", "Unix"], use_2to3 = False, - include_dirs=[np.get_include()], + cmdclass={'build_ext':NumpyBuild}, + setup_requires=['numpy'], ext_modules = extensions, scripts=scripts, - **cythonKwargs )