summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Brett <matthew.brett@gmail.com>2021-10-23 12:05:31 +0100
committerMatthew Brett <matthew.brett@gmail.com>2021-10-23 12:05:31 +0100
commit9db73b58df62f54521bbbb8addafc7b0d5e61d1f (patch)
treee0a33c2dc9e018a64c97badb8e9b4f05bd766332
parent6409a721c17aae94cfd55ccbcf26a95494dd1cf8 (diff)
downloadnumpy-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-xsetup.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/setup.py b/setup.py
index 6fdd3b77e..6cb37d291 100755
--- a/setup.py
+++ b/setup.py
@@ -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