mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #50280 from gtmanfred/2017.7
fix InstallRequirement.from_line for pip 18.1
This commit is contained in:
commit
37ae06cefb
1 changed files with 9 additions and 4 deletions
|
@ -42,10 +42,15 @@ except ImportError:
|
|||
if HAS_PIP is True:
|
||||
try:
|
||||
from pip.req import InstallRequirement
|
||||
_from_line = InstallRequirement.from_line
|
||||
except ImportError:
|
||||
# pip 10.0.0 move req module under pip._internal
|
||||
try:
|
||||
from pip._internal.req import InstallRequirement
|
||||
try:
|
||||
from pip._internal.req import InstallRequirement
|
||||
_from_line = InstallRequirement.from_line
|
||||
except AttributeError:
|
||||
from pip._internal.req.constructors import install_req_from_line as _from_line
|
||||
except ImportError:
|
||||
HAS_PIP = False
|
||||
# Remove references to the loaded pip module above so reloading works
|
||||
|
@ -133,7 +138,7 @@ def _check_pkg_version_format(pkg):
|
|||
logger.debug(
|
||||
'Installed pip version: {0}'.format(pip.__version__)
|
||||
)
|
||||
install_req = InstallRequirement.from_line(pkg)
|
||||
install_req = _from_line(pkg)
|
||||
except AttributeError:
|
||||
logger.debug('Installed pip version is lower than 1.2')
|
||||
supported_vcs = ('git', 'svn', 'hg', 'bzr')
|
||||
|
@ -141,12 +146,12 @@ def _check_pkg_version_format(pkg):
|
|||
for vcs in supported_vcs:
|
||||
if pkg.startswith(vcs):
|
||||
from_vcs = True
|
||||
install_req = InstallRequirement.from_line(
|
||||
install_req = _from_line(
|
||||
pkg.split('{0}+'.format(vcs))[-1]
|
||||
)
|
||||
break
|
||||
else:
|
||||
install_req = InstallRequirement.from_line(pkg)
|
||||
install_req = _from_line(pkg)
|
||||
except (ValueError, InstallationError) as exc:
|
||||
ret['result'] = False
|
||||
if not from_vcs and '=' in pkg and '==' not in pkg:
|
||||
|
|
Loading…
Add table
Reference in a new issue