diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2017-01-16 15:04:47 -0500 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2017-01-16 15:04:47 -0500 |
commit | c80f03bed382c523778c196f93616a04d3d8aa0c (patch) | |
tree | 91979531ac09a830ec35be92125b285503ba4d80 /setuptools | |
parent | e6087bfa308ee6b45c2c1906af1a7f4a177cb57b (diff) | |
parent | 730834b5c286b5ba2091394339d0759035804eba (diff) | |
download | external_python_setuptools-c80f03bed382c523778c196f93616a04d3d8aa0c.tar.gz external_python_setuptools-c80f03bed382c523778c196f93616a04d3d8aa0c.tar.bz2 external_python_setuptools-c80f03bed382c523778c196f93616a04d3d8aa0c.zip |
Merge with master
Diffstat (limited to 'setuptools')
-rw-r--r-- | setuptools/__init__.py | 2 | ||||
-rwxr-xr-x | setuptools/namespaces.py | 1 | ||||
-rwxr-xr-x | setuptools/package_index.py | 4 | ||||
-rw-r--r-- | setuptools/py33compat.py | 1 | ||||
-rw-r--r-- | setuptools/ssl_support.py | 55 |
5 files changed, 33 insertions, 30 deletions
diff --git a/setuptools/__init__.py b/setuptools/__init__.py index c60e1eab..d01918ed 100644 --- a/setuptools/__init__.py +++ b/setuptools/__init__.py @@ -7,7 +7,7 @@ import distutils.filelist from distutils.util import convert_path from fnmatch import fnmatchcase -from six.moves import filter, filterfalse, map +from six.moves import filter, map import setuptools.version from setuptools.extension import Extension diff --git a/setuptools/namespaces.py b/setuptools/namespaces.py index ba907439..556b5dd2 100755 --- a/setuptools/namespaces.py +++ b/setuptools/namespaces.py @@ -1,5 +1,4 @@ import os -import sys from distutils import log import itertools diff --git a/setuptools/package_index.py b/setuptools/package_index.py index 65c3c433..42361058 100755 --- a/setuptools/package_index.py +++ b/setuptools/package_index.py @@ -20,7 +20,7 @@ from six.moves import urllib, http_client, configparser, map import setuptools from pkg_resources import ( CHECKOUT_DIST, Distribution, BINARY_DIST, normalize_path, SOURCE_DIST, - require, Environment, find_distributions, safe_name, safe_version, + Environment, find_distributions, safe_name, safe_version, to_filename, Requirement, DEVELOP_DIST, ) from setuptools import ssl_support @@ -48,7 +48,7 @@ __all__ = [ _SOCKET_TIMEOUT = 15 _tmpl = "setuptools/{setuptools.__version__} Python-urllib/{py_major}" -user_agent = _tmpl.format(py_major=sys.version[:3], **globals()) +user_agent = _tmpl.format(py_major=sys.version[:3], setuptools=setuptools) def parse_requirement_arg(spec): diff --git a/setuptools/py33compat.py b/setuptools/py33compat.py index ad91d73e..0caa2003 100644 --- a/setuptools/py33compat.py +++ b/setuptools/py33compat.py @@ -1,5 +1,4 @@ import dis -import code import array import collections diff --git a/setuptools/ssl_support.py b/setuptools/ssl_support.py index efeef71d..fa5e4421 100644 --- a/setuptools/ssl_support.py +++ b/setuptools/ssl_support.py @@ -2,10 +2,10 @@ import os import socket import atexit import re +import functools -from six.moves import urllib, http_client, map +from six.moves import urllib, http_client, map, filter -import pkg_resources from pkg_resources import ResolutionError, ExtractionError try: @@ -204,47 +204,52 @@ def opener_for(ca_bundle=None): ).open -_wincerts = None +# from jaraco.functools +def once(func): + @functools.wraps(func) + def wrapper(*args, **kwargs): + if not hasattr(func, 'always_returns'): + func.always_returns = func(*args, **kwargs) + return func.always_returns + return wrapper +@once def get_win_certfile(): - global _wincerts - if _wincerts is not None: - return _wincerts.name - try: - from wincertstore import CertFile + import wincertstore except ImportError: return None - class MyCertFile(CertFile): - def __init__(self, stores=(), certs=()): - CertFile.__init__(self) - for store in stores: - self.addstore(store) - self.addcerts(certs) + class CertFile(wincertstore.CertFile): + def __init__(self): + super(CertFile, self).__init__() atexit.register(self.close) def close(self): try: - super(MyCertFile, self).close() + super(CertFile, self).close() except OSError: pass - _wincerts = MyCertFile(stores=['CA', 'ROOT']) + _wincerts = CertFile() + _wincerts.addstore('CA') + _wincerts.addstore('ROOT') return _wincerts.name def find_ca_bundle(): """Return an existing CA bundle path, or None""" - if os.name == 'nt': - return get_win_certfile() - else: - for cert_path in cert_paths: - if os.path.isfile(cert_path): - return cert_path + extant_cert_paths = filter(os.path.isfile, cert_paths) + return ( + get_win_certfile() + or next(extant_cert_paths, None) + or _certifi_where() + ) + + +def _certifi_where(): try: - import certifi - return certifi.where() + return __import__('certifi').where() except (ImportError, ResolutionError, ExtractionError): - return None + pass |