From 2ca138ea68f160db5fc9a8687a08df03ad5dd74c Mon Sep 17 00:00:00 2001 From: David Sheldon Date: Tue, 24 Jul 2018 15:43:29 +0100 Subject: [PATCH] Allow setup.py to be parsed without numpy If numpy isn't available, don't define ext_mods, pip will then determine numpy is required, install it, then call us again. Fixes #653 --- setup.py | 60 +++++++++++++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/setup.py b/setup.py index 5e4357b5..ab7e85a0 100644 --- a/setup.py +++ b/setup.py @@ -38,7 +38,6 @@ from __future__ import print_function import os import sys from setuptools import setup, Extension -import numpy as np import codecs def read(fname): @@ -80,32 +79,39 @@ else: compile_flags = [ '-fopenmp', '-O3'] link_args = ['-lgomp' ] -ext_mods = [Extension(name='GPy.kern.src.stationary_cython', - sources=['GPy/kern/src/stationary_cython.c', - 'GPy/kern/src/stationary_utils.c'], - include_dirs=[np.get_include(),'.'], - extra_compile_args=compile_flags, - extra_link_args = link_args), - Extension(name='GPy.util.choleskies_cython', - sources=['GPy/util/choleskies_cython.c'], - include_dirs=[np.get_include(),'.'], - extra_link_args = link_args, - extra_compile_args=compile_flags), - Extension(name='GPy.util.linalg_cython', - sources=['GPy/util/linalg_cython.c'], - include_dirs=[np.get_include(),'.'], - extra_compile_args=compile_flags, - extra_link_args = link_args), - Extension(name='GPy.kern.src.coregionalize_cython', - sources=['GPy/kern/src/coregionalize_cython.c'], - include_dirs=[np.get_include(),'.'], - extra_compile_args=compile_flags, - extra_link_args = link_args), - Extension(name='GPy.models.state_space_cython', - sources=['GPy/models/state_space_cython.c'], - include_dirs=[np.get_include(),'.'], - extra_compile_args=compile_flags, - extra_link_args = link_args)] +try: + # So that we don't need numpy installed to determine it's a dependency. + import numpy as np + + ext_mods = [Extension(name='GPy.kern.src.stationary_cython', + sources=['GPy/kern/src/stationary_cython.c', + 'GPy/kern/src/stationary_utils.c'], + include_dirs=[np.get_include(), '.'], + extra_compile_args=compile_flags, + extra_link_args=link_args), + Extension(name='GPy.util.choleskies_cython', + sources=['GPy/util/choleskies_cython.c'], + include_dirs=[np.get_include(), '.'], + extra_link_args=link_args, + extra_compile_args=compile_flags), + Extension(name='GPy.util.linalg_cython', + sources=['GPy/util/linalg_cython.c'], + include_dirs=[np.get_include(), '.'], + extra_compile_args=compile_flags, + extra_link_args=link_args), + Extension(name='GPy.kern.src.coregionalize_cython', + sources=['GPy/kern/src/coregionalize_cython.c'], + include_dirs=[np.get_include(), '.'], + extra_compile_args=compile_flags, + extra_link_args=link_args), + Extension(name='GPy.models.state_space_cython', + sources=['GPy/models/state_space_cython.c'], + include_dirs=[np.get_include(), '.'], + extra_compile_args=compile_flags, + extra_link_args=link_args)] +except ModuleNotFoundError: + ext_mods = [] + setup(name = 'GPy', version = __version__,