[Python-modules-commits] [python-pip] 01/08: Import python-pip_8.1.2.orig.tar.gz

Barry Warsaw barry at moszumanska.debian.org
Wed May 11 13:54:43 UTC 2016


This is an automated email from the git hooks/post-receive script.

barry pushed a commit to branch master
in repository python-pip.

commit 030df74bb06ecef9a308cb8315a0c93f1f971cfb
Author: Barry Warsaw <barry at python.org>
Date:   Wed May 11 09:28:54 2016 -0400

    Import python-pip_8.1.2.orig.tar.gz
---
 AUTHORS.txt                                        |   6 +
 CHANGES.txt                                        |  19 +
 PKG-INFO                                           |   2 +-
 pip.egg-info/PKG-INFO                              |   2 +-
 pip.egg-info/SOURCES.txt                           |   3 +-
 pip/__init__.py                                    |   8 +-
 pip/_vendor/README.rst                             |  11 +-
 pip/_vendor/_markerlib/__init__.py                 |  16 -
 pip/_vendor/_markerlib/markers.py                  | 119 ------
 pip/_vendor/colorama/__init__.py                   |   2 +-
 pip/_vendor/colorama/ansitowin32.py                |  10 +-
 pip/_vendor/colorama/initialise.py                 |   3 +-
 pip/_vendor/distlib/__init__.py                    |   2 +-
 pip/_vendor/distlib/util.py                        |  16 +-
 pip/_vendor/distlib/wheel.py                       |   6 +-
 pip/_vendor/packaging/__about__.py                 |   2 +-
 pip/_vendor/packaging/markers.py                   |  16 +-
 pip/_vendor/pkg_resources/__init__.py              | 461 ++++++---------------
 pip/_vendor/pyparsing.py                           |  76 ++--
 pip/_vendor/requests/__init__.py                   |  16 +-
 pip/_vendor/requests/adapters.py                   |  52 ++-
 pip/_vendor/requests/api.py                        |   6 +-
 pip/_vendor/requests/auth.py                       |  19 +
 pip/_vendor/requests/cookies.py                    |   6 +
 pip/_vendor/requests/models.py                     |  10 +-
 pip/_vendor/requests/packages/urllib3/__init__.py  |  11 +-
 .../requests/packages/urllib3/_collections.py      |   2 +-
 .../requests/packages/urllib3/connection.py        |  64 ++-
 .../requests/packages/urllib3/connectionpool.py    |  93 +++--
 .../requests/packages/urllib3/contrib/appengine.py |  12 +-
 .../requests/packages/urllib3/contrib/ntlmpool.py  |  20 +-
 .../requests/packages/urllib3/contrib/pyopenssl.py |  64 ++-
 .../requests/packages/urllib3/contrib/socks.py     | 172 ++++++++
 .../requests/packages/urllib3/exceptions.py        |   8 +
 pip/_vendor/requests/packages/urllib3/fields.py    |   4 +-
 .../requests/packages/urllib3/poolmanager.py       |  17 +-
 pip/_vendor/requests/packages/urllib3/response.py  |  38 +-
 .../requests/packages/urllib3/util/__init__.py     |   2 +
 .../requests/packages/urllib3/util/response.py     |   2 +-
 .../requests/packages/urllib3/util/retry.py        |  14 +-
 pip/_vendor/requests/packages/urllib3/util/ssl_.py |  11 +-
 pip/_vendor/requests/sessions.py                   |  65 +--
 pip/_vendor/requests/status_codes.py               |   1 +
 pip/_vendor/requests/structures.py                 |   4 +-
 pip/_vendor/requests/utils.py                      |  39 +-
 pip/_vendor/vendor.txt                             |  24 +-
 pip/basecommand.py                                 |   8 +-
 pip/commands/search.py                             |  11 +-
 pip/index.py                                       |   4 +-
 pip/pep425tags.py                                  |  25 +-
 pip/req/req_install.py                             |  48 +--
 pip/req/req_set.py                                 |  14 +-
 pip/wheel.py                                       |  10 +-
 setup.cfg                                          |   4 +-
 54 files changed, 927 insertions(+), 753 deletions(-)

diff --git a/AUTHORS.txt b/AUTHORS.txt
index 6b15087..a942b0c 100644
--- a/AUTHORS.txt
+++ b/AUTHORS.txt
@@ -31,6 +31,7 @@ Bradley Ayers <bradley.ayers at gmail.com>
 Brian Rosner <brosner at gmail.com>
 Bruno Renié <brutasse at gmail.com>
 Buck Golemon <buck at yelp.com>
+burrows <burrows at preveil.com>
 Bussonnier Matthias <bussonniermatthias at gmail.com>
 Carl Meyer <carl at oddbird.net>
 Carlos Liam <carlos at aarzee.me>
@@ -47,6 +48,7 @@ Clay McClure <clay at daemons.net>
 Cody Soyland <codysoyland at gmail.com>
 Colin Watson <cjwatson at debian.org>
 Cory Benfield <lukasaoz at gmail.com>
