Skip to content

Commit 9db73b5

Browse files
committed
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.
1 parent 6409a72 commit 9db73b5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

setup.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@
5555
# 1.22.0 ... -> ISRELEASED == True, VERSION == 1.22.0
5656
# 1.22.0rc1 ... -> ISRELEASED == True, VERSION == 1.22.0
5757
ISRELEASED = re.search(r'(dev|\+)', FULLVERSION) is None
58-
MAJOR, MINOR, MICRO = re.match(r'(\d+)\.(\d+)\.(\d+)', FULLVERSION).groups()
58+
_V_MATCH = re.match(r'(\d+)\.(\d+)\.(\d+)', FULLVERSION)
59+
if _V_MATCH is None:
60+
raise RuntimeError(f'Cannot parse version {FULLVERSION}')
61+
MAJOR, MINOR, MICRO = _V_MATCH.groups()
5962
VERSION = '{}.{}.{}'.format(MAJOR, MINOR, MICRO)
6063

6164
# The first version not in the `Programming Language :: Python :: ...` classifiers above

0 commit comments

Comments
 (0)