mirror of
https://github.com/pypa/pip
synced 2023-12-13 21:30:23 +01:00
Add a warning that'll tell people when their Python doesn't support TLS
This commit is contained in:
parent
0f0a4f0f5e
commit
22e059556d
|
@ -14,6 +14,12 @@ import shutil
|
|||
import sys
|
||||
import tempfile
|
||||
|
||||
try:
|
||||
import ssl # noqa
|
||||
HAS_TLS = True
|
||||
except ImportError:
|
||||
HAS_TLS = False
|
||||
|
||||
from pip._vendor.six.moves.urllib import parse as urllib_parse
|
||||
from pip._vendor.six.moves.urllib import request as urllib_request
|
||||
|
||||
|
|
15
pip/index.py
15
pip/index.py
|
@ -25,7 +25,7 @@ from pip.exceptions import (
|
|||
DistributionNotFound, BestVersionAlreadyInstalled, InvalidWheelFilename,
|
||||
UnsupportedWheel,
|
||||
)
|
||||
from pip.download import url_to_path, path_to_url
|
||||
from pip.download import HAS_TLS, url_to_path, path_to_url
|
||||
from pip.models import PyPI
|
||||
from pip.wheel import Wheel, wheel_ext
|
||||
from pip.pep425tags import supported_tags, supported_tags_noarch, get_platform
|
||||
|
@ -175,6 +175,19 @@ class PackageFinder(object):
|
|||
# The Session we'll use to make requests
|
||||
self.session = session
|
||||
|
||||
# If we don't have TLS enabled, then WARN if anyplace we're looking
|
||||
# relies on TLS.
|
||||
if not HAS_TLS:
|
||||
for link in itertools.chain(self.index_urls, self.find_links):
|
||||
parsed = urllib_parse.urlparse(link)
|
||||
if parsed.scheme == "https":
|
||||
logger.warning(
|
||||
"pip is configured with locations that require "
|
||||
"TLS/SSL, however the ssl module in Python is not "
|
||||
"available."
|
||||
)
|
||||
break
|
||||
|
||||
def add_dependency_links(self, links):
|
||||
# # FIXME: this shouldn't be global list this, it should only
|
||||
# # apply to requirements of the package that specifies the
|
||||
|
|
Loading…
Reference in a new issue