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:
Wolodja Wentland 2016-05-20 12:30:57 +02:00
parent 291a3e21fa
commit 57e0475cd4

View file

@ -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