Sync venv scripts from oslo-incubator
Currently install_venv.py and with_venv.sh create virtual
environment in .venv directory and there is no way to specify
the virtual environment path explicitly.
This has been fixed in oslo-incubator.
This patch sync those virtual environment scripts from oslo-incubator.
Also make run_test.sh and run_tempest.sh scripts to use 'VENV' env variable.
Change-Id: I55311cff4dea1f6c5adaa2a6d51eeee2f6cc71ea
Closes-Bug: 1370086
diff --git a/openstack-common.conf b/openstack-common.conf
index 1920295..16ba6a7 100644
--- a/openstack-common.conf
+++ b/openstack-common.conf
@@ -3,6 +3,8 @@
# The list of modules to copy from openstack-common
module=install_venv_common
module=versionutils
+module=with_venv
+module=install_venv
# The base module to hold the copy of openstack.common
base=tempest
diff --git a/run_tempest.sh b/run_tempest.sh
index 5a9b742..0f32045 100755
--- a/run_tempest.sh
+++ b/run_tempest.sh
@@ -20,7 +20,7 @@
}
testrargs=""
-venv=.venv
+venv=${VENV:-.venv}
with_venv=tools/with_venv.sh
serial=0
always_venv=0
diff --git a/run_tests.sh b/run_tests.sh
index 971f89b..9a158e4 100755
--- a/run_tests.sh
+++ b/run_tests.sh
@@ -19,7 +19,7 @@
testrargs=""
just_pep8=0
-venv=.venv
+venv=${VENV:-.venv}
with_venv=tools/with_venv.sh
serial=0
always_venv=0
diff --git a/tools/install_venv.py b/tools/install_venv.py
index 96b8279..d6d9c8e 100644
--- a/tools/install_venv.py
+++ b/tools/install_venv.py
@@ -48,11 +48,11 @@
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']
+ 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']
+ if os.environ.get('VENV'):
+ venv = os.environ['VENV']
pip_requires = os.path.join(root, 'requirements.txt')
test_requires = os.path.join(root, 'test-requirements.txt')
diff --git a/tools/install_venv_common.py b/tools/install_venv_common.py
index 743b59d..e279159 100644
--- a/tools/install_venv_common.py
+++ b/tools/install_venv_common.py
@@ -101,6 +101,7 @@
print('done.')
else:
print("venv already exists...")
+ pass
def pip_install(self, *args):
self.run_command(['tools/with_venv.sh',
@@ -124,7 +125,7 @@
parser.add_option('-n', '--no-site-packages',
action='store_true',
help="Do not inherit packages from global Python "
- "install")
+ "install.")
return parser.parse_args(argv[1:])[0]
diff --git a/tools/with_venv.sh b/tools/with_venv.sh
index 550c477..165c883 100755
--- a/tools/with_venv.sh
+++ b/tools/with_venv.sh
@@ -1,4 +1,6 @@
#!/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_DIR:-/.venv}
+VENV=${VENV:-${VENV_PATH}/${VENV_DIR}}
+source ${VENV}/bin/activate && "$@"