diff options
author | Matthew Brett <matthew.brett@gmail.com> | 2021-10-23 12:05:31 +0100 |
---|---|---|
committer | Matthew Brett <matthew.brett@gmail.com> | 2021-10-23 12:05:31 +0100 |
commit | 9db73b58df62f54521bbbb8addafc7b0d5e61d1f (patch) | |
tree | e0a33c2dc9e018a64c97badb8e9b4f05bd766332 | |
parent | 6409a721c17aae94cfd55ccbcf26a95494dd1cf8 (diff) | |
download | numpy-9db73b58df62f54521bbbb8addafc7b0d5e61d1f.tar.gz |
More informative error for unparsable version
When Git is not installed, it is possible to get useless version strings
from versioneer, such as `0+unknown`. Give a more informative error in
that case.
-rwxr-xr-x | setup.py | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -55,7 +55,10 @@ FULLVERSION = versioneer.get_version() # 1.22.0 ... -> ISRELEASED == True, VERSION == 1.22.0 # 1.22.0rc1 ... -> ISRELEASED == True, VERSION == 1.22.0 ISRELEASED = re.search(r'(dev|\+)', FULLVERSION) is None -MAJOR, MINOR, MICRO = re.match(r'(\d+)\.(\d+)\.(\d+)', FULLVERSION).groups() +_V_MATCH = re.match(r'(\d+)\.(\d+)\.(\d+)', FULLVERSION) +if _V_MATCH is None: + raise RuntimeError(f'Cannot parse version {FULLVERSION}') +MAJOR, MINOR, MICRO = _V_MATCH.groups() VERSION = '{}.{}.{}'.format(MAJOR, MINOR, MICRO) # The first version not in the `Programming Language :: Python :: ...` classifiers above |