diff options
-rwxr-xr-x | tensorflow/tools/ci_build/builds/pip.sh | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/tensorflow/tools/ci_build/builds/pip.sh b/tensorflow/tools/ci_build/builds/pip.sh index 122a3c6dc5..e1820da4a1 100755 --- a/tensorflow/tools/ci_build/builds/pip.sh +++ b/tensorflow/tools/ci_build/builds/pip.sh @@ -49,6 +49,12 @@ # to run. # +# Constants: +# Fixed naming patterns for wheel (.whl) files given different python versions +declare -A WHL_TAGS +WHL_TAGS=(["2.7"]="cp27-none" ["3.4"]="cp34-cp34m" ["3.5"]="cp35-cp35m") + + INSTALL_EXTRA_PIP_PACKAGES=${TF_BUILD_INSTALL_EXTRA_PIP_PACKAGES} @@ -128,10 +134,14 @@ fi # This info will be useful for determining the directory of the local pip # installation of Python PY_MAJOR_MINOR_VER=$(${PYTHON_BIN_PATH} -V 2>&1 | awk '{print $NF}' | cut -d. -f-2) +if [[ -z "${PY_MAJOR_MINOR_VER}" ]]; then + die "ERROR: Unable to determine the major.minor version of Python" +fi echo "Python binary path to be used in PIP install: ${PYTHON_BIN_PATH} "\ "(Major.Minor version: ${PY_MAJOR_MINOR_VER})" + # Build PIP Wheel file PIP_TEST_ROOT="pip_test" PIP_WHL_DIR="${PIP_TEST_ROOT}/whl" @@ -140,16 +150,35 @@ rm -rf ${PIP_WHL_DIR} && mkdir -p ${PIP_WHL_DIR} bazel-bin/tensorflow/tools/pip_package/build_pip_package ${PIP_WHL_DIR} || \ die "build_pip_package FAILED" -# Perform installation WHL_PATH=$(ls ${PIP_WHL_DIR}/tensorflow*.whl) if [[ $(echo ${WHL_PATH} | wc -w) -ne 1 ]]; then die "ERROR: Failed to find exactly one built TensorFlow .whl file in "\ "directory: ${PIP_WHL_DIR}" fi +# If on Linux, rename the whl file properly so it will have the python +# version tags and platform tags that won't cause pip install issues. +if [[ $(uname) == "Linux" ]]; then + PY_TAGS=${WHL_TAGS[${PY_MAJOR_MINOR_VER}]} + + if [[ ! -z "${PY_TAGS}" ]]; then + PLATFORM_TAG=$(to_lower "$(uname)_$(uname -m)") + WHL_DIR=$(dirname "${WHL_PATH}") + WHL_BASE_NAME=$(basename "${WHL_PATH}") + + NEW_WHL_BASE_NAME=$(echo ${WHL_BASE_NAME} | cut -d \- -f 1)-\ +$(echo ${WHL_BASE_NAME} | cut -d \- -f 2)-${PY_TAGS}-${PLATFORM_TAG}.whl + + cp "${WHL_DIR}/${WHL_BASE_NAME}" "${WHL_DIR}/${NEW_WHL_BASE_NAME}" && \ + echo "Copied wheel file: ${WHL_BASE_NAME} --> ${NEW_WHL_BASE_NAME}" || \ + die "ERROR: Failed to copy wheel file to ${NEW_WHL_BASE_NAME}" + fi +fi + echo "whl file path = ${WHL_PATH}" -# Install, in user's local home folder + +# Perform installation echo "Installing pip whl file: ${WHL_PATH}" # Create virtualenv directory for install test |