Merge pull request #48 from grahampugh/dev-packaging

Allow for removal of distutils in a future python
This commit is contained in:
Graham Pugh 2022-03-08 15:13:10 +01:00 committed by GitHub
commit 69ee37ae4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -42,14 +42,18 @@ except ImportError:
from urlparse import urlsplit
from xml.dom import minidom
from xml.parsers.expat import ExpatError
from distutils.version import LooseVersion
try:
from packaging.version import Version
except ImportError:
from distutils.version import LooseVersion as Version
try:
import xattr
except ImportError:
print(
"This tool requires the Python xattr module. "
"Perhaps run `pip install xattr` to install it."
"This tool requires the Python xattr and packaging modules. "
"Perhaps run `pip install xattr packaging` to install them."
)
sys.exit(-1)
@ -698,7 +702,7 @@ def os_installer_product_info(
def get_latest_version(current_item, latest_item):
"""Compares versions between two values and returns the latest (highest) value"""
try:
if LooseVersion(current_item) > LooseVersion(latest_item):
if Version(current_item) > Version(latest_item):
return current_item
else:
return latest_item