-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.sh
executable file
·261 lines (239 loc) · 7.87 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
#!/bin/bash
# - Defines colors and message types:
RED="\033[0;31m"
GREEN="\033[0;32m"
YELLOW="\033[0;33m"
NC="\033[0m" # No Color
INFO="${GREEN}INFO${NC} "
WARNING="${YELLOW}WARNING${NC} "
ERROR="${RED}ERROR${NC} "
bold() { echo -e "\e[1m$*\e[0m"; }
# Name of the conda environment to create:
name="plant3dvision"
# Python version to use:
py_version="3.9"
# Options to use with `pip`:
pip_opt=""
# Boolean to install documentation requirements:
doc=0
# Boolean to install notebook requirements:
notebook=0
# Check if conda is installed & available
if ! command -v conda &>/dev/null; then
echo -e "${ERROR}Conda is not installed or not found in PATH. Please install Conda before running this script."
exit 1
fi
# Function to check numpy version
check_numpy_version() {
numpy_version=$(python3 -c "import numpy; print(numpy.__version__)" 2>/dev/null)
if [ $? -eq 0 ]; then
echo -e "${INFO}Numpy version installed: ${numpy_version}"
echo "Numpy version installed: ${numpy_version}" >> numpy_versions.log
else
echo -e "${WARNING}Numpy is not installed or could not be detected."
echo "Numpy is not installed or could not be detected." >> numpy_versions.log
fi
}
usage() {
echo -e "$(bold USAGE):"
echo -e " ./install.sh [OPTIONS]"
echo ""
echo -e "$(bold DESCRIPTION):"
echo -e " Install the sources and dependencies for the 'plant-3d-vision' ROMI library in a conda environment."
echo ""
echo -e "$(bold OPTIONS):"
echo " -n, --name
Name of the conda environment to use, defaults to '${name}'."
echo " --dev
Install the sources in developer mode."
echo " --doc
Install the packages required to build documentation."
echo " --notebook
Install the packages required to run jupyter notebooks."
echo " --python
Set the version of python to use, defaults to '${py_version}'.
Only used if the conda environment is created."
# General options:
echo " -h, --help
Output a usage message and exit."
echo ""
echo -e "$(bold EXAMPLES):"
echo " 1. Create a 'plant3dvision' conda environment & install the sources in 'develop' mode."
echo " $ ./install.sh --dev"
echo " 2 Install the sources in an existing 'romi' environment."
echo " $ ./install.sh -n romi"
}
while [ "$1" != "" ]; do
case $1 in
-n | --name)
shift
name=$1
;;
--dev)
pip_opt="${pip_opt} -e"
;;
--doc)
doc=1
;;
--notebook)
notebook=1
;;
--python)
shift
py_version=$1
;;
-h | --help)
usage
exit
;;
*)
usage
exit 1
;;
esac
shift
done
# source ${HOME}/miniconda3/bin/activate
# Get the path to the environment to create:
CONDA_BASE_PATH=$(dirname "$(dirname $CONDA_EXE)")
CONDA_ENV_PATH=${CONDA_BASE_PATH}/envs/${name}
if [ -d "$CONDA_ENV_PATH" ]; then
echo -e "${WARNING}# - Using existing '${name}' conda environment..."
eval "$(conda shell.bash hook)"
conda activate ${name}
else
echo -e "${INFO}# - Creating '${name}' conda environment..."
start_time=$(date +%s)
conda create -y -n "${name}" python="${py_version}" "numpy<2"
if [ $? -ne 0 ]; then
echo -e "${ERROR}Failed to create conda environment '${name}'."
exit 1
fi
echo -e "${INFO}Conda environment creation done in $(($(date +%s) - start_time)) s."
eval "$(conda shell.bash hook)"
conda activate "${name}"
if [ $? -ne 0 ]; then
echo -e "${ERROR}Failed to activate conda environment '${name}'."
exit 1
fi
fi
# Check numpy version after installation.
check_numpy_version
# Install `plantdb` sources:
echo -e "\n\n${INFO}# - Installing 'plantdb' sources..."
start_time=$(date +%s)
python3 -m pip install ${pip_opt} plantdb/
build_status=$?
if [ ${build_status} == 0 ]; then
echo -e "${INFO}'plantdb' sources installed in $(($(date +%s) - start_time)) s."
# Check numpy version after installation.
check_numpy_version
else
echo -e "${ERROR}'plantdb' sources install failed with code '${build_status}'!"
exit ${build_status}
fi
# Install `romitask` sources:
echo -e "\n\n${INFO}# - Installing 'romitask' sources..."
start_time=$(date +%s)
python3 -m pip install ${pip_opt} romitask/
build_status=$?
if [ ${build_status} == 0 ]; then
echo -e "${INFO}'romitask' sources installed in $(($(date +%s) - start_time)) s."
# Check numpy version after installation.
check_numpy_version
else
echo -e "${ERROR}'romitask' sources install failed with code '${build_status}'!"
exit ${build_status}
fi
# Install `skeleton_refinement` sources:
echo -e "\n\n${INFO}# - Installing 'skeleton_refinement' sources..."
start_time=$(date +%s)
python3 -m pip install ${pip_opt} skeleton_refinement/
build_status=$?
if [ ${build_status} == 0 ]; then
echo -e "${INFO}'skeleton_refinement' sources installed in $(($(date +%s) - start_time)) s."
# Check numpy version after installation.
check_numpy_version
else
echo -e "${ERROR}'skeleton_refinement' sources install failed with code '${build_status}'!"
exit ${build_status}
fi
# Install `romiseg` sources:
echo -e "\n\n${INFO}# - Installing 'romiseg' sources..."
start_time=$(date +%s)
python3 -m pip install torch==1.12.1+cu102 torchvision==0.13.1+cu102 --extra-index-url https://download.pytorch.org/whl/cu102
python3 -m pip install ${pip_opt} romiseg/
build_status=$?
if [ ${build_status} == 0 ]; then
echo -e "${INFO}'romiseg' sources installed in $(($(date +%s) - start_time)) s."
# Check numpy version after installation.
check_numpy_version
else
echo -e "${ERROR}'romiseg' sources install failed with code '${build_status}'!"
exit ${build_status}
fi
# Install `romicgal` sources:
echo -e "\n\n${INFO}# - Installing 'romicgal' sources..."
start_time=$(date +%s)
python3 -m pip install pybind11
python3 -m pip install romicgal/
build_status=$?
if [ ${build_status} == 0 ]; then
echo -e "${INFO}'romicgal' sources installed in $(($(date +%s) - start_time)) s."
# Check numpy version after installation.
check_numpy_version
else
echo -e "${ERROR}'romicgal' sources install failed with code '${build_status}'!"
exit ${build_status}
fi
# Install `dtw` sources:
echo -e "\n\n${INFO}# - Installing 'dtw' sources..."
start_time=$(date +%s)
python3 -m pip install -r dtw/requirements.txt
python3 -m pip install ${pip_opt} dtw/
build_status=$?
if [ ${build_status} == 0 ]; then
echo -e "${INFO}'dtw' sources installed in $(($(date +%s) - start_time)) s."
# Check numpy version after installation.
check_numpy_version
else
echo -e "${ERROR}'dtw' sources install failed with code '${build_status}'!"
exit ${build_status}
fi
# Install `plant-3d-vision` sources:
echo -e "\n\n${INFO}# - Installing 'plant-3d-vision' sources..."
start_time=$(date +%s)
envpython3 -m pip install ${pip_opt} .
build_status=$?
if [ ${build_status} == 0 ]; then
echo -e "${INFO}'plant-3d-vision' sources installed in $(($(date +%s) - start_time)) s."
# Check numpy version after installation.
check_numpy_version
else
echo -e "${ERROR}'plant-3d-vision' sources install failed with code '${build_status}'!"
exit ${build_status}
fi
if [ "${doc}" -eq 1 ]; then
echo -e "\n\n${INFO}# - Installing documentation requirements..."
start_time=$(date +%s)
python3 -m pip install -U "Sphinx>5" sphinx-material sphinx-argparse sphinx-copybutton sphinx-panels sphinx-prompt myst-nb myst-parser
build_status=$?
if [ ${build_status} == 0 ]; then
echo -e "${INFO}Documentation requirements installed in $(($(date +%s) - start_time)) s."
else
echo -e "${ERROR}Documentation requirements install failed with code '${build_status}'!"
exit ${build_status}
fi
fi
if [ "${notebook}" -eq 1 ]; then
echo -e "\n\n${INFO}# - Installing notebook requirements..."
start_time=$(date +%s)
python3 -m pip install -U jupyter notebook ipywidgets plotly
build_status=$?
if [ ${build_status} == 0 ]; then
echo -e "${INFO}Notebook requirements installed in $(($(date +%s) - start_time)) s."
else
echo -e "${ERROR}Notebook requirements install failed with code '${build_status}'!"
exit ${build_status}
fi
fi