1 #!/usr/bin/env bash 2 # Copyright 2017 The TensorFlow Authors. All Rights Reserved. 3 # 4 # Licensed under the Apache License, Version 2.0 (the "License"); 5 # you may not use this file except in compliance with the License. 6 # You may obtain a copy of the License at 7 # 8 # http://www.apache.org/licenses/LICENSE-2.0 9 # 10 # Unless required by applicable law or agreed to in writing, software 11 # distributed under the License is distributed on an "AS IS" BASIS, 12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 # See the License for the specific language governing permissions and 14 # limitations under the License. 15 # ============================================================================= 16 17 18 set -e 19 20 BINARY="bazel-bin/tensorflow/contrib/tpu/profiler/capture_tpu_profile" 21 PACKAGE_NAME="cloud_tpu_profiler" 22 PIP_PACKAGE="tensorflow/contrib/tpu/profiler/pip_package" 23 24 function main() { 25 if [ $# -lt 1 ] ; then 26 echo "No destination dir provided" 27 exit 1 28 fi 29 30 DEST=$1 31 TMPDIR=$(mktemp -d -t tmp.XXXXXXXXXX) 32 33 echo $(date) : "=== Using tmpdir: ${TMPDIR}" 34 35 if [ ! -f "${BINARY}" ]; then 36 echo "Could not find ${BINARY}. Did you run from the root of the build tree?" 37 exit 1 38 fi 39 40 cp ${PIP_PACKAGE}/README ${TMPDIR} 41 cp ${PIP_PACKAGE}/setup.py ${TMPDIR} 42 cp -R ${PIP_PACKAGE}/${PACKAGE_NAME} ${TMPDIR} 43 mkdir ${TMPDIR}/${PACKAGE_NAME}/data 44 cp ${BINARY} ${TMPDIR}/${PACKAGE_NAME}/data 45 echo $(ls $TMPDIR) 46 47 pushd ${TMPDIR} 48 echo $(date) : "=== Building wheel" 49 echo $(pwd) 50 python setup.py bdist_wheel >/dev/null 51 python3 setup.py bdist_wheel >/dev/null 52 mkdir -p ${DEST} 53 cp dist/* ${DEST} 54 popd 55 rm -rf ${TMPDIR} 56 echo $(date) : "=== Output wheel file is in: ${DEST}" 57 } 58 59 main "$@" 60