+Cory Wright <corywright at gmail.com>
 Craig Kerstiens <craig.kerstiens at gmail.com>
 Cristian Sorinel <cristian.sorinel at gmail.com>
 Dan Savilonis <djs at n-cube.org>
@@ -88,6 +90,7 @@ Francesco Montesano <franz.bergesund at gmail.com>
 Gabriel de Perthuis <g2p.code at gmail.com>
 Garry Polley <garrympolley at gmail.com>
 Geoffrey Lehée <geoffrey at lehee.name>
+Geoffrey Sneddon <me at gsnedders.com>
 George Song <george at 55minutes.com>
 Georgi Valkov <georgi.t.valkov at gmail.com>
 gizmoguy1 <gizmoguy1 at gmail.com>
@@ -100,6 +103,7 @@ Hynek Schlawack <hs at ox.cx>
 Ian Bicking <ianb at colorstudy.com>
 Ian Cordasco <graffatcolmingov at gmail.com>
 Ian Lee <IanLee1521 at gmail.com>
+Ian Wienand <ian at wienand.org>
 Ian Wienand <iwienand at redhat.com>
 Igor Sobreira <igor at igorsobreira.com>
 Ilya Baryshev <baryshev at gmail.com>
@@ -261,6 +265,7 @@ Thomas Kluyver <takowl at gmail.com>
 Thomas Smith <smithtg at ncbi.nlm.nih.gov>
 Tim Harder <radhermit at gmail.com>
 tim smith <github at tim-smith.us>
+tinruufu <tinruufu at gmail.com>
 Tomer Chachamu <tomer.chachamu at gmail.com>
 Tony Zhaocheng Tan <tony at tonytan.io>
 Toshio Kuratomi <toshio at fedoraproject.org>
@@ -276,6 +281,7 @@ Wil Tan <wil at dready.org>
 William ML Leslie <william.leslie.ttg at gmail.com>
 Xavier Fernandez <xav.fernandez at gmail.com>
 Xavier Fernandez <xavier.fernandez at polyconseil.fr>
+Yen Chi Hsuan <yan12125 at gmail.com>
 Yoval P <yoval at gmx.com>
 Yu Jian <askingyj at gmail.com>
 Zearin <zearin at gonk.net>
diff --git a/CHANGES.txt b/CHANGES.txt
index 9394b05..51e103c 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,3 +1,22 @@
+**8.1.2 (2016-05-10)**
+
+* Fix a regression on systems with uninitialized locale (:issue:`3575`).
+
+* Use environment markers to filter packages before determining if a
+  required wheel is supported. Solves (:issue:`3254`).
+
+* Make glibc parsing for `manylinux1` support more robust for the variety of
+  glibc versions found in the wild (:issue:`3588`).
+
+* Update environment marker support to fully support PEP 508 and legacy
+  environment markers (:issue:`3624`).
+
+* Always use debug logging to the ``--log`` file (:issue:`3351`).
+
+* Don't attempt to wrap search results for extremely narrow terminal windows
+  (:issue:`3655`).
+
+
 **8.1.1 (2016-03-17)**
 
 * Fix regression with non-ascii requirement files on Python 2 and add support
diff --git a/PKG-INFO b/PKG-INFO
index 6afdcd6..d4ffabb 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: pip
-Version: 8.1.1
+Version: 8.1.2
 Summary: The PyPA recommended tool for installing Python packages.
 Home-page: https://pip.pypa.io/
 Author: The pip developers
diff --git a/pip.egg-info/PKG-INFO b/pip.egg-info/PKG-INFO
index 6afdcd6..d4ffabb 100644
--- a/pip.egg-info/PKG-INFO
+++ b/pip.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: pip
-Version: 8.1.1
+Version: 8.1.2
 Summary: The PyPA recommended tool for installing Python packages.
 Home-page: https://pip.pypa.io/
 Author: The pip developers
diff --git a/pip.egg-info/SOURCES.txt b/pip.egg-info/SOURCES.txt
index 8b1e554..93507d2 100644
--- a/pip.egg-info/SOURCES.txt
+++ b/pip.egg-info/SOURCES.txt
@@ -58,8 +58,6 @@ pip/_vendor/re-vendor.py
 pip/_vendor/retrying.py
 pip/_vendor/six.py
 pip/_vendor/vendor.txt
-pip/_vendor/_markerlib/__init__.py
-pip/_vendor/_markerlib/markers.py
 pip/_vendor/cachecontrol/__init__.py
 pip/_vendor/cachecontrol/_cmd.py
 pip/_vendor/cachecontrol/adapter.py
@@ -227,6 +225,7 @@ pip/_vendor/requests/packages/urllib3/contrib/__init__.py
 pip/_vendor/requests/packages/urllib3/contrib/appengine.py
 pip/_vendor/requests/packages/urllib3/contrib/ntlmpool.py
 pip/_vendor/requests/packages/urllib3/contrib/pyopenssl.py
