forked from nu-ZOO/MULE
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
77 lines (59 loc) · 1.91 KB
/
setup.sh
File metadata and controls
77 lines (59 loc) · 1.91 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/env bash
function install_conda {
# This function has been heavily inspired by Invisible Cities (next-exp/IC on github).
# Conda installation for MacOS and Linux
case "$(uname -s)" in
Darwin)
export CONDA_OS=MacOSX
;;
Linux)
export CONDA_OS=Linux
;;
*)
echo Installation only support on MacOS and Linux.;
exit 1;;
esac
echo Installing conda for $CONDA_OS # This doesn't currently understand/recognise arm based architectures. Fix!
CONDA_URL="https://repo.anaconda.com/miniconda/Miniconda3-py${PYTHON_VERSION//.}_24.9.2-0-${CONDA_OS}-x86_64.sh"
if which wget; then
wget ${CONDA_URL} -O miniconda.sh
else
curl ${CONDA_URL} -o miniconda.sh
fi
bash miniconda.sh -b -p $HOME/miniconda
CONDA_SH=$HOME/miniconda/etc/profile.d/conda.sh
source $CONDA_SH
echo Activated conda by sourcing $CONDA_SH
}
PYTHON_VERSION='3.12'
DATE='10-24'
# set env name
MULE_ENV_NAME=MULE-${PYTHON_VERSION}-${DATE}
# set directory path to variable
export MULE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
# setup environment variables
export PATH=$MULE_DIR/bin:$PATH
echo "$(<${MULE_DIR}/assets/MULE.txt)"
echo "Identified directory: $MULE_DIR"
# If conda isn't installed, install conda
if conda --version ; then
echo Initialising Conda...
else
echo "No Conda installation detected, installing conda."
echo 'Download conda? Select [1/2]:'
select yn in Yes No; do
case $yn in
Yes ) install_conda; break;;
No ) echo "MULE activation aborted"; return;;
esac
done
fi
# If conda environment exists, activate it. Otherwise create it
if ! (conda env list | grep ${MULE_ENV_NAME}) >> /dev/null
then
echo "Couldn't find environment, creating environment..."
conda env create -f MULE_environment.yml python=$PYTHON_VERSION
fi
echo "Activating environment..."
conda activate ${MULE_ENV_NAME}
cd ${MULE_DIR}