-
-
Notifications
You must be signed in to change notification settings - Fork 102
/
run.sh
executable file
·155 lines (129 loc) · 3.91 KB
/
run.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
#!/bin/bash
#
# usage: ./run.sh command [argument ...]
#
# Commands used during development / CI.
# Also, executable documentation for project dev practices.
#
# See https://death.andgravity.com/run-sh
# for an explanation of how it works and why it's useful.
# First, set up the environment.
# (Check the notes at the end when changing this.)
set -o nounset
set -o pipefail
set -o errexit
# Change the current directory to the project root.
PROJECT_ROOT=${0%/*}
if [[ $0 != $PROJECT_ROOT && $PROJECT_ROOT != "" ]]; then
cd "$PROJECT_ROOT"
fi
readonly PROJECT_ROOT=$( pwd )
# Store the absolute path to this script (useful for recursion).
readonly SCRIPT="$PROJECT_ROOT/$( basename "$0" )"
# Commands follow.
# System requirements:
# apt install python3-build twine
#
DESIGNER_MODULE_ROOT_DIR="./src/pygubudesigner"
python3bin=$(which python3)
function tests {
cd tests; $python3bin -W default -m unittest -v; cd ..;
}
function build {
$python3bin -m build
}
function upload_testpypi {
build
twine upload --skip-existing -r test_pygubu_designer dist/*
}
function upload_pypi {
build
twine upload --skip-existing -r pygubu_designer_project dist/*
}
function create_pot {
# Pygubu designer
pkg_name="pygubudesigner"
pot_path="$DESIGNER_MODULE_ROOT_DIR/data/locale/pygubu-designer.pot"
ui_files=$(find ${DESIGNER_MODULE_ROOT_DIR}/data/ui -name "*.ui" | sort | paste -d " ")
# echo $ui_files
xgettext \
--package-name $pkg_name \
--language=Glade \
--verbose \
--output=${pot_path} \
$ui_files
py_files=$(find ${DESIGNER_MODULE_ROOT_DIR} -name "*.py" | sort | paste -d " ")
# echo $py_files
xgettext \
--package-name $pkg_name \
--join-existing \
--language=Python \
--keyword=_ \
--verbose \
--output=${pot_path} \
--from-code=UTF-8 \
$py_files
#
# Pygubu
pkg_name="pygubu"
pot_path="$DESIGNER_MODULE_ROOT_DIR/data/locale/pygubu.pot"
PYGUBU_SRC_DIR="../pygubu/src/pygubu"
if [[ -d ${PYGUBU_SRC_DIR} ]];then
py_files=$(find ${PYGUBU_SRC_DIR} -name "*.py" | sort | paste -d " ")
# echo $py_files
xgettext \
--package-name $pkg_name \
--language=Python \
--keyword=_ \
--verbose \
--output=${pot_path} \
--from-code=UTF-8 \
$py_files
fi
}
function update_po {
pot_designer="$DESIGNER_MODULE_ROOT_DIR/data/locale/pygubu-designer.pot"
pot_pygubu="$DESIGNER_MODULE_ROOT_DIR/data/locale/pygubu.pot"
po_files=$(find $DESIGNER_MODULE_ROOT_DIR/data/locale -name "pygubu-designer.po")
for _po in $po_files
do
echo "Merging ${pot_designer} to ${_po}"
msgmerge --verbose $_po ${pot_designer} -U
done
po_files=$(find $DESIGNER_MODULE_ROOT_DIR/data/locale -name "pygubu.po")
for _po in $po_files
do
echo "Merging ${pot_pygubu} to ${_po}"
msgmerge --verbose $_po ${pot_pygubu} -U
done
}
function compile_po {
for _po in $(find ./src/pygubudesigner/data/locale -name "*.po")
do
msgfmt --verbose -o ${_po/.po/.mo} $_po
done
}
function install_from_testpypi {
VENV_DIR=$PROJECT_ROOT"/../venv_testpypi";
if [ -d "$VENV_DIR" ]; then
rm -rf $VENV_DIR;
fi
echo "Creating venv."
python3 -m venv $VENV_DIR
source $VENV_DIR/bin/activate
pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ pygubu
pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ pygubu-designer
pygubu-designer
deactivate
}
# Commands end. Dispatch to command.
"$@"
# Some dev notes for this script.
#
# The commands *require*:
#
# * The current working directory is the project root.
# * The shell options and globals are set as they are.
#
# Inspired by http://www.oilshell.org/blog/2020/02/good-parts-sketch.html
#