Merge pull request #3554 from jdemeyer/allow_no_ssl

Allow running Sphinx without ssl
This commit is contained in:
Takeshi KOMIYA 2017-03-16 10:44:59 +09:00 committed by GitHub
commit 7a3f35e014

View File

@ -36,12 +36,16 @@ except ImportError:
# for requests < 2.4.0 # for requests < 2.4.0
InsecureRequestWarning = None InsecureRequestWarning = None
# try to load requests[security] # try to load requests[security] (but only if SSL is available)
try: try:
pkg_resources.require(['requests[security]'])
except (pkg_resources.DistributionNotFound,
pkg_resources.VersionConflict):
import ssl import ssl
except ImportError:
pass
else:
try:
pkg_resources.require(['requests[security]'])
except (pkg_resources.DistributionNotFound,
pkg_resources.VersionConflict):
if not getattr(ssl, 'HAS_SNI', False): if not getattr(ssl, 'HAS_SNI', False):
# don't complain on each url processed about the SSL issue # don't complain on each url processed about the SSL issue
requests.packages.urllib3.disable_warnings( requests.packages.urllib3.disable_warnings(
@ -53,7 +57,7 @@ except (pkg_resources.DistributionNotFound,
'install "requests[security]" as a dependency or upgrade to ' 'install "requests[security]" as a dependency or upgrade to '
'a python version with SNI support (Python 3 and Python 2.7.9+).' 'a python version with SNI support (Python 3 and Python 2.7.9+).'
) )
except pkg_resources.UnknownExtra: except pkg_resources.UnknownExtra:
warnings.warn( warnings.warn(
'Some links may return broken results due to being unable to ' 'Some links may return broken results due to being unable to '
'check the Server Name Indication (SNI) in the returned SSL cert ' 'check the Server Name Indication (SNI) in the returned SSL cert '