From 4c891b9243985bb95d8beff8affa9db470a1c94a Mon Sep 17 00:00:00 2001 From: Chet Burgess Date: Wed, 6 Feb 2013 04:36:34 +0000 Subject: support reloctable venv roots in testing framework run_tests.sh, with_venv.sh, and the install_venv.py scripts now support relocating the venv root to another location. All 3 scripts now support new envinroment variables to configure the location of the venv and the tools directory. To maintain compatability the defaults are set to the current values. venv_path = Location of the virtualenv directory Default: $(pwd) venv_name = Name of the virtualenv directory Default: .venv tools_path = Location of the tools directory Default: $(pwd) Additionally the run_tests.sh script also takes these value as arguments and will pass them along accordingly. --virtual-env-path Location of the virtualenv directory Default: $(pwd) --virtual-env-name Name of the virtualenv directory Default: .venv --tools-path Location of the tools directory Default: $(pwd) DocImpact Change-Id: I1be036058227206ecca342f692cd3d6aadb24069 Fixes: bug #1116942 --- tools/install_venv.py | 16 +++++++++++----- tools/with_venv.sh | 9 ++++++--- 2 files changed, 17 insertions(+), 8 deletions(-) (limited to 'tools') diff --git a/tools/install_venv.py b/tools/install_venv.py index 60f4894ed..ce5c17fab 100644 --- a/tools/install_venv.py +++ b/tools/install_venv.py @@ -28,7 +28,7 @@ os.sys.path.insert(0, parentdir) import install_venv_common as install_venv -def print_help(): +def print_help(venv, root): help = """ Nova development environment setup is complete. @@ -38,21 +38,27 @@ def print_help(): To activate the Nova virtualenv for the extent of your current shell session you can run: - $ source .venv/bin/activate + $ source %s/bin/activate Or, if you prefer, you can run commands in the virtualenv on a case by case basis by running: - $ tools/with_venv.sh + $ %s/tools/with_venv.sh Also, make test will automatically use the virtualenv. """ - print help + print help % (venv, root) def main(argv): root = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) + + if os.environ.get('tools_path'): + root = os.environ['tools_path'] venv = os.path.join(root, '.venv') + if os.environ.get('venv'): + venv = os.environ['venv'] + pip_requires = os.path.join(root, 'tools', 'pip-requires') test_requires = os.path.join(root, 'tools', 'test-requires') py_version = "python%s.%s" % (sys.version_info[0], sys.version_info[1]) @@ -65,7 +71,7 @@ def main(argv): install.create_virtualenv(no_site_packages=options.no_site_packages) install.install_dependencies() install.post_process() - print_help() + print_help(venv, root) if __name__ == '__main__': main(sys.argv) diff --git a/tools/with_venv.sh b/tools/with_venv.sh index 550c4774e..94e05c127 100755 --- a/tools/with_venv.sh +++ b/tools/with_venv.sh @@ -1,4 +1,7 @@ #!/bin/bash -TOOLS=`dirname $0` -VENV=$TOOLS/../.venv -source $VENV/bin/activate && "$@" +tools_path=${tools_path:-$(dirname $0)} +venv_path=${venv_path:-${tools_path}} +venv_dir=${venv_name:-/../.venv} +TOOLS=${tools_path} +VENV=${venv:-${venv_path}/${venv_dir}} +source ${VENV}/bin/activate && "$@" -- cgit