-
Notifications
You must be signed in to change notification settings - Fork 12
/
install.sh
executable file
·72 lines (59 loc) · 2.18 KB
/
install.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
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env bash
# boolean variable to exit the program on error
shall_exit=false
# prints the error message as the first argument and exits the program with non-zero status
function quit_install () {
echo ""
echo "$(tput setaf 1)ERROR: ${1} $(tput sgr 0)"
echo "please set the LANG and LC_ALL variables in your shell startup script (eg. .bashrc, .bash_profile) to the following values: "
echo " export LC_ALL=en_US.UTF-8"
echo " export LANG=en_US.UTF-8"
echo "and re-execute them so that the changes take place. Exiting the installation process"
exit 1
}
# check if LANG environment is set to the correct value
if [[ -z ${LANG+x} ]]; then
err_msg="LANG environment variable is not set"
shall_exit=true
fi
# check if LC_ALL variable is set to the correct value
if [[ -z ${LC_ALL+x} ]]; then
err_msg="LC_ALL variable is not set"
shall_exit=true
fi
# we have an error, terminate the script
if [[ ${shall_exit} == true ]]; then
quit_install "${err_msg}"
fi
git_error_message="You need git version >= 2.13 to install the esm_tools (see README.rst)."
if hash git 2>/dev/null; then
git_version=`git --version | rev | cut -d' ' -f 1 | rev`
major_git_version=`git --version | rev | cut -d' ' -f 1 | rev | cut -d'.' -f 1`
minor_git_version=`git --version | rev | cut -d' ' -f 1 | rev | cut -d'.' -f 2`
if test ${major_git_version} -lt "2"; then
echo $git_error_message
echo "git version found: ${git_version}"
else
if test ${minor_git_version} -lt "10"; then
echo $git_error_message
echo "git version found: ${git_version}"
fi
fi
else
echo $git_error_message
echo "No installed git version found."
fi
# See here: https://tinyurl.com/5b57knvx
if [ ! -z ${VIRTUAL_ENV+x} ]; then
echo "Detected virtual environment $VIRTUAL_ENV"
pip install -e .
elif [ ! -z ${CONDA_PREFIX+x} ]; then
echo "======================="
echo "Using CONDA environment"
echo "======================="
echo "WARNING: The use of a conda environment is currently not recommended. Use only for testing purposes!"
${CONDA_PREFIX}/bin/pip install -e .
else
echo "Standard install to user directory (likely ${HOME}/.local)"
pip install --user -e .
fi