[SCons] Check for a supported version of Python

This commit is contained in:
Ray Speth 2018-09-11 21:25:35 -04:00
parent d2a1bf1e6a
commit 0707caaee6
2 changed files with 14 additions and 6 deletions

View file

@ -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':

View file

@ -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 = {