setup_env.sh 1.3 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
8
9
10
11
12
13
14
15
16

set -e

this_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
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
17
18
19
20
21
case "$(uname -s)" in
    Darwin*) os=MacOSX;;
    *) os=Linux
esac

moto's avatar
moto committed
22
23
24
# 1. Install conda at ./conda
if [ ! -d "${conda_dir}" ]; then
    printf "* Installing conda\n"
moto's avatar
moto committed
25
    wget -O miniconda.sh "http://repo.continuum.io/miniconda/Miniconda3-latest-${os}-x86_64.sh"
moto's avatar
moto committed
26
27
28
29
30
31
32
33
34
35
36
    bash ./miniconda.sh -b -f -p "${conda_dir}"
fi
eval "$(${conda_dir}/bin/conda shell.bash hook)"

# 2. Create test environment at ./env
if [ ! -d "${env_dir}" ]; then
    printf "* Creating a test environment\n"
    conda create --prefix "${env_dir}" -y python="$PYTHON_VERSION"
fi
conda activate "${env_dir}"

37
38
39
# 3. Install Conda dependencies
printf "* Installing dependencies (except PyTorch)\n"
conda env update --file "${this_dir}/environment.yml" --prune
moto's avatar
moto committed
40
41
42
if [ "${os}" == Linux ] ; then
    pip install clang-format
fi
moto's avatar
moto committed
43

moto's avatar
moto committed
44
45
46
47
48
49
50
# 4. Buld codecs
mkdir -p third_party/build
(
    cd third_party/build
    cmake ..
    cmake --build .
)