diff --git a/changelog/63350.fixed b/changelog/63350.fixed new file mode 100644 index 000000000000..a544d15d1e43 --- /dev/null +++ b/changelog/63350.fixed @@ -0,0 +1 @@ +Import StrictVersion and LooseVersion from setuptools.distutils.verison or setuptools._distutils.version, if first not available diff --git a/salt/utils/pkg/win.py b/salt/utils/pkg/win.py index 9e8c4894ced6..c09c187cb1be 100644 --- a/salt/utils/pkg/win.py +++ b/salt/utils/pkg/win.py @@ -72,12 +72,7 @@ except ImportError: from collections import OrderedDict -try: - from salt.utils.versions import LooseVersion -except ImportError: - from setuptools._distutils.version import ( - LooseVersion, # pylint: disable=blacklisted-module - ) +from salt.utils.versions import LooseVersion # pylint: disable=too-many-instance-attributes diff --git a/salt/utils/versions.py b/salt/utils/versions.py index 8cbff8eaeb20..d4d24212ebae 100644 --- a/salt/utils/versions.py +++ b/salt/utils/versions.py @@ -18,15 +18,23 @@ import sys import warnings -from setuptools._distutils.version import LooseVersion as _LooseVersion -from setuptools._distutils.version import StrictVersion as _StrictVersion +# pylint: disable=blacklisted-module +try: + from setuptools.distutils.version import LooseVersion as _LooseVersion + from setuptools.distutils.version import StrictVersion as _StrictVersion +except ImportError: + try: + from setuptools._distutils.version import LooseVersion as _LooseVersion + from setuptools._distutils.version import StrictVersion as _StrictVersion + except ImportError: + from distutils.version import LooseVersion as _LooseVersion + from distutils.version import StrictVersion as _StrictVersion + # pylint: enable=blacklisted-module import salt.version # pylint: disable=blacklisted-module - - log = logging.getLogger(__name__)