diff options
author | Lidi Zheng <scallopsky@gmail.com> | 2018-11-09 15:30:24 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-09 15:30:24 -0800 |
commit | 6a368df7ab746c973d41cf0b53494577ee1874f3 (patch) | |
tree | cadd8e3d72ee8f0822e584b4b47c724604e0cbb8 | |
parent | 2b568d2027091f9aa2858db98f128dbf5ae60330 (diff) | |
parent | c6471a7f858da25a3d730a382e73757504055a31 (diff) |
Merge pull request #17150 from lidizheng/enable-virtualenv-tests
Fix gRPC python tests failing under `virtualenv`
-rwxr-xr-x | tools/run_tests/helper_scripts/build_python.sh | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/tools/run_tests/helper_scripts/build_python.sh b/tools/run_tests/helper_scripts/build_python.sh index 4c94c4c6d2..8394f07e51 100755 --- a/tools/run_tests/helper_scripts/build_python.sh +++ b/tools/run_tests/helper_scripts/build_python.sh @@ -56,6 +56,12 @@ function is_linux() { fi } +function inside_venv() { + if [[ -n "${VIRTUAL_ENV}" ]]; then + echo true + fi +} + # Associated virtual environment name for the given python command. function venv() { $1 -c "import sys; print('py{}{}'.format(*sys.version_info[:2]))" @@ -134,10 +140,14 @@ fi # Perform build operations # ############################ -# Instantiate the virtualenv from the Python version passed in. -$PYTHON -m pip install --user virtualenv -$PYTHON -m virtualenv "$VENV" -VENV_PYTHON=$(script_realpath "$VENV/$VENV_RELATIVE_PYTHON") +if [[ "$(inside_venv)" ]]; then + VENV_PYTHON="$PYTHON" +else + # Instantiate the virtualenv from the Python version passed in. + $PYTHON -m pip install --user virtualenv + $PYTHON -m virtualenv "$VENV" + VENV_PYTHON=$(script_realpath "$VENV/$VENV_RELATIVE_PYTHON") +fi # See https://github.com/grpc/grpc/issues/14815 for more context. We cannot rely # on pip to upgrade itself because if pip is too old, it may not have the required |