Update tools/install_venv.py to work w/ latest pip

pip dropped the -E option as of 1.1; now to install in a virtualenv,
you just explicitly activate the virtualenv.  This commit fakes the
same behavior of explicitly specifying a virtualenv for installation
by altering tools/with_venv.sh to optionally take the -E flag

Fixes Bug #1081200

Change-Id: I470ba9563864337b8af2a79ae463e269ba66bf8f
This commit is contained in:
Nikhil Manchanda 2012-11-20 08:53:47 -08:00 committed by Aaron Crickenberger
parent f300b17621
commit 5e7757faa6
2 changed files with 32 additions and 5 deletions

5
tools/install_venv.py Normal file → Executable file
View File

@ -1,3 +1,4 @@
#!/usr/bin/env python
# vim: tabstop=4 shiftwidth=4 softtabstop=4
@ -102,10 +103,10 @@ def install_dependencies(venv=VENV):
print 'Installing dependencies with pip (this can take a while)...'
# Install greenlet by hand - just listing it in the requires file does not
# get it in stalled in the right order
run_command(['tools/with_venv.sh', 'pip', 'install', '-E', venv,
run_command(['tools/with_venv.sh', '-E', venv, 'pip', 'install',
'greenlet'], redirect_output=False)
for requires in (PIP_REQUIRES, TEST_REQUIRES):
run_command(['tools/with_venv.sh', 'pip', 'install', '-E', venv, '-r',
run_command(['tools/with_venv.sh', '-E', venv, 'pip', 'install', '-r',
requires], redirect_output=False)
# Tell the virtual env how to "import reddwarf"

View File

@ -1,4 +1,30 @@
#!/bin/bash
TOOLS=`dirname $0`
VENV=$TOOLS/../.venv
source $VENV/bin/activate && $@
set -e
me=${0##*/}
dir="$(dirname $0)"
function print_usage() {
cat >&2 <<EOS
Run commands in a default (or specific) virtualenv
Usage: $me [-E venv] commands
Options:
-h prints out this message
-E venv use this virtualenv (default: ${venv})
EOS
}
venv="${dir}/../.venv"
while getopts ":hE:" opt; do
case "$opt" in
h|\?) print_usage; exit 1 ;;
E) venv=$OPTARG ;;
esac
done
shift $((OPTIND-1))
source "${venv}/bin/activate" && $@