Update dist_utils.py so only check_pip_version() function relies on pip
presence.
Other function don't rely on pip anymore.
@@ -31,16 +31,8 @@ else:
GET_PIP = 'curl https://bootstrap.pypa.io/get-pip.py | python'
-try:
- import pip
-except ImportError as e:
- print('Failed to import pip: %s' % (text_type(e)))
- print('')
- print('Download pip:\n%s' % (GET_PIP))
- sys.exit(1)
-
-
__all__ = [
+ 'check_pip_is_installed',
'check_pip_version',
'fetch_requirements',
'apply_vagrant_workaround',
@@ -49,10 +41,27 @@ __all__ = [
]
+def check_pip_is_installed():
+ """
+ Ensure that pip is installed.
+ """
+ try:
+ import pip # NOQA
+ except ImportError as e:
+ print('Failed to import pip: %s' % (text_type(e)))
+ print('')
+ print('Download pip:\n%s' % (GET_PIP))
+ sys.exit(1)
+
+
def check_pip_version(min_version='6.0.0'):
"""
Ensure that a minimum supported version of pip is installed.
"""
+ check_pip_is_installed()
+
+ import pip
+
if StrictVersion(pip.__version__) < StrictVersion(min_version):
print("Upgrade pip, your version '{0}' "
"is outdated. Minimum required version is '{1}':\n{2}".format(pip.__version__,
