From 5a53092c9e08798aaadc03338ba588f2b79efbcd Mon Sep 17 00:00:00 2001 From: Simon Cross Date: Sat, 10 Dec 2022 14:05:45 +0100 Subject: [PATCH] Simplify version parsing. Calling Version directly has given the strict parsing we require since the Version class was created and the class predates the parse(...) function itself. This simpler code should give the correct behaviour on all versions of packaging since 2014. --- setup.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/setup.py b/setup.py index 9b15d4ea9b..a81f0f9fbc 100755 --- a/setup.py +++ b/setup.py @@ -132,12 +132,7 @@ def _determine_version(options): version_filename = os.path.join(options['rootdir'], 'VERSION') with open(version_filename, "r") as version_file: version_string = version_file.read().strip() - version = packaging.version.parse(version_string) - # LegacyVersion was removed in packaging 22, but is still returned by - # packing <= 21 - LegacyVersion = getattr(packaging.version, "LegacyVersion", type(None)) - if isinstance(version, LegacyVersion): - raise ValueError("invalid version: " + version_string) + version = packaging.version.Version(version_string) options['short_version'] = str(version.public) options['release'] = not version.is_devrelease if not options['release']: