From 0707caaee667c4ceb092f8c5208a5e560c4b31b7 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Tue, 11 Sep 2018 21:25:35 -0400 Subject: [PATCH] [SCons] Check for a supported version of Python --- SConstruct | 15 +++++++++++---- interfaces/cython/setup.py.in | 5 +++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/SConstruct b/SConstruct index 33c2b26c7..ae9cdfd86 100644 --- a/SConstruct +++ b/SConstruct @@ -1110,6 +1110,7 @@ if env['VERBOSE']: env['python_cmd_esc'] = quoted(env['python_cmd']) # Python Package Settings +python_min_version = LooseVersion('3.3') cython_min_version = LooseVersion('0.23') numpy_min_test_version = LooseVersion('1.8.1') @@ -1176,13 +1177,19 @@ if env['python_package'] in ('full', 'default'): print(err, err.output) warn_no_python = True else: - env['python_version'] = info[0] + python_version = LooseVersion(info[0]) numpy_version = LooseVersion(info[1]) cython_version = LooseVersion(info[2]) if len(info) > 3: print("WARNING: Unexpected output while checking Python / Numpy / Cython versions:") print('| ' + '\n| '.join(info[3:])) + if python_version < python_min_version: + print("WARNING: Python is an incompatible version: " + "Found {0} but {1} or newer is required".format( + python_version, python_min_version)) + warn_no_python = True + if numpy_version == LooseVersion('0.0.0'): print("NumPy not found.") warn_no_python = True @@ -1217,7 +1224,7 @@ if env['python_package'] in ('full', 'default'): sys.exit(1) else: - print('INFO: Building the full Python package for Python {0}'.format(env['python_version'])) + print('INFO: Building the full Python package for Python {0}'.format(python_version)) env['python_package'] = 'full' if env['python_package'] in ('minimal', 'minimal-default'): @@ -1241,7 +1248,7 @@ if env['python_package'] in ('minimal', 'minimal-default'): print(err, err.output) warn_no_python = True else: - (env['python_version'],) = info.splitlines()[-1:] + python_version = info.splitlines()[-1] if warn_no_python: if env['python_package'] == 'minimal-default': @@ -1253,7 +1260,7 @@ if env['python_package'] in ('minimal', 'minimal-default'): print('ERROR: Could not execute the Python interpreter {!r}.'.format(env['python_cmd'])) sys.exit(1) else: - print('INFO: Building the minimal Python package for Python {0}'.format(env['python_version'])) + print('INFO: Building the minimal Python package for Python {0}'.format(python_version)) env['python_package'] = 'minimal' if env['python_package'] != 'none': diff --git a/interfaces/cython/setup.py.in b/interfaces/cython/setup.py.in index b0f321c19..8b37a2c8e 100644 --- a/interfaces/cython/setup.py.in +++ b/interfaces/cython/setup.py.in @@ -9,7 +9,7 @@ from setuptools import setup # 'has_ext_modules' method is called in bdist_msi.run, which is where the # replacement of build_lib happens. Subsequent calls to 'has_ext_modules' # should use the correct value so that the resulting installer is specific to -# this Python version. Known to affect Python versions 2.6 through 3.3. If +# this Python version. Known to affect Python versions 2.6 through 3.7. If # this bug is ever fixed, this patch should be made conditional on the Python # version. if os.name == 'nt': @@ -83,10 +83,11 @@ setup( 'Operating System :: POSIX :: Linux', 'Programming Language :: C++', 'Programming Language :: Fortran', - 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', 'Topic :: Scientific/Engineering :: Chemistry', ], package_data = {