Index: urllib3-1.5/urllib3/_collections.py =================================================================== --- urllib3-1.5.orig/urllib3/_collections.py +++ urllib3-1.5/urllib3/_collections.py @@ -10,7 +10,10 @@ from threading import Lock try: # Python 2.7+ from collections import OrderedDict except ImportError: - from .packages.ordered_dict import OrderedDict + try: # backport package + from ordereddict import OrderedDict + except ImportError: + from .packages.ordered_dict import OrderedDict __all__ = ['RecentlyUsedContainer'] Index: urllib3-1.5/urllib3/connectionpool.py =================================================================== --- urllib3-1.5.orig/urllib3/connectionpool.py +++ urllib3-1.5/urllib3/connectionpool.py @@ -51,8 +51,20 @@ from .exceptions import ( TimeoutError, ) -from .packages.ssl_match_hostname import match_hostname, CertificateError -from .packages import six +try: + # python3.2+ + from ssl import match_hostname, CertificateError +except ImportError: + try: + # Older python where the backport from pypi is installed + from backports.ssl_match_hostname import match_hostname, CertificateError + except ImportError: + # Other older python we use our bundled copy + from .packages.ssl_match_hostname import match_hostname, CertificateError +try: + import six +except ImportError: + from .packages import six xrange = six.moves.xrange Index: urllib3-1.5/urllib3/filepost.py =================================================================== --- urllib3-1.5.orig/urllib3/filepost.py +++ urllib3-1.5/urllib3/filepost.py @@ -10,8 +10,12 @@ import mimetypes from uuid import uuid4 from io import BytesIO -from .packages import six -from .packages.six import b +try: + import six + from six import b +except ImportError: + from .packages import six + from .packages.six import b writer = codecs.lookup('utf-8')[3] Index: urllib3-1.5/urllib3/response.py =================================================================== --- urllib3-1.5.orig/urllib3/response.py +++ urllib3-1.5/urllib3/response.py @@ -11,7 +11,10 @@ import zlib from io import BytesIO from .exceptions import DecodeError -from .packages.six import string_types as basestring +try: + from six import string_types as basestring +except ImportError: + from .packages.six import string_types as basestring log = logging.getLogger(__name__) Index: urllib3-1.5/urllib3/util.py =================================================================== --- urllib3-1.5.orig/urllib3/util.py +++ urllib3-1.5/urllib3/util.py @@ -18,7 +18,10 @@ except ImportError: # `poll` doesn't exi except ImportError: # `select` doesn't exist on AppEngine. select = False -from .packages import six +try: + import six +except ImporError: + from .packages import six from .exceptions import LocationParseError Index: urllib3-1.5/test/test_collections.py =================================================================== --- urllib3-1.5.orig/test/test_collections.py +++ urllib3-1.5/test/test_collections.py @@ -1,7 +1,10 @@ import unittest from urllib3._collections import RecentlyUsedContainer as Container -from urllib3.packages import six +try: + import six +except ImportError: + from urllib3.packages import six xrange = six.moves.xrange Index: urllib3-1.5/test/test_connectionpool.py =================================================================== --- urllib3-1.5.orig/test/test_connectionpool.py +++ urllib3-1.5/test/test_connectionpool.py @@ -1,7 +1,16 @@ import unittest from urllib3.connectionpool import connection_from_url, HTTPConnectionPool -from urllib3.packages.ssl_match_hostname import CertificateError +try: + # python3.2+ + from ssl import CertificateError +except ImportError: + try: + # Older python where the backport from pypi is installed + from backports.ssl_match_hostname import CertificateError + except ImportError: + # Other older python we use our bundled copy + from urllib3.packages.ssl_match_hostname import CertificateError from urllib3.exceptions import ( ClosedPoolError, EmptyPoolError, Index: urllib3-1.5/test/test_filepost.py =================================================================== --- urllib3-1.5.orig/test/test_filepost.py +++ urllib3-1.5/test/test_filepost.py @@ -1,7 +1,10 @@ import unittest from urllib3.filepost import encode_multipart_formdata, iter_fields -from urllib3.packages.six import b, u +try: + from six import b, u +except ImportError: + from urllib3.packages.six import b, u BOUNDARY = '!! test boundary !!' Index: urllib3-1.5/setup.py =================================================================== --- urllib3-1.5.orig/setup.py +++ urllib3-1.5/setup.py @@ -44,8 +44,7 @@ setup(name='urllib3', author_email='andrey.petrov@shazow.net', url='http://urllib3.readthedocs.org/', license='MIT', - packages=['urllib3', 'dummyserver', 'urllib3.packages', - 'urllib3.packages.ssl_match_hostname', + packages=['urllib3', 'dummyserver', 'urllib3', ], requires=requirements, tests_require=tests_requirements,