mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
fix pip.req import error in pip 10.0.0
This commit is contained in:
parent
c1dc42e67e
commit
bd0c23396c
@ -41,14 +41,18 @@ except ImportError:
|
||||
|
||||
if HAS_PIP is True:
|
||||
try:
|
||||
import pip.req
|
||||
from pip.req import InstallRequirement
|
||||
except ImportError:
|
||||
HAS_PIP = False
|
||||
# Remove references to the loaded pip module above so reloading works
|
||||
import sys
|
||||
del pip
|
||||
if 'pip' in sys.modules:
|
||||
del sys.modules['pip']
|
||||
# pip 10.0.0 move req module under pip._internal
|
||||
try:
|
||||
from pip._internal.req import InstallRequirement
|
||||
except:
|
||||
HAS_PIP = False
|
||||
# Remove references to the loaded pip module above so reloading works
|
||||
import sys
|
||||
del pip
|
||||
if 'pip' in sys.modules:
|
||||
del sys.modules['pip']
|
||||
|
||||
try:
|
||||
from pip.exceptions import InstallationError
|
||||
@ -129,7 +133,7 @@ def _check_pkg_version_format(pkg):
|
||||
logger.debug(
|
||||
'Installed pip version: {0}'.format(pip.__version__)
|
||||
)
|
||||
install_req = pip.req.InstallRequirement.from_line(pkg)
|
||||
install_req = InstallRequirement.from_line(pkg)
|
||||
except AttributeError:
|
||||
logger.debug('Installed pip version is lower than 1.2')
|
||||
supported_vcs = ('git', 'svn', 'hg', 'bzr')
|
||||
@ -137,12 +141,12 @@ def _check_pkg_version_format(pkg):
|
||||
for vcs in supported_vcs:
|
||||
if pkg.startswith(vcs):
|
||||
from_vcs = True
|
||||
install_req = pip.req.InstallRequirement.from_line(
|
||||
install_req = InstallRequirement.from_line(
|
||||
pkg.split('{0}+'.format(vcs))[-1]
|
||||
)
|
||||
break
|
||||
else:
|
||||
install_req = pip.req.InstallRequirement.from_line(pkg)
|
||||
install_req = InstallRequirement.from_line(pkg)
|
||||
except (ValueError, InstallationError) as exc:
|
||||
ret['result'] = False
|
||||
if not from_vcs and '=' in pkg and '==' not in pkg:
|
||||
|
Loading…
Reference in New Issue
Block a user