Skip to content

Commit 1de683e

Browse files
committed
qtpy: use our internal parse() as a fallback when packaging.version.parse() 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 spyder-ide#508
1 parent cbd2c29 commit 1de683e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

qtpy/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,12 @@ def _parse_int(value):
194194

195195
def _parse_version(version):
196196
"""Parse a version string into a tuple of ints"""
197-
return tuple(_parse_int(x) for x in version.split("."))
197+
try:
198+
from packaging.version import parse as _packaging_version_parse
199+
except ImportError:
200+
return tuple(_parse_int(x) for x in version.split("."))
201+
else:
202+
return _packaging_version_parse(version)
198203

199204

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

0 commit comments

Comments
 (0)