diff --git a/build_tensorflow/build_tensorflow.sh b/build_tensorflow/build_tensorflow.sh index 8959ccd..8c9df87 100755 --- a/build_tensorflow/build_tensorflow.sh +++ b/build_tensorflow/build_tensorflow.sh @@ -47,6 +47,16 @@ TF_GIT_URL=${TF_GIT_URL:-"https://github.com/tensorflow/tensorflow"} WORKDIR=${WORKDIR:-"$DIR"} BAZEL_BIN="$(command -v bazel)" +function set_selected_python_default() { + PYTHON_BIN_PATH=$(command -v python${TF_PYTHON_VERSION}) + default_python=$(command -v python) + [ -z "$default_python" ] && { + default_python="$(dirname $PYTHON_BIN_PATH)/python" + } + rm -f $default_python &>/dev/null + ln -sf $PYTHON_BIN_PATH $default_python &>/dev/null +} + function log_failure_msg() { echo -ne "[${RED}ERROR${NC}] $@\n" } @@ -85,6 +95,7 @@ function build_bazel() ln -sf "${WORKDIR}/bin/bazel-${BAZEL_VERSION}" "${WORKDIR}/bin/bazel" &>/dev/null return 0 fi + set_selected_python_default cd $WORKDIR @@ -198,11 +209,8 @@ function configure_tensorflow() $BAZEL_BIN clean export PYTHON_BIN_PATH=$(command -v python${TF_PYTHON_VERSION}) export ${TF_BUILD_VARS} - - # TODO: llvm calling python2 (remove in future) - local default_python="$(command -v python)" - rm -f $(command -v python) &>/dev/null - ln -sf $PYTHON_BIN_PATH $default_python &>/dev/null + + set_selected_python_default # if need_cuda is enabled, search sdk if [ "$TF_NEED_CUDA" == "1" ]; then