-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathprepare-conda-env.sh
executable file
·61 lines (45 loc) · 1.83 KB
/
prepare-conda-env.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
if [[ $OSTYPE == 'darwin'* ]]; then
MINICONDA_URL='https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh'
else
MINICONDA_URL='https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh'
fi
function get_or_install_conda_path() {
local conda_exe=$(which conda)
if [[ ! -z ${conda_exe} ]]; then
echo "Found existing conda executable at $(which conda)" 1>&2
echo "$(dirname ${conda_exe})/../etc/profile.d/conda.sh"
return
fi
local install_dir=${_DIR}/miniconda
rm -rf ${install_dir}
local temp_dir=$(mktemp -d)
( cd ${temp_dir}
wget $MINICONDA_URL -O miniconda.sh 1>&2
chmod +x miniconda.sh
./miniconda.sh -b -p ${install_dir} 1>&2
if [[ $? -ne 0 ]]; then
echo "Failed to install miniconda! Please install miniconda following the instructions at this link, then rerun the script: https://docs.conda.io/en/latest/miniconda.html" 1>&2
exit 1
fi
)
rm -rf ${temp_dir}
echo "Installation of miniconda successful" 1>&2
echo "${install_dir}/etc/profile.d/conda.sh"
}
function prepare_conda_env() {
### Preparing the base environment "inline"
local env_name="inline"
local conda_path=$(get_or_install_conda_path)
echo ">>> Preparing conda environment \"${env_name}\", using conda at ${conda_path}" 1>&2
# Preparation
source ${conda_path}
conda env remove --name $env_name
conda create --name $env_name python=3.9 pip -y
conda activate $env_name
# Other libraries
pip install -r requirements.txt
}
prepare_conda_env
conda activate inline