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