+pip/_vendor/requests/packages/urllib3/contrib/socks.py
 pip/_vendor/requests/packages/urllib3/packages/__init__.py
 pip/_vendor/requests/packages/urllib3/packages/ordered_dict.py
 pip/_vendor/requests/packages/urllib3/packages/six.py
diff --git a/pip/__init__.py b/pip/__init__.py
index 51e7eaf..588c881 100755
--- a/pip/__init__.py
+++ b/pip/__init__.py
@@ -31,7 +31,7 @@ import pip.cmdoptions
 cmdoptions = pip.cmdoptions
 
 # The version as used in the setup.py and the docs conf.py
-__version__ = "8.1.1"
+__version__ = "8.1.2"
 
 
 logger = logging.getLogger(__name__)
@@ -212,7 +212,11 @@ def main(args=None):
 
     # Needed for locale.getpreferredencoding(False) to work
     # in pip.utils.encoding.auto_decode
-    locale.setlocale(locale.LC_ALL, '')
+    try:
+        locale.setlocale(locale.LC_ALL, '')
+    except locale.Error as e:
+        # setlocale can apparently crash if locale are uninitialized
+        logger.debug("Ignoring error %s when setting locale", e)
     command = commands_dict[cmd_name](isolated=check_isolated(cmd_args))
     return command.main(cmd_args)
 
diff --git a/pip/_vendor/README.rst b/pip/_vendor/README.rst
index 6a27c09..a9cddb1 100644
--- a/pip/_vendor/README.rst
+++ b/pip/_vendor/README.rst
@@ -92,20 +92,19 @@ situation that we expect pip to be used and not mandate some external mechanism
 such as OS packages.
 
 
-_markerlib and pkg_resources
-----------------------------
+pkg_resources
+-------------
 
-_markerlib and pkg_resources has been pulled in from setuptools 19.4
+pkg_resources has been pulled in from setuptools 21.0.0
 
 
 Modifications
 -------------
 
 * html5lib has been modified to import six from pip._vendor
-* pkg_resources has been modified to import _markerlib from pip._vendor
-* markerlib has been modified to import its API from pip._vendor
+* pkg_resources has been modified to import its externs from pip._vendor
 * CacheControl has been modified to import its dependencies from pip._vendor
-* packaging has been modified to import its dependencies from pip._vendor.
+* packaging has been modified to import its dependencies from pip._vendor
 
 
 Debundling
