setup_env.sh 1.26 KB
Newer Older
moto's avatar
moto committed
1
2
#!/usr/bin/env bash

3
4
5
6
# This script is for setting up environment in which unit test is ran.
# To speed up the CI time, the resulting environment is cached.
#
# Do not install PyTorch and torchaudio here, otherwise they also get cached.
moto's avatar
moto committed
7

moto's avatar
moto committed
8
set -ex
moto's avatar
moto committed
9
10
11
12
13
14
15

root_dir="$(git rev-parse --show-toplevel)"
conda_dir="${root_dir}/conda"
env_dir="${root_dir}/env"

cd "${root_dir}"

moto's avatar
moto committed
16
17
18
19
20
case "$(uname -s)" in
    Darwin*) os=MacOSX;;
    *) os=Linux
esac

moto's avatar
moto committed
21
22
23
# 1. Install conda at ./conda
if [ ! -d "${conda_dir}" ]; then
    printf "* Installing conda\n"
24
    wget --quiet -O miniconda.sh "http://repo.continuum.io/miniconda/Miniconda3-latest-${os}-x86_64.sh"
moto's avatar
moto committed
25
    bash ./miniconda.sh -b -f -p "${conda_dir}"
26
27
28
29
30
31
    eval "$("${conda_dir}/bin/conda" shell.bash hook)"
    conda update --quiet -y conda
    printf "* Updating the base Python version to %s\n" "${PYTHON_VERSION}"
    conda install --quiet -y python="${PYTHON_VERSION}"
else
    eval "$("${conda_dir}/bin/conda" shell.bash hook)"
moto's avatar
moto committed
32
fi
33

moto's avatar
moto committed
34
35
36

# 2. Create test environment at ./env
if [ ! -d "${env_dir}" ]; then
37
38
    printf "* Creating a test environment with PYTHON_VERSION=%s\n" "${PYTHON_VERSION}\n"
    conda create --prefix "${env_dir}" -y python="${PYTHON_VERSION}"
moto's avatar
moto committed
39
40
41
fi
conda activate "${env_dir}"

moto's avatar
moto committed
42
# 3. Install minimal build tools
43
pip --quiet install cmake ninja