mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Don't fail if pkg_resources is not importable
This commit is contained in:
parent
a1eb400041
commit
493f493bbe
1 changed files with 5 additions and 3 deletions
|
@ -37,7 +37,7 @@ from salt.version import SaltStackVersion as _SaltStackVersion
|
|||
from salt.exceptions import CommandExecutionError, CommandNotFoundError
|
||||
|
||||
# Import 3rd-party libs
|
||||
from salt.ext import six
|
||||
import salt.ext.six as six
|
||||
# pylint: disable=import-error
|
||||
try:
|
||||
import pip
|
||||
|
@ -290,8 +290,10 @@ def _pep440_version_cmp(pkg1, pkg2, ignore_epoch=False):
|
|||
and 1 if version1 > version2. Return None if there was a problem
|
||||
making the comparison.
|
||||
'''
|
||||
normalize = lambda x: six.text_type(x).split('!', 1)[-1] \
|
||||
if ignore_epoch else six.text_type(x)
|
||||
if HAS_PKG_RESOURCES is False:
|
||||
log.warning('The pkg_resources packages was not loaded. Please install setuptools.')
|
||||
return None
|
||||
normalize = lambda x: six.text_type(x).split('!', 1)[-1] if ignore_epoch else six.text_type(x)
|
||||
pkg1 = normalize(pkg1)
|
||||
pkg2 = normalize(pkg2)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue