8000 setup.py: Fix numpy installation · saketkc/scikit-learn@eab4f7c · GitHub
[go: up one dir, main page]

Skip to content

Commit eab4f7c

Browse files
committed
setup.py: Fix numpy installation
Pass build_requires if numpy is not found Fixes scikit-learn#4164 Signed-off-by: Saket Choudhary <saketkc@gmail.com>
1 parent d39fe22 commit eab4f7c

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

setup.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,19 @@ def configuration(parent_package='', top_path=None):
104104

105105
return config
106106

107+
def is_Numpy_installed():
108+
try:
109+
import numpy
110+
except ImportError:
111+
return False
107112

108113
def setup_package():
114+
115+
build_requires = []
116+
is_numpy_installed = is_Numpy_installed()
117+
if is_numpy_installed is False:
118+
build_requires = ['numpy>=1.6.2']
119+
109120
metadata = dict(name=DISTNAME,
110121
maintainer=MAINTAINER,
111122
maintainer_email=MAINTAINER_EMAIL,
@@ -134,6 +145,7 @@ def setup_package():
134145
'Programming Language :: Python :: 3.4',
135146
],
136147
cmdclass={'clean': CleanCommand},
148+
install_requires=build_requires,
137149
**extra_setuptools_args)
138150

139151
if (len(sys.argv) >= 2
@@ -152,6 +164,10 @@ def setup_package():
152164

153165
metadata['version'] = VERSION
154166
else:
167+
if is_numpy_installed is False:
168+
sys.stderr.write("[Error] Numpy is required to setup scikit-learn\n"
169+
"Please install numpy from http://numpy.org\n")
170+
sys.exit(1)
155171
from numpy.distutils.core import setup
156172

157173
metadata['configuration'] = configuration

0 commit comments

Comments
 (0)
0