forked from TUW-GEO/esa_cci_sm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
107 lines (94 loc) · 2.66 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/bin/bash
###
### How to use the installation script
### ===================================
#
# To install this package, you need conda installed (the conda command must work
# in your shell, see https://docs.conda.io/en/latest/miniconda.html),
# then install the package like:
#
# $ bash install.sh -d --python 3.6 --name *env_name*
#
# To get information on the flags, run
#
# $ bash install.sh --help"
###
function setup()
{
local __py_vers=$1
local __name=$2
local __develop=$3
conda config --set always_yes yes
conda create -n $__name python=$__py_vers
conda activate $__name
conda env update -f environment.yml -n $__name
if [[ $__develop -eq 0 ]]; then
echo "Installing package..."
python setup.py install
else
echo "Installing package in development mode..."
python setup.py develop
fi;
conda config --set always_yes no
}
function install()
{
local __name=$NAME
local __py=$PYTHON
local __develop=$DEVELOP
conda_base=$(conda info --base)
source $conda_base/etc/profile.d/conda.sh
echo "Setup environment $__name ..."
setup $__py $__name $__develop
}
#===============================================================================
# default
DEVELOP=0
NAME="esa_cci_sm"
PYTHON="3.6"
_help=0
# Loop through arguments and process them
for arg in "$@"
do
case $arg in
-d) #switch
DEVELOP=1
shift # Remove --develop from processing
;;
-n|--name) # kwarg
NAME="$2"
shift # Remove argument name from processing
shift # Remove argument value from processing
;;
-p|--python) # kwarg
PYTHON="$2"
shift # Remove argument name from processing
shift # Remove argument value from processing
;;
-h|--help)
_help=1
shift
echo "Usage: bash install.sh [OPTION] "
echo "Setup environment for developing this package. "
echo "Optional arguments/flags to pass to >> $ bash install.sh "
echo "-d Flag to install package in development mode (default: False) "
echo "-n, --name Name of the environment to install, (default: $NAME)"
echo "-p, --python Python version to install together with other dependencies (default: $PYTHON) "
echo "-h, --help Show this help message."
esac
done
if [[ $_help -eq 0 ]]; then
install $NAME $PYTHON $DEVELOP;
echo " "
echo "Installation complete."
echo " "
echo "#"
echo "# To activate this environment, use"
echo "#"
echo "# $ conda activate $NAME"
echo "#"
echo "# To deactivate an active environment, use"
echo "#"
echo "# $ conda deactivate $NAME"
echo " "
fi