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
This commit is contained in:
David Sheldon 2018-07-24 15:43:29 +01:00 committed by GitHub
parent 06441f583f
commit 2ca138ea68
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -38,7 +38,6 @@ from __future__ import print_function
import os import os
import sys import sys
from setuptools import setup, Extension from setuptools import setup, Extension
import numpy as np
import codecs import codecs
def read(fname): def read(fname):
@ -80,6 +79,10 @@ else:
compile_flags = [ '-fopenmp', '-O3'] compile_flags = [ '-fopenmp', '-O3']
link_args = ['-lgomp' ] link_args = ['-lgomp' ]
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', ext_mods = [Extension(name='GPy.kern.src.stationary_cython',
sources=['GPy/kern/src/stationary_cython.c', sources=['GPy/kern/src/stationary_cython.c',
'GPy/kern/src/stationary_utils.c'], 'GPy/kern/src/stationary_utils.c'],
@ -106,6 +109,9 @@ ext_mods = [Extension(name='GPy.kern.src.stationary_cython',
include_dirs=[np.get_include(), '.'], include_dirs=[np.get_include(), '.'],
extra_compile_args=compile_flags, extra_compile_args=compile_flags,
extra_link_args=link_args)] extra_link_args=link_args)]
except ModuleNotFoundError:
ext_mods = []
setup(name = 'GPy', setup(name = 'GPy',
version = __version__, version = __version__,