-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit_dev_cli_env.sh
More file actions
51 lines (44 loc) · 1.11 KB
/
init_dev_cli_env.sh
File metadata and controls
51 lines (44 loc) · 1.11 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
#!/bin/bash
# Suggest using git-bash to execute
# This script is used for server execution environment (non-gui env)
# global constants
VENV_ROOT=./.venv
DOT_GIT_FILE=./.git
DOT_GIT_EXCLUDE_LIST=(
"__pycache__"
".history"
".venv"
)
# check if function's in-params number is valid
function checkParamNum() {
if [ $# -ne 2 ]; then
echo -e "need 2 params num for comparison"
fi
argNum=$1
expectArgNum=$2
if [ ${argNum} -ne ${expectArgNum} ]; then
echo -e "in-params number is not valid, expect: ${expectArgNum}, actual: ${argNum}"
return 1
fi
}
# create python virtual environment
function createVenv() {
expectArgNum=1
checkParamNum $# ${expectArgNum}
venvPath=$1
if [ -d "${venvPath}" ]; then
echo "venv already exists"
else
echo "Creating venv"
python -m venv ${venvPath}
fi
}
# install dependencies
function installDeps() {
# update pip
${VENV_ROOT}/bin/python -m pip install --upgrade pip
# install cli requirements only
${VENV_ROOT}/bin/pip install -r requirements.txt
}
createVenv ${VENV_ROOT}
installDeps