Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import StrictVersion and LooseVersion from setuptools.distutils.verison or setuptools._distutils.version #63352

Merged
merged 4 commits into from
Dec 22, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/63350.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Import StrictVersion and LooseVersion from setuptools.distutils.verison or setuptools._distutils.version, if first not available
11 changes: 8 additions & 3 deletions salt/utils/pkg/win.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,14 @@
try:
from salt.utils.versions import LooseVersion
except ImportError:
from setuptools._distutils.version import (
LooseVersion, # pylint: disable=blacklisted-module
)
try:
from setuptools.distutils.version import (
LooseVersion, # pylint: disable=blacklisted-module
)
except ImportError:
from setuptools._distutils.version import (
LooseVersion, # pylint: disable=blacklisted-module
)
dmurphy18 marked this conversation as resolved.
Show resolved Hide resolved

# pylint: disable=too-many-instance-attributes

Expand Down
21 changes: 16 additions & 5 deletions salt/utils/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,29 @@
import sys
import warnings

from setuptools._distutils.version import LooseVersion as _LooseVersion
from setuptools._distutils.version import StrictVersion as _StrictVersion
log = logging.getLogger(__name__)

try:
from setuptools.distutils.version import LooseVersion as _LooseVersion
from setuptools.distutils.version import StrictVersion as _StrictVersion
except ImportError:
log.debug(
"unable to import from setuptools.distutils.version, will attempt setuptools._distutils.version"
)
try:
from setuptools._distutils.version import LooseVersion as _LooseVersion
from setuptools._distutils.version import StrictVersion as _StrictVersion
except:
log.debug("unable to import from setuptools._distutils.version")
raise ImportError()


# pylint: enable=blacklisted-module
import salt.version

# pylint: disable=blacklisted-module
dmurphy18 marked this conversation as resolved.
Show resolved Hide resolved


log = logging.getLogger(__name__)


class StrictVersion(_StrictVersion):
def parse(self, vstring):
_StrictVersion.parse(self, vstring)
Expand Down