summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/changes.rst16
-rw-r--r--setup.py9
-rwxr-xr-xvirtualenv.py151
-rw-r--r--virtualenv_support/pip-8.1.0-py2.py3-none-any.whl (renamed from virtualenv_support/pip-8.0.2-py2.py3-none-any.whl)bin1188805 -> 1197452 bytes
-rw-r--r--virtualenv_support/setuptools-20.2.2-py2.py3-none-any.whl (renamed from virtualenv_support/setuptools-20.0-py2.py3-none-any.whl)bin472174 -> 508508 bytes
5 files changed, 96 insertions, 80 deletions
diff --git a/docs/changes.rst b/docs/changes.rst
index e2a027b..e8d7bb4 100644
--- a/docs/changes.rst
+++ b/docs/changes.rst
@@ -1,6 +1,20 @@
Release History
===============
+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)
-------------------
@@ -80,7 +94,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`
diff --git a/setup.py b/setup.py
index 71261e0..ee03bc5 100644
--- a/setup.py
+++ b/setup.py
@@ -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):
diff --git a/virtualenv.py b/virtualenv.py
index 0b4a94d..68a5d87 100755
--- a/virtualenv.py
+++ b/virtualenv.py
@@ -27,6 +27,7 @@ import struct
import subprocess
import pkgutil
import tempfile
+import textwrap
from distutils.util import strtobool
from os.path import join
@@ -35,7 +36,7 @@ try:
except ImportError:
import configparser as ConfigParser
-__version__ = "14.0.6"
+__version__ = "15.0.0"
virtualenv_version = __version__ # legacy
if sys.version_info < (2, 6):
@@ -353,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)
@@ -709,7 +707,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:
@@ -739,7 +737,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]
@@ -748,6 +748,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()
@@ -771,7 +775,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:
@@ -839,48 +843,56 @@ 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)
- sys.path = pythonpath.split(os.pathsep) + sys.path
- cert_data = pkgutil.get_data("pip._vendor.requests", "cacert.pem")
+ SCRIPT = textwrap.dedent("""
+ import sys
+ import pkgutil
+ import tempfile
+ import os
- if cert_data is not None:
- cert_file = tempfile.NamedTemporaryFile(delete=False)
- cert_file.write(cert_data)
- cert_file.close()
- else:
- cert_file = None
+ import pip
- try:
- cmd = [
- py_executable, '-c',
- 'import sys, pip; sys.exit(pip.main(["install", "--ignore-installed"] + sys.argv[1:]))',
- ] + project_names
- logger.start_progress('Installing %s...' % (', '.join(project_names)))
- logger.indent += 2
-
- env = {
- "PYTHONPATH": pythonpath,
- "JYTHONPATH": pythonpath, # for Jython < 3.x
- "PIP_FIND_LINKS": findlinks,
- "PIP_USE_WHEEL": "1",
- "PIP_ONLY_BINARY": ":all:",
- "PIP_PRE": "1",
- "PIP_USER": "0",
- }
-
- if not download:
- env["PIP_NO_INDEX"] = "1"
-
- if cert_file is not None:
- env["PIP_CERT"] = cert_file.name
+ 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:
- call_subprocess(cmd, show_stdout=False, extra_env=env)
+ 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:
- logger.indent -= 2
- logger.end_progress()
+ 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
+
+ env = {
+ "PYTHONPATH": pythonpath,
+ "JYTHONPATH": pythonpath, # for Jython < 3.x
+ "PIP_FIND_LINKS": findlinks,
+ "PIP_USE_WHEEL": "1",
+ "PIP_ONLY_BINARY": ":all:",
+ "PIP_PRE": "1",
+ "PIP_USER": "0",
+ }
+
+ if not download:
+ env["PIP_NO_INDEX"] = "1"
+
+ try:
+ call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=SCRIPT)
finally:
- if cert_file is not None:
- os.remove(cert_file.name)
+ logger.indent -= 2
+ logger.end_progress()
def create_environment(home_dir, site_packages=False, clear=False,
@@ -1583,16 +1595,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
@@ -1611,9 +1621,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."
@@ -1660,9 +1670,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 ')
@@ -1677,22 +1686,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):
"""
@@ -1775,9 +1781,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'
@@ -2297,7 +2302,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__':
diff --git a/virtualenv_support/pip-8.0.2-py2.py3-none-any.whl b/virtualenv_support/pip-8.1.0-py2.py3-none-any.whl
index cff6237..9a2691b 100644
--- a/virtualenv_support/pip-8.0.2-py2.py3-none-any.whl
+++ b/virtualenv_support/pip-8.1.0-py2.py3-none-any.whl
Binary files differ
diff --git a/virtualenv_support/setuptools-20.0-py2.py3-none-any.whl b/virtualenv_support/setuptools-20.2.2-py2.py3-none-any.whl
index fb13052..89cf840 100644
--- a/virtualenv_support/setuptools-20.0-py2.py3-none-any.whl
+++ b/virtualenv_support/setuptools-20.2.2-py2.py3-none-any.whl
Binary files differ