diff --git a/setup.py b/setup.py index fbe428dd..3539fdfe 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ import setuptools setuptools.dist.Distribution().fetch_build_eggs(['packaging']) -import packaging.version +from packaging.version import InvalidVersion, parse # base source directory @@ -19,7 +19,9 @@ if not match: raise RuntimeError(f'Unable to find __version__ in {init_file}.') version = match.group(1) -if isinstance(packaging.version.parse(version), packaging.version.LegacyVersion): +try: + version_obj = parse(version) +except InvalidVersion: raise RuntimeError(f'Invalid version string {version}.') # run setup