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
8
9
10
11
12
13
14
15
16
17
18
19

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}"

# 1. Install conda at ./conda
if [ ! -d "${conda_dir}" ]; then
    printf "* Installing conda\n"
20
21
    export tmp_conda="$(echo $conda_dir | tr '/' '\\')"
    export miniconda_exe="$(echo $root_dir | tr '/' '\\')\\miniconda.exe"
22
    curl --silent --output miniconda.exe https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe -O
23
24
25
    "$this_dir/install_conda.bat"
    unset tmp_conda
    unset miniconda_exe
moto's avatar
moto committed
26
fi
Nikita Shulga's avatar
Nikita Shulga committed
27
eval "$("${conda_dir}/Scripts/conda.exe" 'shell.bash' 'hook')"
28

moto's avatar
moto committed
29
30
# 2. Create test environment at ./env
if [ ! -d "${env_dir}" ]; then
31
32
    printf "* Creating a test environment with PYTHON_VERSION=%s\n" "${PYTHON_VERSION}"
    conda create --prefix "${env_dir}" -y python="${PYTHON_VERSION}"
moto's avatar
moto committed
33
34
fi
conda activate "${env_dir}"
35
36
37

# 3. Install minimal build tools
pip --quiet install cmake ninja
38
conda install --quiet -y 'ffmpeg>=4.1'