Repository: pypa/pip

Issue:
Update distlib to 0.2.3
- Pip version: 8.1.1
- Python version: 2.x
- Operating System: Arch Linux
### Description:

I'm trying to solve https://github.com/pypa/virtualenv/issues/457 via https://github.com/pypa/virtualenv/pull/875. Previously the latter needed to patch distlib. Now a new version of distlib is released. Please consider update distlib in pip.
### What I've run:

There are lots of sample outputs at https://github.com/pypa/virtualenv/issues/457. They are not related to pip, though, so I don't copy and paste.



Discussion:

Resolving patch:
diff --git a/pip/_vendor/distlib/__init__.py b/pip/_vendor/distlib/__init__.py
--- 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
--- a/pip/_vendor/distlib/util.py
+++ b/pip/_vendor/distlib/util.py
@@ -33,7 +33,8 @@
                      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 @@ def __eq__(self, other):
     __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
--- a/pip/_vendor/distlib/wheel.py
+++ b/pip/_vendor/distlib/wheel.py
@@ -293,11 +293,13 @@ def get_hash(self, data, hash_kind=None):
         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 = []


Test patch: