Skip to content

Commit

Permalink
Merge pull request #2039 from hodgestar/fix/v5-fix-legacy-version-check
Browse files Browse the repository at this point in the history
Fix parsing of version number when using packaging 22.
  • Loading branch information
hodgestar committed Dec 9, 2022
2 parents 0f8f610 + a9c328c commit 169b000
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,11 @@ def _determine_version(options):
with open(version_filename, "r") as version_file:
version_string = version_file.read().strip()
version = packaging.version.parse(version_string)
if isinstance(version, packaging.version.LegacyVersion):
raise ValueError("invalid version: " + 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)
options['short_version'] = str(version.public)
options['release'] = not version.is_devrelease
if not options['release']:
Expand Down

0 comments on commit 169b000

Please sign in to comment.