-
Notifications
You must be signed in to change notification settings - Fork 3
/
setup.sh
executable file
·105 lines (94 loc) · 2.92 KB
/
setup.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
#!/usr/bin/env bash
print_usage() {
printf "bash %s [-h|--help] [-d|--directory <workspace directory>] [-p|--python] [--with-cuda] [--with-deps] [-g|--global] [-c|--clean] [-t|--torch]\n" "$0"
printf "Options:\n"
printf " -h, --help : Prints this help message\n"
printf " -d, --directory <workspace directory> : Builds and installs the package in the specified directory\n"
printf " -p, --python : Installs the python bindings\n"
printf " --with-cuda : Builds the package with CUDA support\n"
printf " --with-deps : Installs the dependencies\n"
printf " -g, --global : Installs the package globally. Needs sudo permissions\n"
}
ORIG_INPUT_PARAMS="$@"
params="$(getopt -o d:hctpg -l directory:,help,clean,torch,python,global,with-cuda,with-deps,pip-path: --name "$(basename "$0")" -- "$@")"
if [ $? -ne 0 ]
then
print_usage
fi
eval set -- "$params"
echo "Params: $params"
unset params
WITH_TORCH=0
INSTALL=true
WITH_DEPS=false
while true; do
case ${1} in
-h|--help) print_usage; exit 0;;
-c|--clean) CLEAN=true;INSTALL=false;shift;;
-t|--torch) WITH_TORCH=ON; shift;;
-p|--python) WITH_PYTHON=true;shift;;
-d|--directory) WS_DIR+=("${2}");shift 2;;
-g|--global) GLOBAL=true;shift;;
--with-cuda) WITH_CUDA=ON;shift;;
--with-deps) WITH_DEPS=true;shift;;
--pip-path) PIP_PATH+=("${2}");shift 2;;
--) shift;break;;
*) print_usage
exit 1 ;;
esac
done
# Get directory of script
# https://stackoverflow.com/questions/59895/getting-the-source-directory-of-a-bash-script-from-within
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
if [[ ${WITH_DEPS} == "true" ]]
then
echo "Installing dependencies"
if [[ ${WS_DIR} ]]
then
INSTALL_DIR=${WS_DIR}/install/
bash ${DIR}/setup_utils/install_dependencies.sh -d ${INSTALL_DIR} --eigen --cgal
else
bash ${DIR}/setup_utils/install_dependencies.sh --eigen --cgal
fi
if [ $? -ne 0 ]; then
echo "deps build failed"
exit 1
fi
fi
if [[ ${INSTALL} ]]
then
bash ${DIR}/cppsrc/setup.sh ${ORIG_INPUT_PARAMS}
if [ $? -ne 0 ]; then
echo "cppsrc build failed"
exit 1
fi
fi
if [[ ${WITH_PYTHON} ]]
then
echo "Installing python bindings"
echo "pip_path: $(which pip)"
# pip install --no-build-isolation ${DIR}/cppsrc/core/python_bindings/
# pip install ${DIR}/cppsrc/core/python_bindings/
pip install .
if [ $? -ne 0 ]; then
echo "python bindings build failed"
exit 1
fi
pip install -e ${DIR}/python/
if [ $? -ne 0 ]; then
echo "CoverageControlTorch Python package install failed"
exit 1
fi
fi
# if clean and WITH_PYTHON, then uninstall
if [[ ${CLEAN} ]] && [[ ${WITH_PYTHON} ]]
then
echo "Cleaning python bindings"
pip uninstall -y pyCoverageControl
pip uninstall -y CoverageControlTorch
fi
# pip install -e ${DIR}/torch/python_bindings/
# if [ $? -ne 0 ]; then
# echo "pyCoverageControlTorch failed"
# exit 1
# fi