diff --git a/pip/_vendor/_markerlib/__init__.py b/pip/_vendor/_markerlib/__init__.py
deleted file mode 100644
index 197781a..0000000
--- a/pip/_vendor/_markerlib/__init__.py
+++ /dev/null
@@ -1,16 +0,0 @@
-try:
-    import ast
-    from pip._vendor._markerlib.markers import default_environment, compile, interpret
-except ImportError:
-    if 'ast' in globals():
-        raise
-    def default_environment():
-        return {}
-    def compile(marker):
-        def marker_fn(environment=None, override=None):
-            # 'empty markers are True' heuristic won't install extra deps.
-            return not marker.strip()
-        marker_fn.__doc__ = marker
-        return marker_fn
-    def interpret(marker, environment=None, override=None):
-        return compile(marker)()
diff --git a/pip/_vendor/_markerlib/markers.py b/pip/_vendor/_markerlib/markers.py
deleted file mode 100644
index fa83706..0000000
--- a/pip/_vendor/_markerlib/markers.py
+++ /dev/null
@@ -1,119 +0,0 @@
-# -*- coding: utf-8 -*-
-"""Interpret PEP 345 environment markers.
-
-EXPR [in|==|!=|not in] EXPR [or|and] ...
-
-where EXPR belongs to any of those:
-
-    python_version = '%s.%s' % (sys.version_info[0], sys.version_info[1])
-    python_full_version = sys.version.split()[0]
-    os.name = os.name
-    sys.platform = sys.platform
-    platform.version = platform.version()
-    platform.machine = platform.machine()
-    platform.python_implementation = platform.python_implementation()
-    a free string, like '2.6', or 'win32'
-"""
-
-__all__ = ['default_environment', 'compile', 'interpret']
-
-import ast
-import os
-import platform
-import sys
-import weakref
-
-_builtin_compile = compile
-
-try:
-    from platform import python_implementation
-except ImportError:
-    if os.name == "java":
-        # Jython 2.5 has ast module, but not platform.python_implementation() function.
-        def python_implementation():
-            return "Jython"
-    else:
-        raise
-
-
-# restricted set of variables
-_VARS = {'sys.platform': sys.platform,
-         'python_version': '%s.%s' % sys.version_info[:2],
-         # FIXME parsing sys.platform is not reliable, but there is no other
-         # way to get e.g. 2.7.2+, and the PEP is defined with sys.version
-         'python_full_version': sys.version.split(' ', 1)[0],
-         'os.name': os.name,
-         'platform.version': platform.version(),
-         'platform.machine': platform.machine(),
-         'platform.python_implementation': python_implementation(),
-         'extra': None # wheel extension
-        }
-
-for var in list(_VARS.keys()):
-    if '.' in var:
-        _VARS[var.replace('.', '_')] = _VARS[var]
-
-def default_environment():
-    """Return copy of default PEP 385 globals dictionary."""
-    return dict(_VARS)
-
-class ASTWhitelist(ast.NodeTransformer):
-    def __init__(self, statement):
-        self.statement = statement # for error messages
-
-    ALLOWED = (ast.Compare, ast.BoolOp, ast.Attribute, ast.Name, ast.Load, ast.Str)
-    # Bool operations
-    ALLOWED += (ast.And, ast.Or)
-    # Comparison operations
-    ALLOWED += (ast.Eq, ast.Gt, ast.GtE, ast.In, ast.Is, ast.IsNot, ast.Lt, ast.LtE, ast.NotEq, ast.NotIn)
-
-    def visit(self, node):
-        """Ensure statement only contains allowed nodes."""
-        if not isinstance(node, self.ALLOWED):
-            raise SyntaxError('Not allowed in environment markers.\n%s\n%s' %
-                               (self.statement,
-                               (' ' * node.col_offset) + '^'))
-        return ast.NodeTransformer.visit(self, node)
-
-    def visit_Attribute(self, node):
-        """Flatten one level of attribute access."""
-        new_node = ast.Name("%s.%s" % (node.value.id, node.attr), node.ctx)
-        return ast.copy_location(new_node, node)
-
-def parse_marker(marker):
-    tree = ast.parse(marker, mode='eval')
-    new_tree = ASTWhitelist(marker).generic_visit(tree)
-    return new_tree
-
-def compile_marker(parsed_marker):
-    return _builtin_compile(parsed_marker, '<environment marker>', 'eval',
-                   dont_inherit=True)
-
-_cache = weakref.WeakValueDictionary()
-
-def compile(marker):
-    """Return compiled marker as a function accepting an environment dict."""
-    try:
-        return _cache[marker]
-    except KeyError:
-        pass
-    if not marker.strip():
-        def marker_fn(environment=None, override=None):
-            """"""
-            return True
-    else:
-        compiled_marker = compile_marker(parse_marker(marker))
-        def marker_fn(environment=None, override=None):
-            """override updates environment"""
-            if override is None:
-                override = {}
-            if environment is None:
-                environment = default_environment()
-            environment.update(override)
-            return eval(compiled_marker, environment)
-    marker_fn.__doc__ = marker
-    _cache[marker] = marker_fn
-    return _cache[marker]
-
-def interpret(marker, environment=None):
-    return compile(marker)(environment)
diff --git a/pip/_vendor/colorama/__init__.py b/pip/_vendor/colorama/__init__.py
index 8fc3f01..670e6b3 100644
--- a/pip/_vendor/colorama/__init__.py
+++ b/pip/_vendor/colorama/__init__.py
@@ -3,5 +3,5 @@ from .initialise import init, deinit, reinit, colorama_text
 from .ansi import Fore, Back, Style, Cursor
 from .ansitowin32 import AnsiToWin32
 
-__version__ = '0.3.6'
+__version__ = '0.3.7'
 
diff --git a/pip/_vendor/colorama/ansitowin32.py b/pip/_vendor/colorama/ansitowin32.py
index a750d2a..b7ff6f2 100644
--- a/pip/_vendor/colorama/ansitowin32.py
+++ b/pip/_vendor/colorama/ansitowin32.py
@@ -13,6 +13,10 @@ if windll is not None:
     winterm = WinTerm()
 
 
+def is_stream_closed(stream):
+    return not hasattr(stream, 'closed') or stream.closed
+
+
 def is_a_tty(stream):
     return hasattr(stream, 'isatty') and stream.isatty()
 
@@ -64,12 +68,12 @@ class AnsiToWin32(object):
 
         # should we strip ANSI sequences from our output?
         if strip is None:
-            strip = conversion_supported or (not wrapped.closed and not is_a_tty(wrapped))
+            strip = conversion_supported or (not is_stream_closed(wrapped) and not is_a_tty(wrapped))
         self.strip = strip
 
         # should we should convert ANSI sequences into win32 calls?
         if convert is None:
-            convert = conversion_supported and not wrapped.closed and is_a_tty(wrapped)
+            convert = conversion_supported and not is_stream_closed(wrapped) and is_a_tty(wrapped)
         self.convert = convert
 
         # dict of ansi codes to win32 functions and parameters
@@ -145,7 +149,7 @@ class AnsiToWin32(object):
     def reset_all(self):
         if self.convert:
             self.call_win32('m', (0,))
-        elif not self.strip and not self.wrapped.closed:
+        elif not self.strip and not is_stream_closed(self.wrapped):
             self.wrapped.write(Style.RESET_ALL)
 
 
diff --git a/pip/_vendor/colorama/initialise.py b/pip/_vendor/colorama/initialise.py
index 4bce9f2..834962a 100644
--- a/pip/_vendor/colorama/initialise.py
+++ b/pip/_vendor/colorama/initialise.py
@@ -16,7 +16,8 @@ atexit_done = False
 
 
 def reset_all():
