If Cython can't be imported, the cython_version is undefined
This results in a NameError and building fails. Change to check for one exception at a time, with the relevant error message.
This commit is contained in:
parent
4a4886f63e
commit
7054a7bb3d
1 changed files with 18 additions and 9 deletions
27
SConstruct
27
SConstruct
|
|
@ -1140,18 +1140,27 @@ if require_python or want_python:
|
|||
import Cython
|
||||
cython_version = LooseVersion(Cython.__version__)
|
||||
assert cython_version >= cython_min_version
|
||||
except (ImportError, AssertionError):
|
||||
message = ("Cython not found or incompatible version: "
|
||||
except ImportError:
|
||||
message = "Cython could not be imported."
|
||||
have_cython = False
|
||||
except AssertionError:
|
||||
message = ("Cython is an incompatible version: "
|
||||
"Found {0} but {1} or newer is required.".format(cython_version,
|
||||
cython_min_version))
|
||||
if require_python:
|
||||
print('ERROR: ' + message)
|
||||
sys.exit(1)
|
||||
elif want_python:
|
||||
print('WARNING: ' + message)
|
||||
env['python_package'] = 'minimal'
|
||||
have_cython = False
|
||||
else:
|
||||
print('INFO: Using Cython version {0}.'.format(cython_version))
|
||||
have_cython = True
|
||||
finally:
|
||||
if not have_cython:
|
||||
if require_python:
|
||||
print('ERROR: ' + message)
|
||||
sys.exit(1)
|
||||
elif want_python:
|
||||
print('WARNING: ' + message)
|
||||
env['python_package'] = 'minimal'
|
||||
else:
|
||||
print('INFO: Using Cython version {0}.'.format(cython_version))
|
||||
|
||||
|
||||
if env['python_package'] in ('full', 'minimal', 'default'):
|
||||
# Check the version of the Python package we want to build
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue