diff options
| author | Jenkins <jenkins@review.openstack.org> | 2011-11-08 16:59:19 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2011-11-08 16:59:19 +0000 |
| commit | 2826e862d73d1b2cbe80da3385075cd6c33f511d (patch) | |
| tree | dd7157fd5c8aacf1fbc9b21a619d34c057fb864b | |
| parent | 00d4a56c0407459b7edea5e293c7e29cc296a6ae (diff) | |
| parent | b08bd96ce5bf290ac6198079ad2dce71e675b481 (diff) | |
| download | nova-2826e862d73d1b2cbe80da3385075cd6c33f511d.tar.gz nova-2826e862d73d1b2cbe80da3385075cd6c33f511d.tar.xz nova-2826e862d73d1b2cbe80da3385075cd6c33f511d.zip | |
Merge "Optional --no-site-packages in venv"
| -rwxr-xr-x | run_tests.sh | 12 | ||||
| -rw-r--r-- | tools/install_venv.py | 20 |
2 files changed, 27 insertions, 5 deletions
diff --git a/run_tests.sh b/run_tests.sh index 9a69195be..837f9695a 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -8,6 +8,7 @@ function usage { echo "" echo " -V, --virtual-env Always use virtualenv. Install automatically if not present" echo " -N, --no-virtual-env Don't use virtualenv. Run tests in local environment" + echo " -s, --no-site-packages Isolate the virtualenv from the global Python environment" echo " -r, --recreate-db Recreate the test database (deprecated, as this is now the default)." echo " -n, --no-recreate-db Don't recreate the test database." echo " -x, --stop Stop running tests after the first error or failure." @@ -29,6 +30,7 @@ function process_option { -h|--help) usage;; -V|--virtual-env) always_venv=1; never_venv=0;; -N|--no-virtual-env) always_venv=0; never_venv=1;; + -s|--no-site-packages) no_site_packages=1;; -r|--recreate-db) recreate_db=1;; -n|--no-recreate-db) recreate_db=0;; -f|--force) force=1;; @@ -45,6 +47,8 @@ with_venv=tools/with_venv.sh always_venv=0 never_venv=0 force=0 +no_site_packages=0 +installvenvopts= noseargs= noseopts= wrapper="" @@ -62,6 +66,10 @@ if [ $coverage -eq 1 ]; then noseopts="$noseopts --with-coverage --cover-package=nova" fi +if [ $no_site_packages -eq 1 ]; then + installvenvopts="--no-site-packages" +fi + function run_tests { # Just run the test suites in current environment ${wrapper} $NOSETESTS 2> run_tests.log @@ -123,14 +131,14 @@ then else if [ $always_venv -eq 1 ]; then # Automatically install the virtualenv - python tools/install_venv.py + python tools/install_venv.py $installvenvopts wrapper="${with_venv}" else echo -e "No virtual environment found...create one? (Y/n) \c" read use_ve if [ "x$use_ve" = "xY" -o "x$use_ve" = "x" -o "x$use_ve" = "xy" ]; then # Install the virtualenv and run the test suite in it - python tools/install_venv.py + python tools/install_venv.py $installvenvopts wrapper=${with_venv} fi fi diff --git a/tools/install_venv.py b/tools/install_venv.py index 2ecd446e6..67243fbf7 100644 --- a/tools/install_venv.py +++ b/tools/install_venv.py @@ -23,6 +23,7 @@ Installation script for Nova's development virtualenv """ +import optparse import os import subprocess import sys @@ -128,12 +129,15 @@ def check_dependencies(): get_distro().install_virtualenv() -def create_virtualenv(venv=VENV): +def create_virtualenv(venv=VENV, no_site_packages=True): """Creates the virtual environment and installs PIP only into the virtual environment """ print 'Creating venv...', - run_command(['virtualenv', '-q', VENV]) + if no_site_packages: + run_command(['virtualenv', '-q', '--no-site-packages', VENV]) + else: + run_command(['virtualenv', '-q', VENV]) print 'done.' print 'Installing pip in virtualenv...', if not run_command(['tools/with_venv.sh', 'easy_install', 'pip']).strip(): @@ -191,10 +195,20 @@ def print_help(): print help +def parse_args(): + """Parse command-line arguments""" + parser = optparse.OptionParser() + parser.add_option("-n", "--no-site-packages", dest="no_site_packages", + default=False, action="store_true", + help="Do not inherit packages from global Python install") + return parser.parse_args() + + def main(argv): + (options, args) = parse_args() check_python_version() check_dependencies() - create_virtualenv() + create_virtualenv(no_site_packages=options.no_site_packages) install_dependencies() print_help() |
