aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/run_tests
diff options
context:
space:
mode:
authorGravatar Masood Malekghassemi <atash@google.com>2016-06-13 19:22:43 -0700
committerGravatar Masood Malekghassemi <atash@google.com>2016-07-01 10:18:46 -0700
commit0bd13ed8d0ee0f5600b0b8d05907e86d24a7ab1b (patch)
tree7fdebdd8d7b188c7d92ce0239419149b5bfd86df /tools/run_tests
parent6db60b9041ce8d7bf33254d2daa87ccafd493498 (diff)
Fall back to default python for test virtualenvs
Diffstat (limited to 'tools/run_tests')
-rwxr-xr-xtools/run_tests/build_python.sh14
1 files changed, 13 insertions, 1 deletions
diff --git a/tools/run_tests/build_python.sh b/tools/run_tests/build_python.sh
index 9d2813fa19..1ad928f2da 100755
--- a/tools/run_tests/build_python.sh
+++ b/tools/run_tests/build_python.sh
@@ -33,6 +33,7 @@ set -ex
# change to grpc repo root
cd $(dirname $0)/../..
+# Arguments
PYTHON=${1:-python2.7}
VENV=${2:-py27}
VENV_RELATIVE_PYTHON=${3:-bin/python}
@@ -42,6 +43,10 @@ ROOT=`pwd`
export CFLAGS="-I$ROOT/include -std=gnu99 -fno-wrapv"
export GRPC_PYTHON_BUILD_WITH_CYTHON=1
+# Default python on the host to fall back to when instantiating e.g. the
+# virtualenv.
+HOST_PYTHON=${HOST_PYTHON:-python}
+
# If ccache is available, use it... unless we're on Mac, then all hell breaks
# loose because Python does hacky things to support other hacky things done to
# hacky things on Mac OS X
@@ -71,7 +76,14 @@ if [ "$CONFIG" = "gcov" ]; then
export GRPC_PYTHON_ENABLE_CYTHON_TRACING=1
fi
-($PYTHON -m virtualenv $VENV || true)
+# Instnatiate the virtualenv, preferring to do so from the relevant python
+# version. Even if these commands fail (e.g. on Windows due to name conflicts)
+# it's possible that the virtualenv is still usable and we trust the tester to
+# be able to 'figure it out' instead of us e.g. doing potentially expensive and
+# unnecessary error recovery by `rm -rf`ing the virtualenv.
+($PYTHON -m virtualenv $VENV ||
+ $HOST_PYTHON -m virtualenv -p $PYTHON $VENV ||
+ true)
VENV_PYTHON=`$REALPATH -s "$VENV/$VENV_RELATIVE_PYTHON"`
# pip-installs the directory specified. Used because on MSYS the vanilla Windows