Bug 1259551 - Upgrade vendored virtualenv to 15.0.1; r=ted

While we're addressing virtualenv foo, let's ensure we are running
the latest version. This also pulls in newer versions of pip (8.1.1),
setuptools (20.3), and wheel (0.29.0).

MozReview-Commit-ID: G5uSy66Kd6u
This commit is contained in:
Gregory Szorc
2016-03-24 12:21:55 -07:00
parent 78c6e963f3
commit a52263493c
14 changed files with 244 additions and 112 deletions

View File

@@ -1,6 +1,6 @@
Copyright (c) 2007 Ian Bicking and Contributors
Copyright (c) 2009 Ian Bicking, The Open Planning Project
Copyright (c) 2011-2015 The virtualenv developers
Copyright (c) 2011-2016 The virtualenv developers
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the

View File

@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: virtualenv
Version: 14.0.1
Version: 15.0.1
Summary: Virtual Python Environment builder
Home-page: https://virtualenv.pypa.io/
Author: Jannis Leidel, Carl Meyer and Brian Rosner
@@ -47,54 +47,29 @@ Description: Virtualenv
Release History
===============
14.0.1 (2016-01-21)
15.0.1 (2016-03-17)
-------------------
* Upgrade from pip 8.0.0 to 8.0.2.
* Print error message when DEST_DIR exists and is a file
* Fix the default of ``--(no-)download`` to default to downloading.
* Upgrade setuptools to 20.3
* Upgrade pip to 8.1.1.
14.0.0 (2016-01-19)
15.0.0 (2016-03-05)
-------------------
* **BACKWARDS INCOMPATIBLE** Drop support for Python 3.2.
* Remove the `virtualenv-N.N` script from the package; this can no longer be
correctly created from a wheel installation.
Resolves #851, #692
* Upgrade setuptools to 19.4
* Remove accidental runtime dependency on pip by extracting certificate in the
subprocess.
* Upgrade wheel to 0.26.0
* Upgrade setuptools 20.2.2.
* Upgrade pip to 8.0.0
* Upgrade argparse to 1.4.0
* Added support for ``python-config`` script (PR #798)
* Updated activate.fish (PR #589) (PR #799)
* Account for a ``site.pyo`` correctly in some python implementations (PR #759)
* Properly restore an empty PS1 (#407)
* Properly remove ``pydoc`` when deactivating
* Remove workaround for very old Mageia / Mandriva linuxes (PR #472)
* Added a space after virtualenv name in the prompt: ``(env) $PS1``
* Make sure not to run a --user install when creating the virtualenv (PR #803)
* Remove virtualenv file's path from directory when executing with a new
python. Fixes issue #779, #763 (PR #805)
* Remove use of () in .bat files so ``Program Files (x86)`` works #35
* Download new releases of the preinstalled software from PyPI when there are
new releases available. This behavior can be disabled using
``--no-download``.
* Make ``--no-setuptools``, ``--no-pip``, and ``--no-wheel`` independent of
each other.
* Upgrade pip to 8.1.0.
`Full Changelog <https://virtualenv.pypa.io/en/latest/changes.html>`_.
@@ -107,7 +82,6 @@ Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.1
Classifier: Programming Language :: Python :: 3.2
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5

View File

@@ -1,13 +1,24 @@
virtualenv
==========
A tool for creating isolated 'virtual' python environments.
.. image:: https://img.shields.io/pypi/v/virtualenv.svg
:target: https://pypi.python.org/pypi/virtualenv
.. image:: https://img.shields.io/travis/pypa/virtualenv/develop.svg
:target: http://travis-ci.org/pypa/virtualenv
For documentation, see https://virtualenv.pypa.io/
* `Installation <https://virtualenv.pypa.io/en/latest/installation.html>`_
* `Documentation <https://virtualenv.pypa.io/>`_
* `Changelog <https://virtualenv.pypa.io/en/latest/changes.html>`_
* `Issues <https://github.com/pypa/virtualenv/issues>`_
* `PyPI <https://pypi.python.org/pypi/virtualenv/>`_
* `Github <https://github.com/pypa/virtualenv>`_
* `User mailing list <http://groups.google.com/group/python-virtualenv>`_
* `Dev mailing list <http://groups.google.com/group/pypa-dev>`_
* User IRC: #pypa on Freenode.
* Dev IRC: #pypa-dev on Freenode.
Code of Conduct

View File

@@ -1,6 +1,73 @@
Release History
===============
15.0.1 (2016-03-17)
-------------------
* Print error message when DEST_DIR exists and is a file
* Upgrade setuptools to 20.3
* Upgrade pip to 8.1.1.
15.0.0 (2016-03-05)
-------------------
* Remove the `virtualenv-N.N` script from the package; this can no longer be
correctly created from a wheel installation.
Resolves :issue:`851`, :issue:`692`
* Remove accidental runtime dependency on pip by extracting certificate in the
subprocess.
* Upgrade setuptools 20.2.2.
* Upgrade pip to 8.1.0.
14.0.6 (2016-02-07)
-------------------
* Upgrade setuptools to 20.0
* Upgrade wheel to 0.29.0
* Fix an error where virtualenv didn't pass in a working ssl certificate for
pip, causing "weird" errors related to ssl.
14.0.5 (2016-02-01)
-------------------
* Homogenize drive letter casing for both prefixes and filenames. :issue:`858`
14.0.4 (2016-01-31)
-------------------
* Upgrade setuptools to 19.6.2
* Revert ac4ea65; only correct drive letter case.
Fixes :issue:`856`, :issue:`815`
14.0.3 (2016-01-28)
-------------------
* Upgrade setuptools to 19.6.1
14.0.2 (2016-01-28)
-------------------
* Upgrade setuptools to 19.6
* Supress any errors from `unset` on different shells (:pull:`843`)
* Normalize letter case for prefix path checking. Fixes :issue:`837`
14.0.1 (2016-01-21)
-------------------
@@ -38,7 +105,7 @@ Release History
* Make sure not to run a --user install when creating the virtualenv (:pull:`803`)
* Remove virtualenv file's path from directory when executing with a new
* Remove virtualenv.py's path from sys.path when executing with a new
python. Fixes issue :issue:`779`, :issue:`763` (:pull:`805`)
* Remove use of () in .bat files so ``Program Files (x86)`` works :issue:`35`
@@ -56,6 +123,7 @@ Release History
* Upgrade pip to 7.1.2.
13.1.1 (2015-08-20)
-------------------
@@ -65,6 +133,7 @@ Release History
* Make the activate script safe to use when bash is running with ``-u``.
13.1.0 (2015-06-30)
-------------------

View File

@@ -45,7 +45,9 @@ On Posix systems, this resides in :file:`/ENV/bin/`, so you can run::
$ source bin/activate
For some shells (e.g. the original Bourne Shell) you may need to use the
:command:`.` command, when :command:`source` does not exist.
:command:`.` command, when :command:`source` does not exist. There are also
separate activate files for some other shells, like csh and fish.
:file:`bin/activate` should work for bash/zsh/dash.
This will change your ``$PATH`` so its first entry is the virtualenv's
``bin/`` directory. (You have to use ``source`` because it changes your

View File

@@ -1,8 +1,8 @@
[wheel]
[bdist_wheel]
universal = 1
[egg_info]
tag_svn_revision = 0
tag_date = 0
tag_build =
tag_svn_revision = 0

View File

@@ -29,10 +29,7 @@ try:
setup_params = {
'entry_points': {
'console_scripts': [
'virtualenv=virtualenv:main',
'virtualenv-%s.%s=virtualenv:main' % sys.version_info[:2]
],
'console_scripts': ['virtualenv=virtualenv:main'],
},
'zip_safe': False,
'cmdclass': {'test': PyTest},
@@ -46,9 +43,7 @@ except ImportError:
setup_params = {}
else:
script = 'scripts/virtualenv'
script_ver = script + '-%s.%s' % sys.version_info[:2]
shutil.copy(script, script_ver)
setup_params = {'scripts': [script, script_ver]}
setup_params = {'scripts': [script]}
def read_file(*paths):
@@ -111,10 +106,9 @@ setup(
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.1',
'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
],
keywords='setuptools deployment installation distutils',
author='Ian Bicking',

View File

@@ -0,0 +1,44 @@
import sys
import subprocess
import virtualenv
import pytest
VIRTUALENV_SCRIPT = virtualenv.__file__
def test_commandline_basic(tmpdir):
"""Simple command line usage should work"""
subprocess.check_call([
sys.executable,
VIRTUALENV_SCRIPT,
str(tmpdir.join('venv'))
])
def test_commandline_explicit_interp(tmpdir):
"""Specifying the Python interpreter should work"""
subprocess.check_call([
sys.executable,
VIRTUALENV_SCRIPT,
'-p', sys.executable,
str(tmpdir.join('venv'))
])
# The registry lookups to support the abbreviated "-p 3.5" form of specifying
# a Python interpreter on Windows don't seem to work with Python 3.5. The
# registry layout is not well documented, and it's not clear that the feature
# is sufficiently widely used to be worth fixing.
# See https://github.com/pypa/virtualenv/issues/864
@pytest.mark.skipif("sys.platform == 'win32' and sys.version_info[:2] >= (3,5)")
def test_commandline_abbrev_interp(tmpdir):
"""Specifying abbreviated forms of the Python interpreter should work"""
if sys.platform == 'win32':
fmt = '%s.%s'
else:
fmt = 'python%s.%s'
abbrev = fmt % (sys.version_info[0], sys.version_info[1])
subprocess.check_call([
sys.executable,
VIRTUALENV_SCRIPT,
'-p', abbrev,
str(tmpdir.join('venv'))
])

View File

@@ -25,6 +25,9 @@ import glob
import distutils.sysconfig
import struct
import subprocess
import pkgutil
import tempfile
import textwrap
from distutils.util import strtobool
from os.path import join
@@ -33,7 +36,7 @@ try:
except ImportError:
import configparser as ConfigParser
__version__ = "14.0.1"
__version__ = "15.0.1"
virtualenv_version = __version__ # legacy
if sys.version_info < (2, 6):
@@ -351,22 +354,19 @@ def copyfile(src, dest, symlink=True):
def writefile(dest, content, overwrite=True):
if not os.path.exists(dest):
logger.info('Writing %s', dest)
f = open(dest, 'wb')
f.write(content.encode('utf-8'))
f.close()
with open(dest, 'wb') as f:
f.write(content.encode('utf-8'))
return
else:
f = open(dest, 'rb')
c = f.read()
f.close()
with open(dest, 'rb') as f:
c = f.read()
if c != content.encode("utf-8"):
if not overwrite:
logger.notify('File %s exists with different content; not overwriting', dest)
return
logger.notify('Overwriting %s with new content', dest)
f = open(dest, 'wb')
f.write(content.encode('utf-8'))
f.close()
with open(dest, 'wb') as f:
f.write(content.encode('utf-8'))
else:
logger.info('Content %s already in place', dest)
@@ -677,6 +677,11 @@ def main():
home_dir = args[0]
if os.path.exists(home_dir) and os.path.isfile(home_dir):
logger.fatal('ERROR: File already exists and is not a directory.')
logger.fatal('Please provide a different path or delete the file.')
sys.exit(3)
if os.environ.get('WORKING_ENV'):
logger.fatal('ERROR: you cannot run virtualenv while in a workingenv')
logger.fatal('Please deactivate your workingenv, then re-run this script')
@@ -707,7 +712,7 @@ def main():
def call_subprocess(cmd, show_stdout=True,
filter_stdout=None, cwd=None,
raise_on_returncode=True, extra_env=None,
remove_from_env=None):
remove_from_env=None, stdin=None):
cmd_parts = []
for part in cmd:
if len(part) > 45:
@@ -737,7 +742,9 @@ def call_subprocess(cmd, show_stdout=True,
env = None
try:
proc = subprocess.Popen(
cmd, stderr=subprocess.STDOUT, stdin=None, stdout=stdout,
cmd, stderr=subprocess.STDOUT,
stdin=None if stdin is None else subprocess.PIPE,
stdout=stdout,
cwd=cwd, env=env)
except Exception:
e = sys.exc_info()[1]
@@ -746,6 +753,10 @@ def call_subprocess(cmd, show_stdout=True,
raise
all_output = []
if stdout is not None:
if stdin is not None:
proc.stdin.write(stdin)
proc.stdin.close()
stdout = proc.stdout
encoding = sys.getdefaultencoding()
fs_encoding = sys.getfilesystemencoding()
@@ -769,7 +780,7 @@ def call_subprocess(cmd, show_stdout=True,
else:
logger.info(line)
else:
proc.communicate()
proc.communicate(stdin)
proc.wait()
if proc.returncode:
if raise_on_returncode:
@@ -837,10 +848,35 @@ def install_wheel(project_names, py_executable, search_dirs=None,
return urljoin('file:', pathname2url(os.path.abspath(p)))
findlinks = ' '.join(space_path2url(d) for d in search_dirs)
cmd = [
py_executable, '-c',
'import sys, pip; sys.exit(pip.main(["install", "--ignore-installed"] + sys.argv[1:]))',
] + project_names
SCRIPT = textwrap.dedent("""
import sys
import pkgutil
import tempfile
import os
import pip
cert_data = pkgutil.get_data("pip._vendor.requests", "cacert.pem")
if cert_data is not None:
cert_file = tempfile.NamedTemporaryFile(delete=False)
cert_file.write(cert_data)
cert_file.close()
else:
cert_file = None
try:
args = ["install", "--ignore-installed"]
if cert_file is not None:
args += ["--cert", cert_file.name]
args += sys.argv[1:]
sys.exit(pip.main(args))
finally:
if cert_file is not None:
os.remove(cert_file.name)
""").encode("utf8")
cmd = [py_executable, '-'] + project_names
logger.start_progress('Installing %s...' % (', '.join(project_names)))
logger.indent += 2
@@ -858,11 +894,12 @@ def install_wheel(project_names, py_executable, search_dirs=None,
env["PIP_NO_INDEX"] = "1"
try:
call_subprocess(cmd, show_stdout=False, extra_env=env)
call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=SCRIPT)
finally:
logger.indent -= 2
logger.end_progress()
def create_environment(home_dir, site_packages=False, clear=False,
unzip_setuptools=False,
prompt=None, search_dirs=None, download=False,
@@ -978,6 +1015,12 @@ def change_prefix(filename, dst_prefix):
# Check longer prefixes first so we don't split in the middle of a filename
prefixes = sorted(prefixes, key=len, reverse=True)
filename = os.path.abspath(filename)
# On Windows, make sure drive letter is uppercase
if is_win and filename[0] in 'abcdefghijklmnopqrstuvwxyz':
filename = filename[0].upper() + filename[1:]
for i, prefix in enumerate(prefixes):
if is_win and prefix[0] in 'abcdefghijklmnopqrstuvwxyz':
prefixes[i] = prefix[0].upper() + prefix[1:]
for src_prefix in prefixes:
if filename.startswith(src_prefix):
_, relpath = filename.split(src_prefix, 1)
@@ -1557,16 +1600,14 @@ def fixup_scripts(home_dir, bin_dir):
if not os.path.isfile(filename):
# ignore subdirs, e.g. .svn ones.
continue
f = open(filename, 'rb')
try:
lines = None
with open(filename, 'rb') as f:
try:
lines = f.read().decode('utf-8').splitlines()
except UnicodeDecodeError:
# This is probably a binary program instead
# of a script, so just ignore it.
continue
finally:
f.close()
if not lines:
logger.warn('Script %s is an empty file' % filename)
continue
@@ -1585,9 +1626,9 @@ def fixup_scripts(home_dir, bin_dir):
continue
logger.notify('Making script %s relative' % filename)
script = relative_script([new_shebang] + lines[1:])
f = open(filename, 'wb')
f.write('\n'.join(script).encode('utf-8'))
f.close()
with open(filename, 'wb') as f:
f.write('\n'.join(script).encode('utf-8'))
def relative_script(lines):
"Return a script that'll work in a relocatable environment."
@@ -1634,9 +1675,8 @@ def fixup_pth_and_egg_link(home_dir, sys_path=None):
def fixup_pth_file(filename):
lines = []
prev_lines = []
f = open(filename)
prev_lines = f.readlines()
f.close()
with open(filename) as f:
prev_lines = f.readlines()
for line in prev_lines:
line = line.strip()
if (not line or line.startswith('#') or line.startswith('import ')
@@ -1651,22 +1691,19 @@ def fixup_pth_file(filename):
logger.info('No changes to .pth file %s' % filename)
return
logger.notify('Making paths in .pth file %s relative' % filename)
f = open(filename, 'w')
f.write('\n'.join(lines) + '\n')
f.close()
with open(filename, 'w') as f:
f.write('\n'.join(lines) + '\n')
def fixup_egg_link(filename):
f = open(filename)
link = f.readline().strip()
f.close()
with open(filename) as f:
link = f.readline().strip()
if os.path.abspath(link) != link:
logger.debug('Link in %s already relative' % filename)
return
new_link = make_relative_path(filename, link)
logger.notify('Rewriting link %s in %s as %s' % (link, filename, new_link))
f = open(filename, 'w')
f.write(new_link)
f.close()
with open(filename, 'w') as f:
f.write(new_link)
def make_relative_path(source, dest, dest_is_directory=True):
"""
@@ -1749,9 +1786,8 @@ def create_bootstrap_script(extra_text, python_version=''):
filename = __file__
if filename.endswith('.pyc'):
filename = filename[:-1]
f = codecs.open(filename, 'r', encoding='utf-8')
content = f.read()
f.close()
with codecs.open(filename, 'r', encoding='utf-8') as f:
content = f.read()
py_exe = 'python%s' % python_version
content = (('#!/usr/bin/env %s\n' % py_exe)
+ '## WARNING: This file is generated\n'
@@ -1911,20 +1947,20 @@ AVijEPwfucjncQ==
##file activate.sh
ACTIVATE_SH = convert("""
eJytVdtu2kAQffdXDAalSVqK6GMrqhIFCaQEIkyp2qZyFnuIVzVrtLsmIZd/76wvYONAHxI/gHdn
dvbMnDPjOkwCrmDOQ4RFrDTMEGKFPtxxHYCtolh6CDMuWszTfMU02nA6l9ECZkwFp1Yd1lEMHhMi
0iBjAVyDzyV6Olxblo/5KTg+gUcL6ImFQg3NOSzXfuRZyV4dJJrdKPQBxYrLSCxQaFgxydksRJV5
1eA3NB+g8Tjtjt+7z/CHzulYCgVaxgh8DmQAysdHL2SS0mAaWBgmx8manbcbj+7o4tydDsaT790L
96o76VM4m+J9AR2gSPzNYywdu1HxtjceeL+MpE4cN3tpipVDiX3O/wfm56Q/GvZHl709kDb2CrCN
pQpvYzoIsuxFULO6JxpRQRQTPz5qYjehH5jw4UEFH+Au4F4AAVshMPojkxctFsasA6LAKCsLRfry
iBGiRkdwSwhIMPQ2j6RZLBlJMDuqPgL8IBVGsc7MmovbLEzJ0RQIGqbE4A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5/zlT6fvTntjZzAaNl9rQ5JkU5KIc0GX
inagwU57T2eddqWlTrvaS6d9sImZeUMkhWysveF0m37NcGub9Dpgi0j4qGiOzATjDr06OBjOYQOo
7RBoGtNm9Denv1i0LVI7lxJDXLHSSBeWRflsyyqw7diuW3h0XdvK6lBMyaoMG1UyHdTsoYBuue75
YOgOu1c91/2cwYpznPPeDoQpGL2xSm09NKp7BsvQ2hnT3aMs07lUnskpxewvBk73/LLnXo9HV9eT
ijB3hWBO2ygoiWg/bKuZxqCCQq0DD3vkWIVvI2KosIw+vqW1gIItEG5KJb+xb09g65ktwYKgTc51
uGJ/EFQs0ayEWLCQM5V9N4g+1+8UbXOJzF8bqhKtIqIwicWvzNFROZJlpfD8A7Vc044R0FxkcezG
VzsV75usvTdYef+57v5n1b225qhXfwEmxHEs
""")
##file activate.fish
@@ -2271,7 +2307,9 @@ def mach_o_change(path, what, value):
do_macho(file, 64, LITTLE_ENDIAN)
assert(len(what) >= len(value))
do_file(open(path, 'r+b'))
with open(path, 'r+b') as f:
do_file(f)
if __name__ == '__main__':

View File

@@ -2,7 +2,7 @@
# you cannot run it directly
deactivate () {
unset -f pydoc
unset -f pydoc >/dev/null 2>&1
# reset old environment variables
# ! [ -z ${VAR+_} ] returns true if VAR is declared at all