fix pkg_resources for usage with testing pip

We do weird things with the pip modules for salt-jenkins, we need to directly
import the module instead of a function from the module for the namespacing we
do there to work.
This commit is contained in:
Daniel Wallace 2018-01-19 16:44:08 -07:00
parent 0ba39a7108
commit 2ddbcb45c1
No known key found for this signature in database
GPG key ID: 5FA5E5544F010D48
2 changed files with 6 additions and 6 deletions

View file

@ -82,7 +82,7 @@ import re
import shutil
import logging
import sys
from pkg_resources import parse_version
import pkg_resources
# Import salt libs
import salt.utils
@ -1287,7 +1287,7 @@ def list_all_versions(pkg,
match = re.search(r'\s*Could not find a version.* \(from versions: (.*)\)', line)
if match:
versions = [v for v in match.group(1).split(', ') if v and excludes.match(v)]
versions.sort(key=parse_version)
versions.sort(key=pkg_resources.parse_version)
break
if not versions:
return None

View file

@ -23,7 +23,7 @@ requisite to a pkg.installed state for the package which provides pip
from __future__ import absolute_import
import re
import logging
from pkg_resources import parse_version
import pkg_resources
# Import salt libs
import salt.utils
@ -266,11 +266,11 @@ def _pep440_version_cmp(pkg1, pkg2, ignore_epoch=False):
pkg2 = normalize(pkg2)
try:
if parse_version(pkg1) < parse_version(pkg2):
if pkg_resources.parse_version(pkg1) < pkg_resources.parse_version(pkg2):
return -1
if parse_version(pkg1) == parse_version(pkg2):
if pkg_resources.parse_version(pkg1) == pkg_resources.parse_version(pkg2):
return 0
if parse_version(pkg1) > parse_version(pkg2):
if pkg_resources.parse_version(pkg1) > pkg_resources.parse_version(pkg2):
return 1
except Exception as exc:
logger.exception(exc)