From 87dd1579a25779751e4a41b9e9b25ba3e0fe4d5d Mon Sep 17 00:00:00 2001 From: Carl Meyer Date: Wed, 18 May 2011 10:26:45 -0500 Subject: [PATCH] Removed broken and no-longer-useful -E and PIP_RESPECT_VIRTUALENV options. --- docs/index.txt | 5 ----- docs/news.txt | 7 ++++++ pip/basecommand.py | 39 +++------------------------------- pip/baseparser.py | 29 ------------------------- pip/venv.py | 53 ---------------------------------------------- 5 files changed, 10 insertions(+), 123 deletions(-) delete mode 100644 pip/venv.py diff --git a/docs/index.txt b/docs/index.txt index 286bd7cdf..9fc98ad34 100644 --- a/docs/index.txt +++ b/docs/index.txt @@ -254,11 +254,6 @@ and to bail if not, use:: export PIP_REQUIRE_VIRTUALENV=true -To tell pip to automatically use the currently active virtualenv:: - - export PIP_RESPECT_VIRTUALENV=true - -Providing an environment with ``-E`` will be ignored. Using pip with virtualenvwrapper --------------------------------- diff --git a/docs/news.txt b/docs/news.txt index ecc7a8ad3..dc79ae7b4 100644 --- a/docs/news.txt +++ b/docs/news.txt @@ -6,6 +6,13 @@ Next release (1.1) schedule Beta release mid-July 2011, final release early August. +develop (unreleased) +-------------------- + +* Removed ``-E`` option and ``PIP_RESPECT_VIRTUALENV``; both use a + restart-in-venv mechanism that's broken, and neither one is useful since + every virtualenv now has pip inside it. + 1.0.1 (2011-04-30) ------------------ diff --git a/pip/basecommand.py b/pip/basecommand.py index 54fcdb5a8..643162f10 100644 --- a/pip/basecommand.py +++ b/pip/basecommand.py @@ -11,7 +11,6 @@ from pip.log import logger from pip.baseparser import parser, ConfigOptionParser, UpdatingDefaultsHelpFormatter from pip.download import urlopen from pip.exceptions import BadCommand, InstallationError, UninstallationError -from pip.venv import restart_in_venv from pip.backwardcompat import StringIO, urllib, urllib2, walk_packages __all__ = ['command_dict', 'Command', 'load_all_commands', @@ -45,8 +44,8 @@ class Command(object): def merge_options(self, initial_options, options): # Make sure we have all global options carried over - for attr in ['log', 'venv', 'proxy', 'venv_base', 'require_venv', - 'respect_venv', 'log_explicit_levels', 'log_file', + for attr in ['log', 'proxy', 'require_venv', + 'log_explicit_levels', 'log_file', 'timeout', 'default_vcs', 'skip_requirements_regex', 'no_input']: setattr(options, attr, getattr(initial_options, attr) or getattr(options, attr)) @@ -73,44 +72,12 @@ class Command(object): self.setup_logging() - if options.require_venv and not options.venv: + if options.require_venv: # If a venv is required check if it can really be found if not os.environ.get('VIRTUAL_ENV'): logger.fatal('Could not find an activated virtualenv (required).') sys.exit(3) - # Automatically install in currently activated venv if required - options.respect_venv = True - if args and args[-1] == '___VENV_RESTART___': - ## FIXME: We don't do anything this this value yet: - args = args[:-2] - options.venv = None - else: - # If given the option to respect the activated environment - # check if no venv is given as a command line parameter - if options.respect_venv and os.environ.get('VIRTUAL_ENV'): - if options.venv and os.path.exists(options.venv): - # Make sure command line venv and environmental are the same - if (os.path.realpath(os.path.expanduser(options.venv)) != - os.path.realpath(os.environ.get('VIRTUAL_ENV'))): - logger.fatal("Given virtualenv (%s) doesn't match " - "currently activated virtualenv (%s)." - % (options.venv, os.environ.get('VIRTUAL_ENV'))) - sys.exit(3) - else: - options.venv = os.environ.get('VIRTUAL_ENV') - logger.info('Using already activated environment %s' % options.venv) - if options.venv: - logger.info('Running in environment %s' % options.venv) - site_packages=False - if options.site_packages: - site_packages=True - restart_in_venv(options.venv, options.venv_base, site_packages, - complete_args) - # restart_in_venv should actually never return, but for clarity... - return - - ## FIXME: not sure if this sure come before or after venv restart if options.log: log_fp = open_logfile(options.log, 'a') logger.consumers.append((logger.DEBUG, log_fp)) diff --git a/pip/baseparser.py b/pip/baseparser.py index 5e4898530..6af54c7d4 100644 --- a/pip/baseparser.py +++ b/pip/baseparser.py @@ -122,27 +122,6 @@ parser.add_option( dest='help', action='store_true', help='Show help') -parser.add_option( - '-E', '--environment', - dest='venv', - metavar='DIR', - help='virtualenv environment to run pip in (either give the ' - 'interpreter or the environment base directory)') -parser.add_option( - '-s', '--enable-site-packages', - dest='site_packages', - action='store_true', - help='Include site-packages in virtualenv if one is to be ' - 'created. Ignored if --environment is not used or ' - 'the virtualenv already exists.') -parser.add_option( - # Defines a default root directory for virtualenvs, relative - # virtualenvs names/paths are considered relative to it. - '--virtualenv-base', - dest='venv_base', - type='str', - default='', - help=optparse.SUPPRESS_HELP) parser.add_option( # Run only if inside a virtualenv, bail if not. '--require-virtualenv', '--require-venv', @@ -150,14 +129,6 @@ parser.add_option( action='store_true', default=False, help=optparse.SUPPRESS_HELP) -parser.add_option( - # Use automatically an activated virtualenv instead of installing - # globally. -E will be ignored if used. - '--respect-virtualenv', '--respect-venv', - dest='respect_venv', - action='store_true', - default=False, - help=optparse.SUPPRESS_HELP) parser.add_option( '-v', '--verbose', diff --git a/pip/venv.py b/pip/venv.py deleted file mode 100644 index 88de4f6de..000000000 --- a/pip/venv.py +++ /dev/null @@ -1,53 +0,0 @@ -"""Tools for working with virtualenv environments""" - -import os -import sys -import subprocess -from pip.exceptions import BadCommand -from pip.log import logger - - -def restart_in_venv(venv, base, site_packages, args): - """ - Restart this script using the interpreter in the given virtual environment - """ - if base and not os.path.isabs(venv) and not venv.startswith('~'): - base = os.path.expanduser(base) - # ensure we have an abs basepath at this point: - # a relative one makes no sense (or does it?) - if os.path.isabs(base): - venv = os.path.join(base, venv) - - if venv.startswith('~'): - venv = os.path.expanduser(venv) - - if not os.path.exists(venv): - try: - import virtualenv - except ImportError: - print('The virtual environment does not exist: %s' % venv) - print('and virtualenv is not installed, so a new environment cannot be created') - sys.exit(3) - print('Creating new virtualenv environment in %s' % venv) - virtualenv.logger = logger - logger.indent += 2 - virtualenv.create_environment(venv, site_packages=site_packages) - if sys.platform == 'win32': - python = os.path.join(venv, 'Scripts', 'python.exe') - # check for bin directory which is used in buildouts - if not os.path.exists(python): - python = os.path.join(venv, 'bin', 'python.exe') - else: - python = os.path.join(venv, 'bin', 'python') - if not os.path.exists(python): - python = venv - if not os.path.exists(python): - raise BadCommand('Cannot find virtual environment interpreter at %s' % python) - base = os.path.dirname(os.path.dirname(python)) - file = os.path.join(os.path.dirname(__file__), 'runner.py') - if file.endswith('.pyc'): - file = file[:-1] - proc = subprocess.Popen( - [python, file] + args + [base, '___VENV_RESTART___']) - proc.wait() - sys.exit(proc.returncode)