-    AnsiToWin32(orig_stdout).reset_all()
+    if AnsiToWin32 is not None:    # Issue #74: objects might become None at exit
+        AnsiToWin32(orig_stdout).reset_all()
 
 
 def init(autoreset=False, convert=None, strip=None, wrap=True):
diff --git a/pip/_vendor/distlib/__init__.py b/pip/_vendor/distlib/__init__.py
index c2421d8..7026860 100644
--- a/pip/_vendor/distlib/__init__.py
+++ b/pip/_vendor/distlib/__init__.py
@@ -6,7 +6,7 @@
 #
 import logging
 
-__version__ = '0.2.2'
+__version__ = '0.2.3'
 
 class DistlibException(Exception):
     pass
diff --git a/pip/_vendor/distlib/util.py b/pip/_vendor/distlib/util.py
index 1aa4cdd..7e209ec 100644
--- a/pip/_vendor/distlib/util.py
+++ b/pip/_vendor/distlib/util.py
@@ -33,7 +33,8 @@ from .compat import (string_types, text_type, shutil, raw_input, StringIO,
                      cache_from_source, urlopen, urljoin, httplib, xmlrpclib,
                      splittype, HTTPHandler, HTTPSHandler as BaseHTTPSHandler,
                      BaseConfigurator, valid_ident, Container, configparser,
-                     URLError, match_hostname, CertificateError, ZipFile)
+                     URLError, match_hostname, CertificateError, ZipFile,
+                     fsdecode)
 
 logger = logging.getLogger(__name__)
 
@@ -165,7 +166,10 @@ def get_executable():
 #    else:
 #        result = sys.executable
 #    return result
-    return os.path.normcase(sys.executable)
+    result = os.path.normcase(sys.executable)
+    if not isinstance(result, text_type):
+        result = fsdecode(result)
+    return result
 
 
 def proceed(prompt, allowed_chars, error_prompt=None, default=None):
@@ -553,12 +557,11 @@ class ExportEntry(object):
     __hash__ = object.__hash__
 
 
