Fix MacOS venv issue.

PiperOrigin-RevId: 353986703
Change-Id: Ia190e0ea4c524f5147e153ece0467cca2bed0fb2
This commit is contained in:
Amit Patankar 2021-01-26 17:26:18 -08:00 committed by TensorFlower Gardener
parent be36503971
commit 9c2bafc235
2 changed files with 10 additions and 3 deletions

View File

@ -29,11 +29,18 @@ WIN_GPU_MAX_WHL_SIZE=252M
function run_smoke_test() {
VENV_TMP_DIR=$(mktemp -d)
# Check if in a virtualenv and exit if yes.
IN_VENV=$(python -c 'import sys; print("1" if sys.version_info.major == 3 and sys.prefix != sys.base_prefix else "0")')
if [[ "$IN_VENV" == "1" ]]; then
echo "It appears that we are already in a virtualenv. Deactivating..."
deactivate || source deactivate || die "FAILED: Unable to deactivate from existing virtualenv."
fi
${PYTHON_BIN_PATH} -m virtualenv -p ${PYTHON_BIN_PATH} "${VENV_TMP_DIR}" || \
echo "WARNING: Unable to create virtualenv. Assuming we are in one already."
die "FAILED: Unable to create virtualenv"
source "${VENV_TMP_DIR}/bin/activate" || \
echo "WARNING: Unable to activate virtualenv. Assuming we are in one already."
die "FAILED: Unable to activate virtualenv "
# install tensorflow
python -m pip install ${WHL_NAME} || \

View File

@ -289,7 +289,7 @@ fi
check_global_vars
# Check if in a virtualenv and exit if yes.
IN_VENV=$(python -c 'import sys; print("1" if hasattr(sys, "base_prefix") else "0")')
IN_VENV=$(python -c 'import sys; print("1" if sys.version_info.major == 3 and sys.prefix != sys.base_prefix else "0")')
if [[ "$IN_VENV" == "1" ]]; then
echo "It appears that we are already in a virtualenv. Deactivating..."
deactivate || source deactivate || die "FAILED: Unable to deactivate from existing virtualenv."