]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Make "certifi" optional on py34.
authorBen Darnell <ben@bendarnell.com>
Wed, 18 Feb 2015 03:33:36 +0000 (22:33 -0500)
committerBen Darnell <ben@bendarnell.com>
Wed, 18 Feb 2015 03:33:36 +0000 (22:33 -0500)
setup.py
tornado/netutil.py
tornado/simple_httpclient.py
tornado/test/iostream_test.py
tornado/test/simple_httpclient_test.py

index dcbb1bc82c17c86a5731f3a8d16d0296f634cc05..4434abcaa7484f7d22b20f2e3b57cda12949c1c2 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -35,6 +35,7 @@ from distutils.core import Extension
 # no compiler is available.
 from distutils.command.build_ext import build_ext
 
+
 class custom_build_ext(build_ext):
     """Allow C extension building to fail.
 
@@ -104,7 +105,7 @@ with open('README.rst') as f:
     kwargs['long_description'] = f.read()
 
 if (platform.python_implementation() == 'CPython' and
-    os.environ.get('TORNADO_EXTENSION') != '0'):
+        os.environ.get('TORNADO_EXTENSION') != '0'):
     # This extension builds and works on pypy as well, although pypy's jit
     # produces equivalent performance.
     kwargs['ext_modules'] = [
@@ -120,16 +121,21 @@ if (platform.python_implementation() == 'CPython' and
 
 if setuptools is not None:
     # If setuptools is not available, you're on your own for dependencies.
-    install_requires = ['certifi']
+    install_requires = []
     if sys.version_info < (3, 2):
         install_requires.append('backports.ssl_match_hostname')
+    if sys.version_info < (3, 4):
+        # Certifi is also optional on 2.7.9+, although making our dependencies
+        # conditional on micro version numbers seems like a bad idea
+        # until we have more declarative metadata.
+        install_requires.append('certifi')
     kwargs['install_requires'] = install_requires
 
 setup(
     name="tornado",
     version=version,
-    packages = ["tornado", "tornado.test", "tornado.platform"],
-    package_data = {
+    packages=["tornado", "tornado.test", "tornado.platform"],
+    package_data={
         # data files need to be listed both here (which determines what gets
         # installed) and in MANIFEST.in (which determines what gets included
         # in the sdist tarball)
index 48355f9473b247c89464a293ddb1a77e781a2941..3464255f0fe8f9a7d12ec0cf42ccabe244430420 100644 (file)
@@ -18,7 +18,6 @@
 
 from __future__ import absolute_import, division, print_function, with_statement
 
-import certifi
 import errno
 import os
 import sys
@@ -36,6 +35,14 @@ except ImportError:
     # ssl is not available on Google App Engine
     ssl = None
 
+try:
+    import certifi
+except ImportError:
+    # certifi is optional as long as we have ssl.create_default_context.
+    if not hasattr(ssl, 'create_default_context'):
+        raise
+    certifi = None
+
 try:
     xrange  # py2
 except NameError:
index bb080af97f8eed55ffb1ec257a51af155e50f6b6..ffa03ea686659a76e6cc6117f8f689933962ef94 100644 (file)
@@ -234,7 +234,10 @@ class _HTTPConnection(httputil.HTTPMessageDelegate):
                 ssl_options["cert_reqs"] = ssl.CERT_REQUIRED
             if self.request.ca_certs is not None:
                 ssl_options["ca_certs"] = self.request.ca_certs
-            else:
+            elif not hasattr(ssl, 'create_default_context'):
+                # When create_default_context is present,
+                # we can omit the "ca_certs" parameter entirely,
+                # which avoids the dependency on "certifi" for py34.
                 ssl_options["ca_certs"] = _default_ca_certs()
             if self.request.client_key is not None:
                 ssl_options["keyfile"] = self.request.client_key
index 227e9ad5baa317baf847d87e13a8130976e01ea2..c1662885f63562cb56ec5b313045fdc890d642e6 100644 (file)
@@ -10,7 +10,6 @@ from tornado.stack_context import NullContext
 from tornado.testing import AsyncHTTPTestCase, AsyncHTTPSTestCase, AsyncTestCase, bind_unused_port, ExpectLog, gen_test
 from tornado.test.util import unittest, skipIfNonUnix, refusing_port
 from tornado.web import RequestHandler, Application
-import certifi
 import errno
 import logging
 import os
index be3c2d940614b71ef48ea00727c864e497cf171a..2d72992e004a5c1263a135e9dffc09733f19d03a 100644 (file)
@@ -192,9 +192,6 @@ class SimpleHTTPClientTestMixin(object):
             response = self.wait()
             response.rethrow()
 
-    def test_default_certificates_exist(self):
-        open(_default_ca_certs()).close()
-
     def test_gzip(self):
         # All the tests in this file should be using gzip, but this test
         # ensures that it is in fact getting compressed.