Skip to content

Commit

Permalink
qtpy: use our internal parse() as a fallback when packaging.version.p…
Browse files Browse the repository at this point in the history
…arse() is not installed

Continue relying on packaging.version.parse() when it is installed.
Our internal parsing code is now used as a fallback instead.

Suggested-by: @dalthviz in #508
  • Loading branch information
davvid committed Dec 18, 2024
1 parent 09caecd commit 1fe2e9f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion qtpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,12 @@ def _parse_int(value):

def _parse_version(version):
"""Parse a version string into a tuple of ints"""
return tuple(_parse_int(x) for x in version.split("."))
try:
from packaging.version import parse as _packaging_version_parse
except ImportError:
return tuple(_parse_int(x) for x in version.split("."))
else:
return _packaging_version_parse(version)


# Unless `FORCE_QT_API` is set, use previously imported Qt Python bindings
Expand Down

0 comments on commit 1fe2e9f

Please sign in to comment.