Skip to content

Commit

Permalink
Fix parsing of package versions in packaging 22. (#181)
Browse files Browse the repository at this point in the history
Co-Authored-By: Simon Cross <165551+hodgestar@users.noreply.github.com>
  • Loading branch information
BoxiLi and hodgestar committed Dec 9, 2022
1 parent 17d37af commit da5290d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ 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):
# 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
Expand Down

0 comments on commit da5290d

Please sign in to comment.