diff options
| author | Jason R. Coombs <jaraco@jaraco.com> | 2016-01-04 21:00:47 -0500 |
|---|---|---|
| committer | Jason R. Coombs <jaraco@jaraco.com> | 2016-01-04 21:00:47 -0500 |
| commit | d9184f7b8f0b9405f68ea45dbd574aad6a08666d (patch) | |
| tree | e93b4d6ca527f8b22c4a11b978864f61ebe02405 /pkg_resources/__init__.py | |
| parent | 6bdbe8957d8c8d293e3fea3fa4baf45eb7c3a3a4 (diff) | |
| parent | b639cf0fa905f6fda3879c991197b759aaa20091 (diff) | |
| download | python-setuptools-git-19.3b1.tar.gz | |
Merge feature/issue-22919.3b1
Diffstat (limited to 'pkg_resources/__init__.py')
| -rw-r--r-- | pkg_resources/__init__.py | 43 |
1 files changed, 12 insertions, 31 deletions
diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py index b55e4127..7becc951 100644 --- a/pkg_resources/__init__.py +++ b/pkg_resources/__init__.py @@ -37,7 +37,6 @@ import plistlib import email.parser import tempfile import textwrap -import itertools from pkgutil import get_importer try: @@ -46,23 +45,8 @@ except ImportError: # Python 3.2 compatibility import imp as _imp -PY3 = sys.version_info > (3,) -PY2 = not PY3 - -if PY3: - from urllib.parse import urlparse, urlunparse - -if PY2: - from urlparse import urlparse, urlunparse - filter = itertools.ifilter - map = itertools.imap - -if PY3: - string_types = str, -else: - string_types = str, eval('unicode') - -iteritems = (lambda i: i.items()) if PY3 else lambda i: i.iteritems() +from pkg_resources.extern import six +from pkg_resources.extern.six.moves import urllib # capture these to bypass sandboxing from os import utime @@ -87,16 +71,13 @@ try: except ImportError: pass -try: - import pkg_resources._vendor.packaging.version - import pkg_resources._vendor.packaging.specifiers - packaging = pkg_resources._vendor.packaging -except ImportError: - # fallback to naturally-installed version; allows system packagers to - # omit vendored packages. - import packaging.version - import packaging.specifiers +from pkg_resources.extern import packaging +__import__('pkg_resources.extern.packaging.version') +__import__('pkg_resources.extern.packaging.specifiers') + +filter = six.moves.filter +map = six.moves.map if (3, 0) < sys.version_info < (3, 3): msg = ( @@ -555,7 +536,7 @@ run_main = run_script def get_distribution(dist): """Return a current distribution object for a Requirement or string""" - if isinstance(dist, string_types): + if isinstance(dist, six.string_types): dist = Requirement.parse(dist) if isinstance(dist, Requirement): dist = get_provider(dist) @@ -2303,7 +2284,7 @@ def _set_parent_ns(packageName): def yield_lines(strs): """Yield non-empty/non-comment lines of a string or sequence""" - if isinstance(strs, string_types): + if isinstance(strs, six.string_types): for s in strs.splitlines(): s = s.strip() # skip blank lines/comments @@ -2470,9 +2451,9 @@ class EntryPoint(object): def _remove_md5_fragment(location): if not location: return '' - parsed = urlparse(location) + parsed = urllib.parse.urlparse(location) if parsed[-1].startswith('md5='): - return urlunparse(parsed[:-1] + ('',)) + return urllib.parse.urlunparse(parsed[:-1] + ('',)) return location |
