mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Make pip InstallationError import more robust
The way the version check was implemented fails on ancient pip versions that do not provide pip.__version__ yet. We will therefore simply try to import InstallationError and fall back to ValueError if it has not been defined in the installed pip version.
This commit is contained in:
parent
291a3e21fa
commit
57e0475cd4
1 changed files with 2 additions and 4 deletions
|
@ -49,11 +49,9 @@ if HAS_PIP is True:
|
|||
if 'pip' in sys.modules:
|
||||
del sys.modules['pip']
|
||||
|
||||
ver = pip.__version__.split('.')
|
||||
pip_ver = tuple([int(x) for x in ver if x.isdigit()])
|
||||
if pip_ver >= (8, 0, 0):
|
||||
try:
|
||||
from pip.exceptions import InstallationError
|
||||
else:
|
||||
except ImportError:
|
||||
InstallationError = ValueError
|
||||
|
||||
# pylint: enable=import-error
|
||||
|
|
Loading…
Add table
Reference in a new issue