1*da0073e9SAndroid Build Coastguard Worker#!/bin/bash 2*da0073e9SAndroid Build Coastguard Worker 3*da0073e9SAndroid Build Coastguard Workerset -ex 4*da0073e9SAndroid Build Coastguard Worker 5*da0073e9SAndroid Build Coastguard Worker# realpath might not be available on MacOS 6*da0073e9SAndroid Build Coastguard Workerscript_path=$(python -c "import os; import sys; print(os.path.realpath(sys.argv[1]))" "${BASH_SOURCE[0]}") 7*da0073e9SAndroid Build Coastguard Workertop_dir=$(dirname $(dirname $(dirname "$script_path"))) 8*da0073e9SAndroid Build Coastguard Workertp2_dir="$top_dir/third_party" 9*da0073e9SAndroid Build Coastguard WorkerBUILD_DIR="$top_dir/build" 10*da0073e9SAndroid Build Coastguard Workermkdir -p "$BUILD_DIR" 11*da0073e9SAndroid Build Coastguard Worker 12*da0073e9SAndroid Build Coastguard Worker_pip_install() { 13*da0073e9SAndroid Build Coastguard Worker if [[ -n "$CI" ]]; then 14*da0073e9SAndroid Build Coastguard Worker if [[ -z "${SCCACHE_BUCKET}" ]]; then 15*da0073e9SAndroid Build Coastguard Worker ccache -z 16*da0073e9SAndroid Build Coastguard Worker fi 17*da0073e9SAndroid Build Coastguard Worker fi 18*da0073e9SAndroid Build Coastguard Worker if [[ -n "$CI" ]]; then 19*da0073e9SAndroid Build Coastguard Worker time pip install "$@" 20*da0073e9SAndroid Build Coastguard Worker else 21*da0073e9SAndroid Build Coastguard Worker pip install "$@" 22*da0073e9SAndroid Build Coastguard Worker fi 23*da0073e9SAndroid Build Coastguard Worker if [[ -n "$CI" ]]; then 24*da0073e9SAndroid Build Coastguard Worker if [[ -n "${SCCACHE_BUCKET}" ]]; then 25*da0073e9SAndroid Build Coastguard Worker sccache --show-stats 26*da0073e9SAndroid Build Coastguard Worker else 27*da0073e9SAndroid Build Coastguard Worker ccache -s 28*da0073e9SAndroid Build Coastguard Worker fi 29*da0073e9SAndroid Build Coastguard Worker fi 30*da0073e9SAndroid Build Coastguard Worker} 31*da0073e9SAndroid Build Coastguard Worker 32*da0073e9SAndroid Build Coastguard Worker# Install onnx 33*da0073e9SAndroid Build Coastguard Worker_pip_install -b "$BUILD_DIR/onnx" "file://$tp2_dir/onnx#egg=onnx" 34*da0073e9SAndroid Build Coastguard Worker 35*da0073e9SAndroid Build Coastguard Worker# Install caffe2 and pytorch 36*da0073e9SAndroid Build Coastguard Workerpip install -r "$top_dir/caffe2/requirements.txt" 37*da0073e9SAndroid Build Coastguard Workerpip install -r "$top_dir/requirements.txt" 38*da0073e9SAndroid Build Coastguard Workerpython setup.py install 39