Repository navigation
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·113 lines (94 loc) · 2.59 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·113 lines (94 loc) · 2.59 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
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
#!/bin/bash -e
NO_VENT=false
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color
DEV=false
ONLY_DEP=false
_error() {
echo -e ${RED}$1${NC} > /dev/stderr; exit 1;
}
_info() {
echo -e ${GREEN}$1${NC} > /dev/stdout
}
function _python () {
($(command -v python3) --version &>/dev/null && (python3 $@; return $?)) ||
($(command -v python) --version &>/dev/null && (python $@; return $?))
}
function _pip () {
_python -m pip $@
}
function _virtualenv () {
_python -m virtualenv $@
}
function _ensure_virtualenv_installed () {
_virtualenv --help &>/dev/null || _error "'virtualenv' is needed but not installed properly"
}
function _ensure_pip_installed () {
_pip -V &>/dev/null || _error "'pip' required but not installed properly, exiting"
}
function _ensure_npm_installed () {
$(command -v npm &> /dev/null) || _error "'npm' is needed but not installed properly"
}
while [ $# -gt 0 ]
do
case $1 in
--venv )
VENV=true && shift
VENV_PATH=$1
if [[ -z $VENV_PATH ]] ; then
echo "VENV_PATH" is required
fi
;;
--dev )
DEV=true
;;
--dependency-only )
ONLY_DEP=true
;;
-h | --help )
echo "usage: setup.sh [-h] [--venv VENV_PATH]
options:
--venv Create a virtual env in given patch and install all python packages inside the virtual env.
--dev Install dev packages, or only production packages are installed.
"
exit 0
;;
esac
shift
done
_info "***Make sure required tools are installed***"
_ensure_pip_installed
_ensure_npm_installed
_info "***Create virtualenv if needed***"
if [[ $VENV == 'true' ]] ; then
_ensure_virtualenv_installed
_virtualenv $VENV_PATH
source $VENV_PATH/bin/activate
fi
_info "***Installing requirements of Metadash***"
if [[ -f 'requirements.txt' ]]; then
_pip install -r requirements.txt
fi
if [[ $DEV == 'true' && -f 'requirements.dev.txt' ]]; then
_info "Installing dev requirements of Metadash"
_pip install -r requirements.dev.txt
fi
_info "***Installing requirements of Plugins***"
for file in ./metadash/plugins/*/requirements.txt; do
if [[ -f $file ]]; then
_pip install -r $file
fi
done
_info "***Install node packages***"
if [[ $DEV == 'true' ]]; then
npm install
else
npm install --production
fi
if [[ $ONLY_DEP == 'true' ]]; then
_info "***Dependency installation finished, exiting***"
exit 0;
fi
_info "***Rebuilding Assets***"
npm run build