-ENTRY_RE = re.compile(r'''(?P<name>(\w|[-.])+)
+ENTRY_RE = re.compile(r'''(?P<name>(\w|[-.+])+)
                       \s*=\s*(?P<callable>(\w+)([:\.]\w+)*)
                       \s*(\[\s*(?P<flags>\w+(=\w+)?(,\s*\w+(=\w+)?)*)\s*\])?
                       ''', re.VERBOSE)
 
-
 def get_export_entry(specification):
     m = ENTRY_RE.search(specification)
     if not m:
@@ -760,8 +763,9 @@ def _get_external_data(url):
         # using a custom redirect handler.
         resp = urlopen(url)
         headers = resp.info()
-        if headers.get('Content-Type') != 'application/json':
-            logger.debug('Unexpected response for JSON request')
+        ct = headers.get('Content-Type')
+        if not ct.startswith('application/json'):
+            logger.debug('Unexpected response for JSON request: %s', ct)
         else:
             reader = codecs.getreader('utf-8')(resp)
             #data = reader.read().decode('utf-8')
diff --git a/pip/_vendor/distlib/wheel.py b/pip/_vendor/distlib/wheel.py
index a08fb54..2952b8e 100644
--- a/pip/_vendor/distlib/wheel.py
+++ b/pip/_vendor/distlib/wheel.py
@@ -293,11 +293,13 @@ class Wheel(object):
         return hash_kind, result
 
     def write_record(self, records, record_path, base):
+        records = list(records) # make a copy for sorting
+        p = to_posix(os.path.relpath(record_path, base))
+        records.append((p, '', ''))
+        records.sort()
         with CSVWriter(record_path) as writer:
             for row in records:
                 writer.writerow(row)
-            p = to_posix(os.path.relpath(record_path, base))
-            writer.writerow((p, '', ''))
 
     def write_records(self, info, libdir, archive_paths):
         records = []
diff --git a/pip/_vendor/packaging/__about__.py b/pip/_vendor/packaging/__about__.py
index 47e5a6f..c21a758 100644
--- a/pip/_vendor/packaging/__about__.py
+++ b/pip/_vendor/packaging/__about__.py
@@ -12,7 +12,7 @@ __title__ = "packaging"
 __summary__ = "Core utilities for Python packages"
 __uri__ = "https://github.com/pypa/packaging"
 
-__version__ = "16.5"
+__version__ = "16.7"
 
 __author__ = "Donald Stufft and individual contributors"
 __email__ = "donald at stufft.io"
diff --git a/pip/_vendor/packaging/markers.py b/pip/_vendor/packaging/markers.py
index dec8a27..9195243 100644
--- a/pip/_vendor/packaging/markers.py
+++ b/pip/_vendor/packaging/markers.py
@@ -75,9 +75,23 @@ VARIABLE = (
     L("python_version") |
     L("sys_platform") |
     L("os_name") |
+    L("os.name") |  # PEP-345
+    L("sys.platform") |  # PEP-345
+    L("platform.version") |  # PEP-345
+    L("platform.machine") |  # PEP-345
+    L("platform.python_implementation") |  # PEP-345
+    L("python_implementation") |  # undocumented setuptools legacy
     L("extra")
 )
-VARIABLE.setParseAction(lambda s, l, t: Variable(t[0]))
+ALIASES = {
+    'os.name': 'os_name',
+    'sys.platform': 'sys_platform',
+    'platform.version': 'platform_version',
+    'platform.machine': 'platform_machine',
+    'platform.python_implementation': 'platform_python_implementation',
+    'python_implementation': 'platform_python_implementation'
+}
+VARIABLE.setParseAction(lambda s, l, t: Variable(ALIASES.get(t[0], t[0])))
 
 VERSION_CMP = (
     L("===") |
diff --git a/pip/_vendor/pkg_resources/__init__.py b/pip/_vendor/pkg_resources/__init__.py
index e62da92..91e1a9d 100644
--- a/pip/_vendor/pkg_resources/__init__.py
+++ b/pip/_vendor/pkg_resources/__init__.py
@@ -28,8 +28,6 @@ import warnings
 import stat
 import functools
 import pkgutil
-import token
-import symbol
 import operator
 import platform
 import collections
@@ -46,7 +44,7 @@ except ImportError:
     import imp as _imp
 
 from pip._vendor import six
-from pip._vendor.six.moves import urllib, map
+from pip._vendor.six.moves import urllib, map, filter
 
 # capture these to bypass sandboxing
 from os import utime
@@ -60,25 +58,20 @@ except ImportError:
 from os import open as os_open
 from os.path import isdir, split
 
-# Avoid try/except due to potential problems with delayed import mechanisms.
-if sys.version_info >= (3, 3) and sys.implementation.name == "cpython":
-    import importlib.machinery as importlib_machinery
-else:
-    importlib_machinery = None
-
 try:
-    import parser
+    import importlib.machinery as importlib_machinery
+    # access attribute to force import under delayed import mechanisms.
+    importlib_machinery.__name__
 except ImportError:
-    pass
+    importlib_machinery = None
 
 from pip._vendor import packaging
 __import__('pip._vendor.packaging.version')
 __import__('pip._vendor.packaging.specifiers')
+__import__('pip._vendor.packaging.requirements')
+__import__('pip._vendor.packaging.markers')
 
 
-filter = six.moves.filter
-map = six.moves.map
-
 if (3, 0) < sys.version_info < (3, 3):
     msg = (
         "Support for Python 3.0-3.2 has been dropped. Future versions "
@@ -799,6 +792,8 @@ class WorkingSet(object):
         best = {}
         to_activate = []
 
+        req_extras = _ReqExtras()
+
         # Mapping of requirement to set of distributions that required it;
         # useful for reporting info about conflicts.
         required_by = collections.defaultdict(set)
@@ -809,6 +804,10 @@ class WorkingSet(object):
             if req in processed:
                 # Ignore cyclic or redundant dependencies
                 continue
+
+            if not req_extras.markers_pass(req):
+                continue
+
             dist = best.get(req.key)
             if dist is None:
                 # Find the best distribution and add it to the map
@@ -841,6 +840,7 @@ class WorkingSet(object):
             # Register the new requirements needed by req
             for new_requirement in new_requirements:
                 required_by[new_requirement].add(req.project_name)
+                req_extras[new_requirement] = req.extras
 
             processed[req] = True
 
@@ -973,6 +973,26 @@ class WorkingSet(object):
         self.callbacks = callbacks[:]
 
 
+class _ReqExtras(dict):
+    """
+    Map each requirement to the extras that demanded it.
+    """
+
+    def markers_pass(self, req):
+        """
+        Evaluate markers for req against each extra that
+        demanded it.
+
+        Return False if the req has a marker and fails
+        evaluation. Otherwise, return True.
+        """
+        extra_evals = (
+            req.marker.evaluate({'extra': extra})
+            for extra in self.get(req, ()) + (None,)
+        )
+        return not req.marker or any(extra_evals)
+
+
 class Environment(object):
     """Searchable snapshot of distributions on a search path"""
 
@@ -1176,22 +1196,23 @@ class ResourceManager:
         old_exc = sys.exc_info()[1]
         cache_path = self.extraction_path or get_default_cache()
 
-        err = ExtractionError("""Can't extract file(s) to egg cache
+        tmpl = textwrap.dedent("""
+            Can't extract file(s) to egg cache
 
-The following error occurred while trying to extract file(s) to the Python egg
-cache:
+            The following error occurred while trying to extract file(s) to the Python egg
+            cache:
 
-  %s
+              {old_exc}
 
-The Python egg cache directory is currently set to:
+            The Python egg cache directory is currently set to:
 
-  %s
+              {cache_path}
 
-Perhaps your account does not have write access to this directory?  You can
-change the cache directory by setting the PYTHON_EGG_CACHE environment
-variable to point to an accessible directory.
-""" % (old_exc, cache_path)
-        )
+            Perhaps your account does not have write access to this directory?  You can
+            change the cache directory by setting the PYTHON_EGG_CACHE environment
+            variable to point to an accessible directory.
+            """).lstrip()
+        err = ExtractionError(tmpl.format(**locals()))
         err.manager = self
         err.cache_path = cache_path
         err.original_error = old_exc
@@ -1386,202 +1407,34 @@ def to_filename(name):
     return name.replace('-','_')
 
 
-class MarkerEvaluation(object):
-    values = {
-        'os_name': lambda: os.name,
-        'sys_platform': lambda: sys.platform,
-        'python_full_version': platform.python_version,
-        'python_version': lambda: platform.python_version()[:3],
-        'platform_version': platform.version,
-        'platform_machine': platform.machine,
-        'platform_python_implementation': platform.python_implementation,
-        'python_implementation': platform.python_implementation,
-    }
-
-    @classmethod
-    def is_invalid_marker(cls, text):
-        """
-        Validate text as a PEP 426 environment marker; return an exception
-        if invalid or False otherwise.
-        """
-        try:
-            cls.evaluate_marker(text)
-        except SyntaxError as e:
-            return cls.normalize_exception(e)
-        return False
-
-    @staticmethod
-    def normalize_exception(exc):
-        """
-        Given a SyntaxError from a marker evaluation, normalize the error
-        message:
-         - Remove indications of filename and line number.
-         - Replace platform-specific error messages with standard error
-           messages.
-        """
-        subs = {
-            'unexpected EOF while parsing': 'invalid syntax',
-            'parenthesis is never closed': 'invalid syntax',
-        }
-        exc.filename = None
-        exc.lineno = None
-        exc.msg = subs.get(exc.msg, exc.msg)
-        return exc
-
-    @classmethod
-    def and_test(cls, nodelist):
-        # MUST NOT short-circuit evaluation, or invalid syntax can be skipped!
-        items = [
-            cls.interpret(nodelist[i])
-            for i in range(1, len(nodelist), 2)
-        ]
-        return functools.reduce(operator.and_, items)
-
-    @classmethod
-    def test(cls, nodelist):
-        # MUST NOT short-circuit evaluation, or invalid syntax can be skipped!
-        items = [
-            cls.interpret(nodelist[i])
-            for i in range(1, len(nodelist), 2)
-        ]
-        return functools.reduce(operator.or_, items)
-
-    @classmethod
-    def atom(cls, nodelist):
-        t = nodelist[1][0]
-        if t == token.LPAR:
-            if nodelist[2][0] == token.RPAR:
-                raise SyntaxError("Empty parentheses")
-            return cls.interpret(nodelist[2])
-        msg = "Language feature not supported in environment markers"
-        raise SyntaxError(msg)
-
-    @classmethod
-    def comparison(cls, nodelist):
-        if len(nodelist) > 4:
-            msg = "Chained comparison not allowed in environment markers"
-            raise SyntaxError(msg)
-        comp = nodelist[2][1]
-        cop = comp[1]
-        if comp[0] == token.NAME:
-            if len(nodelist[2]) == 3:
-                if cop == 'not':
-                    cop = 'not in'
-                else:
-                    cop = 'is not'
-        try:
-            cop = cls.get_op(cop)
-        except KeyError:
-            msg = repr(cop) + " operator not allowed in environment markers"
-            raise SyntaxError(msg)
-        return cop(cls.evaluate(nodelist[1]), cls.evaluate(nodelist[3]))
-
-    @classmethod
-    def get_op(cls, op):
-        ops = {
-            symbol.test: cls.test,
-            symbol.and_test: cls.and_test,
-            symbol.atom: cls.atom,
-            symbol.comparison: cls.comparison,
-            'not in': lambda x, y: x not in y,
-            'in': lambda x, y: x in y,
-            '==': operator.eq,
-            '!=': operator.ne,
-            '<':  operator.lt,
-            '>':  operator.gt,
-            '<=': operator.le,
-            '>=': operator.ge,
-        }
-        if hasattr(symbol, 'or_test'):
-            ops[symbol.or_test] = cls.test
-        return ops[op]
-
-    @classmethod
-    def evaluate_marker(cls, text, extra=None):
-        """
-        Evaluate a PEP 426 environment marker on CPython 2.4+.
-        Return a boolean indicating the marker result in this environment.
-        Raise SyntaxError if marker is invalid.
-
-        This implementation uses the 'parser' module, which is not implemented
-        on
-        Jython and has been superseded by the 'ast' module in Python 2.6 and
-        later.
-        """
-        return cls.interpret(parser.expr(text).totuple(1)[1])
-
-    @staticmethod
-    def _translate_metadata2(env):
-        """
-        Markerlib implements Metadata 1.2 (PEP 345) environment markers.
-        Translate the variables to Metadata 2.0 (PEP 426).
-        """
-        return dict(
-            (key.replace('.', '_'), value)
-            for key, value in env.items()
-        )
-
-    @classmethod
-    def _markerlib_evaluate(cls, text):
-        """
-        Evaluate a PEP 426 environment marker using markerlib.
-        Return a boolean indicating the marker result in this environment.
-        Raise SyntaxError if marker is invalid.
-        """
-        from pip._vendor import _markerlib
-
-        env = cls._translate_metadata2(_markerlib.default_environment())
-        try:
-            result = _markerlib.interpret(text, env)
-        except NameError as e:
-            raise SyntaxError(e.args[0])
-        return result
-
-    if 'parser' not in globals():
-        # Fall back to less-complete _markerlib implementation if 'parser' module
-        # is not available.
-        evaluate_marker = _markerlib_evaluate
+def invalid_marker(text):
+    """
+    Validate text as a PEP 508 environment marker; return an exception
+    if invalid or False otherwise.
+    """
+    try:
+        evaluate_marker(text)
+    except SyntaxError as e:
+        e.filename = None
+        e.lineno = None
+        return e
+    return False
 
-    @classmethod
-    def interpret(cls, nodelist):
-        while len(nodelist)==2: nodelist = nodelist[1]
-        try:
-            op = cls.get_op(nodelist[0])
-        except KeyError:
-            raise SyntaxError("Comparison or logical expression expected")
-        return op(nodelist)
 
-    @classmethod
-    def evaluate(cls, nodelist):
-        while len(nodelist)==2: nodelist = nodelist[1]
-        kind = nodelist[0]
-        name = nodelist[1]
-        if kind==token.NAME:
-            try:
-                op = cls.values[name]
-            except KeyError:
-                raise SyntaxError("Unknown name %r" % name)
-            return op()
-        if kind==token.STRING:
-            s = nodelist[1]
-            if not cls._safe_string(s):
-                raise SyntaxError(
-                    "Only plain strings allowed in environment markers")
-            return s[1:-1]
-        msg = "Language feature not supported in environment markers"
-        raise SyntaxError(msg)
+def evaluate_marker(text, extra=None):
+    """
+    Evaluate a PEP 508 environment marker.
+    Return a boolean indicating the marker result in this environment.
+    Raise SyntaxError if marker is invalid.
 
-    @staticmethod
-    def _safe_string(cand):
-        return (
-            cand[:1] in "'\"" and
-            not cand.startswith('"""') and
-            not cand.startswith("'''") and
-            '\\' not in cand
-        )
+    This implementation uses the 'pyparsing' module.
+    """
+    try:
+        marker = packaging.markers.Marker(text)
+        return marker.evaluate()
+    except packaging.markers.InvalidMarker as e:
+        raise SyntaxError(e)
 
-invalid_marker = MarkerEvaluation.is_invalid_marker
-evaluate_marker = MarkerEvaluation.evaluate_marker
 
 class NullProvider:
     """Try to implement resources and metadata for arbitrary PEP 302 loaders"""
@@ -1727,10 +1580,13 @@ class DefaultProvider(EggProvider):
         with open(path, 'rb') as stream:
             return stream.read()
 
-register_loader_type(type(None), DefaultProvider)
+    @classmethod
+    def _register(cls):
+        loader_cls = getattr(importlib_machinery, 'SourceFileLoader',
+            type(None))
+        register_loader_type(loader_cls, cls)
 
-if importlib_machinery is not None:
-    register_loader_type(importlib_machinery.SourceFileLoader, DefaultProvider)
+DefaultProvider._register()
 
 
 class EmptyProvider(NullProvider):
@@ -2003,7 +1859,13 @@ class FileMetadata(EmptyProvider):
     def get_metadata(self, name):
         if name=='PKG-INFO':
             with io.open(self.path, encoding='utf-8') as f:
-                metadata = f.read()
+                try:
+                    metadata = f.read()
+                except UnicodeDecodeError as exc:
+                    # add path context to error message
+                    tmpl = " in {self.path}"
+                    exc.reason += tmpl.format(self=self)
+                    raise
             return metadata
         raise KeyError("No metadata except PKG-INFO is available")
 
@@ -2136,7 +1998,7 @@ def find_on_path(importer, path_item, only=False):
                         break
 register_finder(pkgutil.ImpImporter, find_on_path)
 
-if importlib_machinery is not None:
+if hasattr(importlib_machinery, 'FileFinder'):
     register_finder(importlib_machinery.FileFinder, find_on_path)
 
 _declare_state('dict', _namespace_handlers={})
@@ -2182,18 +2044,28 @@ def _handle_ns(packageName, path_item):
         path = module.__path__
         path.append(subpath)
         loader.load_module(packageName)
+        _rebuild_mod_path(path, packageName, module)
+    return subpath
 
-        # Rebuild mod.__path__ ensuring that all entries are ordered
... 2420 lines suppressed ...

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-pip.git



More information about the Python-modules-commits mailing list