run update.sh, install netifaces

This commit is contained in:
j 2016-03-23 12:39:11 +01:00
commit 717a291e19
258 changed files with 71187 additions and 1047 deletions

View file

@ -3,6 +3,7 @@ from __future__ import absolute_import
from collections import deque
import contextlib
import errno
import io
import locale
# we have a submodule named 'logging' which would shadow this if we used the
# regular name:
@ -38,7 +39,7 @@ __all__ = ['rmtree', 'display_path', 'backup_dir',
'format_size', 'is_installable_dir',
'is_svn_page', 'file_contents',
'split_leading_dir', 'has_leading_dir',
'normalize_path', 'canonicalize_name',
'normalize_path',
'renames', 'get_terminal_size', 'get_prog',
'unzip_file', 'untar_file', 'unpack_file', 'call_subprocess',
'captured_stdout', 'remove_tracebacks', 'ensure_dir',
@ -199,7 +200,7 @@ def file_contents(filename):
return fp.read().decode('utf-8')
def read_chunks(file, size=4096):
def read_chunks(file, size=io.DEFAULT_BUFFER_SIZE):
"""Yield pieces of data from a file-like object until EOF."""
while True:
chunk = file.read(size)
@ -275,40 +276,22 @@ def renames(old, new):
def is_local(path):
"""
Return True if this is a path pip is allowed to modify.
Return True if path is within sys.prefix, if we're running in a virtualenv.
If we're in a virtualenv, sys.prefix points to the virtualenv's
prefix; only sys.prefix is considered local.
If we're not in a virtualenv, in general we can modify anything.
However, if the OS vendor has configured distutils to install
somewhere other than sys.prefix (which could be a subdirectory of
sys.prefix, e.g. /usr/local), we consider sys.prefix itself nonlocal
and the domain of the OS vendor. (In other words, everything _other
than_ sys.prefix is considered local.)
If we're not in a virtualenv, all paths are considered "local."
"""
path = normalize_path(path)
prefix = normalize_path(sys.prefix)
if running_under_virtualenv():
return path.startswith(normalize_path(sys.prefix))
else:
from pip.locations import distutils_scheme
if path.startswith(prefix):
for local_path in distutils_scheme("").values():
if path.startswith(normalize_path(local_path)):
return True
return False
else:
return True
if not running_under_virtualenv():
return True
return normalize_path(path).startswith(normalize_path(sys.prefix))
def dist_is_local(dist):
"""
Return True if given Distribution object is installed somewhere pip
is allowed to modify.
Return True if given Distribution object is installed locally
(i.e. within current virtualenv).
Always True if we're not in a virtualenv.
"""
return is_local(dist_location(dist))
@ -653,6 +636,31 @@ def call_subprocess(cmd, show_stdout=True, cwd=None,
on_returncode='raise',
command_level=std_logging.DEBUG, command_desc=None,
extra_environ=None, spinner=None):
# This function's handling of subprocess output is confusing and I
# previously broke it terribly, so as penance I will write a long comment
# explaining things.
#
# The obvious thing that affects output is the show_stdout=
# kwarg. show_stdout=True means, let the subprocess write directly to our
# stdout. Even though it is nominally the default, it is almost never used
# inside pip (and should not be used in new code without a very good
# reason); as of 2016-02-22 it is only used in a few places inside the VCS
# wrapper code. Ideally we should get rid of it entirely, because it
# creates a lot of complexity here for a rarely used feature.
#
# Most places in pip set show_stdout=False. What this means is:
# - We connect the child stdout to a pipe, which we read.
# - By default, we hide the output but show a spinner -- unless the
# subprocess exits with an error, in which case we show the output.
# - If the --verbose option was passed (= loglevel is DEBUG), then we show
# the output unconditionally. (But in this case we don't want to show
# the output a second time if it turns out that there was an error.)
#
# stderr is always merged with stdout (even if show_stdout=True).
if show_stdout:
stdout = None
else:
stdout = subprocess.PIPE
if command_desc is None:
cmd_parts = []
for part in cmd:
@ -666,24 +674,28 @@ def call_subprocess(cmd, show_stdout=True, cwd=None,
env.update(extra_environ)
try:
proc = subprocess.Popen(
cmd, stderr=subprocess.STDOUT, stdin=None, stdout=subprocess.PIPE,
cmd, stderr=subprocess.STDOUT, stdin=None, stdout=stdout,
cwd=cwd, env=env)
except Exception as exc:
logger.critical(
"Error %s while executing command %s", exc, command_desc,
)
raise
all_output = []
while True:
line = console_to_str(proc.stdout.readline())
if not line:
break
line = line.rstrip()
all_output.append(line + '\n')
if show_stdout:
logger.debug(line)
if spinner is not None:
spinner.spin()
if stdout is not None:
all_output = []
while True:
line = console_to_str(proc.stdout.readline())
if not line:
break
line = line.rstrip()
all_output.append(line + '\n')
if logger.getEffectiveLevel() <= std_logging.DEBUG:
# Show the line immediately
logger.debug(line)
else:
# Update the spinner
if spinner is not None:
spinner.spin()
proc.wait()
if spinner is not None:
if proc.returncode:
@ -692,7 +704,8 @@ def call_subprocess(cmd, show_stdout=True, cwd=None,
spinner.finish("done")
if proc.returncode:
if on_returncode == 'raise':
if all_output:
if (logger.getEffectiveLevel() > std_logging.DEBUG and
not show_stdout):
logger.info(
'Complete output from command %s:', command_desc,
)
@ -842,11 +855,6 @@ def get_installed_version(dist_name):
return dist.version if dist else None
def canonicalize_name(name):
"""Convert an arbitrary string to a canonical name used for comparison"""
return pkg_resources.safe_name(name).lower()
def consume(iterator):
"""Consume an iterable at C speed."""
deque(iterator, maxlen=0)

View file

@ -11,23 +11,20 @@ class PipDeprecationWarning(Warning):
pass
class RemovedInPip9Warning(PipDeprecationWarning, DeprecationWarning):
class Pending(object):
pass
class RemovedInPip10Warning(PipDeprecationWarning, PendingDeprecationWarning):
class RemovedInPip9Warning(PipDeprecationWarning):
pass
class Python26DeprecationWarning(
PipDeprecationWarning, PendingDeprecationWarning
):
class RemovedInPip10Warning(PipDeprecationWarning, Pending):
pass
DEPRECATIONS = [
RemovedInPip9Warning, RemovedInPip10Warning, Python26DeprecationWarning
]
class Python26DeprecationWarning(PipDeprecationWarning, Pending):
pass
# Warnings <-> Logging Integration
@ -53,15 +50,15 @@ def _showwarning(message, category, filename, lineno, file=None, line=None):
# want it to appear as if someone typed this entire message out.
log_message = "DEPRECATION: %s" % message
# Things that are DeprecationWarnings will be removed in the very
# next version of pip. We want these to be more obvious so we
# use the ERROR logging level while the PendingDeprecationWarnings
# are still have at least 2 versions to go until they are removed
# so they can just be warnings.
if issubclass(category, DeprecationWarning):
logger.error(log_message)
else:
# PipDeprecationWarnings that are Pending still have at least 2
# versions to go until they are removed so they can just be
# warnings. Otherwise, they will be removed in the very next
# version of pip. We want these to be more obvious so we use the
# ERROR logging level.
if issubclass(category, Pending):
logger.warning(log_message)
else:
logger.error(log_message)
else:
_warnings_showwarning(
message, category, filename, lineno, file, line,
@ -69,6 +66,9 @@ def _showwarning(message, category, filename, lineno, file=None, line=None):
def install_warning_logger():
# Enable our Deprecation Warnings
warnings.simplefilter("default", PipDeprecationWarning, append=True)
global _warnings_showwarning
if _warnings_showwarning is None:

View file

@ -0,0 +1,31 @@
import codecs
import locale
import re
BOMS = [
(codecs.BOM_UTF8, 'utf8'),
(codecs.BOM_UTF16, 'utf16'),
(codecs.BOM_UTF16_BE, 'utf16-be'),
(codecs.BOM_UTF16_LE, 'utf16-le'),
(codecs.BOM_UTF32, 'utf32'),
(codecs.BOM_UTF32_BE, 'utf32-be'),
(codecs.BOM_UTF32_LE, 'utf32-le'),
]
ENCODING_RE = re.compile(b'coding[:=]\s*([-\w.]+)')
def auto_decode(data):
"""Check a bytes string for a BOM to correctly detect the encoding
Fallback to locale.getpreferredencoding(False) like open() on Python3"""
for bom, encoding in BOMS:
if data.startswith(bom):
return data[len(bom):].decode(encoding)
# Lets check the first two lines as in PEP263
for line in data.split(b'\n')[:2]:
if line[0:1] == b'#' and ENCODING_RE.search(line):
encoding = ENCODING_RE.search(line).groups()[0].decode('ascii')
return data.decode(encoding)
return data.decode(locale.getpreferredencoding(False))

View file

@ -219,6 +219,11 @@ def hidden_cursor(file):
# even via colorama. So don't even try.
if WINDOWS:
yield
# We don't want to clutter the output with control characters if we're
# writing to a file, or if the user is running with --quiet.
# See https://github.com/pypa/pip/issues/3418
elif not file.isatty() or logger.getEffectiveLevel() > logging.INFO:
yield
else:
file.write(HIDE_CURSOR)
try: