13
13
import traceback
14
14
try :
15
15
import builtins
16
- # This is a bit (!) hackish: we are setting a global variable so that the
17
- # main sklearn __init__ can detect if it is being loaded by the setup
18
- # routine, to avoid attempting to load components that aren't built yet:
19
- # the numpy distutils extensions that are used by scikit-learn to
20
- # recursively build the compiled extensions in sub-packages is based on the
21
- # Python import machinery.
22
- builtins .__SKLEARN_SETUP__ = True
23
16
except ImportError :
24
- # Python 2 is not support but we will raise an explicit error message next.
25
- pass
17
+ # Python 2 compat: just to be able to declare that Python >=3.5 is needed.
18
+ import __builtin__ as builtins
19
+
20
+ # This is a bit (!) hackish: we are setting a global variable so that the
21
+ # main sklearn __init__ can detect if it is being loaded by the setup
22
+ # routine, to avoid attempting to load components that aren't built yet:
23
+ # the numpy distutils extensions that are used by scikit-learn to
24
+ # recursively build the compiled extensions in sub-packages is based on the
25
+ # Python import machinery.
26
+ builtins .__SKLEARN_SETUP__ = True
26
27
27
- if sys .version_info < (3 , 5 ):
28
- raise RuntimeError ("Scikit-learn requires Python 3.5 or later. The current"
29
- " Python version is %s installed in %s."
30
- % (platform .python_version (), sys .executable ))
31
28
32
29
DISTNAME = 'scikit-learn'
33
30
DESCRIPTION = 'A set of python modules for machine learning and data mining'
@@ -116,27 +113,33 @@ def run(self):
116
113
shutil .rmtree (os .path .join (dirpath , dirname ))
117
114
118
115
116
+ cmdclass = {'clean' : CleanCommand }
117
+
119
118
# custom build_ext command to set OpenMP compile flags depending on os and
120
119
# compiler
121
120
# build_ext has to be imported after setuptools
122
- from numpy . distutils . command . build_ext import build_ext # noqa
123
-
121
+ try :
122
+ from numpy . distutils . command . build_ext import build_ext # noqa
124
123
125
- class build_ext_subclass (build_ext ):
126
- def build_extensions (self ):
127
- from sklearn ._build_utils .openmp_helpers import get_openmp_flag
124
+ class build_ext_subclass (build_ext ):
125
+ def build_extensions (self ):
126
+ from sklearn ._build_utils .openmp_helpers import get_openmp_flag
128
127
129
- if not os .getenv ('SKLEARN_NO_OPENMP' ):
130
- openmp_flag = get_openmp_flag (self .compiler )
128
+ if not os .getenv ('SKLEARN_NO_OPENMP' ):
129
+ openmp_flag = get_openmp_flag (self .compiler )
131
130
132
- for e in self .extensions :
133
- e .extra_compile_args += openmp_flag
134
- e .extra_link_args += openmp_flag
131
+ for e in self .extensions :
132
+ e .extra_compile_args += openmp_flag
133
+ e .extra_link_args += openmp_flag
135
134
136
- build_ext .build_extensions (self )
135
+ build_ext .build_extensions (self )
137
136
137
+ cmdclass ['build_ext' ] = build_ext_subclass
138
138
139
- cmdclass = {'clean' : CleanCommand , 'build_ext' : build_ext_subclass }
139
+ except ImportError :
140
+ # Numpy should not be a dependency just to be able to introspect
141
+ # that python 3.5 is required.
142
+ pass
140
143
141
144
142
145
# Optional wheelhouse-uploader features
@@ -225,6 +228,7 @@ def setup_package():
225
228
'Implementation :: PyPy' )
226
229
],
227
230
cmdclass = cmdclass ,
231
+ python_requires = ">=3.5" ,
228
232
install_requires = [
229
233
'numpy>={}' .format (NUMPY_MIN_VERSION ),
230
234
'scipy>={}' .format (SCIPY_MIN_VERSION ),
@@ -250,6 +254,12 @@ def setup_package():
250
254
251
255
metadata ['version' ] = VERSION
252
256
else :
257
+ if sys .version_info < (3 , 5 ):
258
+ raise RuntimeError (
259
+ "Scikit-learn requires Python 3.5 or later. The current"
260
+ " Python version is %s installed in %s."
261
+ % (platform .python_version (), sys .executable ))
262
+
253
263
numpy_status = get_numpy_status ()
254
264
numpy_req_str = "scikit-learn requires NumPy >= {}.\n " .format (
255
265
NUMPY_MIN_VERSION )
0 commit comments