message: Fixes for import issues inside virtualenv for pip tests.
diff: @@ -430,6 +430,10 @@ create_activate_virtualenv() {
  source "${VIRTUALENV_DIR}/bin/activate" || \
  die "FAILED: Unable to activate virtualenv in ${VIRTUALENV_DIR}"
  +
  + # Update .tf_configure.bazelrc with venv python path for bazel test.
  + PYTHON_BIN_PATH="$(which python)"
  + yes "" | ./configure
  }
  install_tensorflow_pip() {
  @@ -442,17 +446,6 @@ install_tensorflow_pip() {
  # Set path to pip.
  PIP_BIN_PATH="$(which pip${PYTHON_VER_CFG})"
  - # Store the original values for the global vars.
  - PYTHON_BIN_PATH_TMP=${PYTHON_BIN_PATH}
  - PIP_BIN_PATH_TMP=${PIP_BIN_PATH}
  -
  - # If in virtualenv, use default python and pip set up for the venv.
  - IN_VENV=$(python -c 'import sys; print("1" if hasattr(sys, "real_prefix") else "0")')
  - if [[ $IN_VENV == "1" ]]; then
  - PYTHON_BIN_PATH=$(which python)
  - PIP_BIN_PATH=$(which pip)
  - fi
  -
  # Print python and pip bin paths
  echo "PYTHON_BIN_PATH to be used to install the .whl: ${PYTHON_BIN_PATH}"
  echo "PIP_BIN_PATH to be used to install the .whl: ${PIP_BIN_PATH}"
  @@ -488,16 +481,6 @@ install_tensorflow_pip() {
  # ImportError: cannot import name py31compat
  ${PIP_BIN_PATH} install --upgrade setuptools==39.1.0 || \
  die "Error: setuptools install, upgrade FAILED"
  -
  - # Set python and pip bin paths to original.
  - if [[ $IN_VENV == "1" ]]; then
  - PYTHON_BIN_PATH=${PYTHON_BIN_PATH_TMP}
  - PIP_BIN_PATH=${PIP_BIN_PATH_TMP}
  - fi
  -
  - # Print the outgoing python and pip bin paths.
  - echo "PYTHON_BIN_PATH: ${PYTHON_BIN_PATH}"
  - echo "PIP_BIN_PATH: ${PIP_BIN_PATH}"
  }
  run_test_with_bazel() {
  @@ -552,8 +535,17 @@ run_test_with_bazel() {
  BAZEL_PARALLEL_TEST_FLAGS="--local_test_jobs=1"
  fi
  + TEST_TARGETS_LN=""
  + for TARGET in ${BAZEL_TEST_TARGETS[@]}; do
  + TARGET_RE="$(echo ${TARGET} | sed -e 's/\/\//\/${PIP_TEST_PREFIX}\//g')"
  + TEST_TARGETS_LN+="${TARGET_RE} "
  + done
  + echo "Test targets (symlink): ${TEST_TARGETS_LN}"
  +
  # Run the test.
  - bazel test --build_tests_only ${BAZEL_BUILD_FLAGS} ${BAZEL_PARALLEL_TEST_FLAGS} --test_tag_filters=${BAZEL_TEST_FILTER_TAGS} -- ${BAZEL_TEST_TARGETS}
  + bazel test --build_tests_only ${BAZEL_BUILD_FLAGS} ${BAZEL_PARALLEL_TEST_FLAGS} --test_tag_filters=${BAZEL_TEST_FILTER_TAGS} -k -- ${TEST_TARGETS_LN}
  +
  + unlink ${PIP_TEST_ROOT}/tensorflow
  }
  run_all_tests() {
  