From 858389db7ccd057cedc50312f383cca6eb6486e1 Mon Sep 17 00:00:00 2001 From: Einst Crazy Date: Tue, 19 Jan 2016 04:07:41 +0000 Subject: [PATCH] Use tools_path/venv environment variables in install_venv In the run_tests.sh, it export tools_path/venv/venv_path. In the install_venv.sh, to get venv value in environ values. In the with_venv.sh, to get correct envirion values. Change-Id: Ia041937eaa8cf2194a929c846a7a96312a641ac5 Partial-Bug: #1535514 --- tools/install_venv.py | 11 +++++++++-- tools/with_venv.sh | 7 +++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/tools/install_venv.py b/tools/install_venv.py index f8fb8fa2916..a33664930e8 100644 --- a/tools/install_venv.py +++ b/tools/install_venv.py @@ -52,8 +52,15 @@ def print_help(): def main(argv): - root = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) - venv = os.path.join(root, '.venv') + if 'tools_path' in os.environ: + root = os.environ['tools_path'] + else: + root = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) + if 'venv' in os.environ: + venv = os.environ['venv'] + else: + venv = os.path.join(root, '.venv') + pip_requires = os.path.join(root, 'requirements.txt') test_requires = os.path.join(root, 'test-requirements.txt') py_version = "python%s.%s" % (sys.version_info[0], sys.version_info[1]) diff --git a/tools/with_venv.sh b/tools/with_venv.sh index 5fb07ea8ccb..8505e3ec519 100755 --- a/tools/with_venv.sh +++ b/tools/with_venv.sh @@ -14,6 +14,9 @@ # License for the specific language governing permissions and limitations # under the License. -TOOLS=`dirname $0` -VENV=$TOOLS/../.venv +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 && "$@"