summaryrefslogtreecommitdiffstats
path: root/Lib/ensurepip
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2013-12-23 13:07:07 (GMT)
committerNick Coghlan <ncoghlan@gmail.com>2013-12-23 13:07:07 (GMT)
commitae2ee96ad797435963e9aa13d54d52db765486c9 (patch)
tree19001152d5edc3130008f609b2ca9cadf80d2f41 /Lib/ensurepip
parentf71cae0a93ea0f8ba83da06bdd71709443d521b6 (diff)
downloadcpython-ae2ee96ad797435963e9aa13d54d52db765486c9.zip
cpython-ae2ee96ad797435963e9aa13d54d52db765486c9.tar.gz
cpython-ae2ee96ad797435963e9aa13d54d52db765486c9.tar.bz2
Issue #19744: improve ensurepip error when ssl is missing
Diffstat (limited to 'Lib/ensurepip')
-rw-r--r--Lib/ensurepip/__init__.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/ensurepip/__init__.py b/Lib/ensurepip/__init__.py
index 0f43bc4..74cd207 100644
--- a/Lib/ensurepip/__init__.py
+++ b/Lib/ensurepip/__init__.py
@@ -14,6 +14,19 @@ _SETUPTOOLS_VERSION = "2.0.1"
_PIP_VERSION = "1.5rc2"
+# pip currently requires ssl support, so we try to provide a nicer
+# error message when that is missing (http://bugs.python.org/issue19744)
+_MISSING_SSL_MESSAGE = ("pip {} requires SSL/TLS".format(_PIP_VERSION))
+try:
+ import ssl
+except ImportError:
+ ssl = None
+ def _require_ssl_for_pip():
+ raise RuntimeError(_MISSING_SSL_MESSAGE)
+else:
+ def _require_ssl_for_pip():
+ pass
+
_PROJECTS = [
("setuptools", _SETUPTOOLS_VERSION),
("pip", _PIP_VERSION),
@@ -57,6 +70,7 @@ def bootstrap(*, root=None, upgrade=False, user=False,
if altinstall and default_pip:
raise ValueError("Cannot use altinstall and default_pip together")
+ _require_ssl_for_pip()
_clear_pip_environment_variables()
# By default, installing pip and setuptools installs all of the
@@ -121,6 +135,7 @@ def _uninstall_helper(*, verbosity=0):
"({!r} installed, {!r} bundled)")
raise RuntimeError(msg.format(pip.__version__, _PIP_VERSION))
+ _require_ssl_for_pip()
_clear_pip_environment_variables()
# Construct the arguments to be passed to the pip command