-
Notifications
You must be signed in to change notification settings - Fork 1
/
prj
executable file
·83 lines (63 loc) · 1.54 KB
/
prj
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
#!/usr/bin/env bash
# SPDX-License-Identifier: AGPL-3.0-or-later
# export LANG=C
PRJ_ROOT="$(dirname "${BASH_SOURCE[0]}")"
# shellcheck source=scripts/main.sh
source "${PRJ_ROOT}/scripts/main.sh"
# shellcheck source=scripts/lib_py.sh
scripts.import py
# shellcheck source=scripts/lib_doc-sphinx.sh
scripts.import doc-sphinx
help() {
cat <<EOF
env.build : build project's developer environment
cmd : run command in project's environment
clean : clean up project folder
test : run development tests
build : build dist packages
EOF
doc.help
}
[ "${V}" = "1" ] && set -x
env.build() {
py.env.build
# https://setuptools.pypa.io/en/latest/userguide/development_mode.html
"${PY_VENV}/bin/pip" install -e ".[dev,test]"
env.build.post
}
env.build.post() {
env.source
# _BOTDETECTION_COMPLETE=bash_source pysandbox > "${PY_VENV}/bin/.botdetection-complete.bash"
# _BOTDETECTION_COMPLETE=zsh_source pysandbox > "${PY_VENV}/bin/.botdetection-complete.zsh"
# _BOTDETECTION_COMPLETE=fish_source pysandbox > "${PY_VENV}/bin/.botdetection-complete.fish"
}
env.source() {
py.env.activate
}
cmd() {
( set -e
env.source
"$@"
)
dump_return $?
}
clean() {
( set -e
msg.build CLEAN "clean up project folder"
py.clean
)
}
test() {
( set -e
msg.build TEST "shellcheck ./prj"
shellcheck -x -s bash ./prj
msg.build TEST "pylint ./src"
cmd pylint ./src
)
dump_return $?
}
build() {
msg.build BUILD "python packages"
cmd python -m build
}
main "$@"