-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_dependencies_MacOS.sh
52 lines (39 loc) · 1.5 KB
/
install_dependencies_MacOS.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
#!/bin/bash
# Get the script directory
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
if [[ -z "${install_dir}" ]]; then
install_dir="$SCRIPT_DIR"
fi
# Python executable
python_cmd="python3"
# Git executable
export GIT="git"
# Python venv without trailing slash (defaults to ${install_dir}/${venv_dir})
venv_dir="venv"
ENV_SCRIPT="prepare_environment.py"
# Disable sentry logging
export ERROR_REPORTING=FALSE
# Do not reinstall existing pip packages on macOS
export PIP_IGNORE_INSTALLED=0
# Use the torch version that work for Mac
export TORCH_COMMAND="pip install torch torchvision"
# Check if python3-venv is installed
if ! "${python_cmd}" -c "import venv" &>/dev/null; then
printf "\n%s\n" "${delimiter}"
printf "\e[1m\e[31mERROR: python3-venv is not installed, aborting...\e[0m"
printf "\n%s\n" "${delimiter}"
exit 1
fi
printf "\e[1m\e[32mInstalling dependencies for Volume Seg Tool...\n"
# Check if virtual environment is already activated
if [[ -z "${VIRTUAL_ENV}" ]]; then
printf "Creating and activating python venv"
cd "${install_dir}" || { printf "\e[1m\e[31mERROR: Can't cd to %s/, aborting...\e[0m" "${install_dir}"; exit 1; }
if [[ ! -d "${venv_dir}" ]]; then
"${python_cmd}" -m venv "${venv_dir}"
fi
source "${venv_dir}"/bin/activate || { printf "\e[1m\e[31mERROR: Cannot activate python venv, aborting...\e[0m"; exit 1; }
else
printf "python venv already activated: ${VIRTUAL_ENV}"
fi
"${python_cmd}" -u "${ENV_SCRIPT}" "$@"