-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathb
executable file
·247 lines (240 loc) · 6.22 KB
/
b
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
#!/bin/bash
# A script to run various automation on rubato
exit_with=0
help_text() {
tab=" "
if [[ $# -ne 0 ]]
then
echo "Unknown arguments: '$@'"
echo "Try './b --help' for more information."
else
echo "Usage: ./b [command] [flags]"
echo ""
echo "Options:"
echo "${tab}help, --help, -h: Show this help manual (default)"
echo "${tab}build, b: Cythonize and build rubato"
echo "${tab}${tab}--force, -f: Force rubato to rebuild"
echo "${tab}demo, dem: Run the demos in quick succession"
echo "${tab}clean, c:"
echo "${tab}${tab}--all, -a: Delete all rubato build files (default)"
echo "${tab}${tab}--dir, -d: Delete only the build directory"
echo "${tab}${tab}--bin, -b: Delete only the binary files"
echo "${tab}${tab}--cython, -c: Delete only the C/C++ files"
echo "${tab}docs, doc:"
echo "${tab}${tab}--save, -s: Build and save the documentation (default)"
echo "${tab}${tab}--live, -l: Start a local server hosting the documentation"
echo "${tab}${tab}--clear, -c: Clear the documentation build directory"
echo "${tab}lint, l: Run linting on rubato"
echo "${tab}test, t: Run the rubato test suite. The next argument is a search term to grep the output with."
echo "${tab}setup, s: Install all needed dependencies for developing rubato"
echo "${tab}precommit, pre: Run the precommit script (run every common test)"
echo "${tab}pypi: Build the project for pypi"
echo "${tab}publish-wheels, wheels <version_name>: Build and publish the wheel to pypi"
fi
}
clean() {
case $1 in
--bin|-b)
echo "Deleting binary files..."
cd rubato
find . -name "*.pyd" -type f -delete
find . -name "*.so" -type f -delete
exit_with="$(expr $?+$exit_with)"
cd ..
;;
--cython|-c)
echo "Deleting cython files..."
cd rubato
find . -name "*.cpp" -not -name "cdraw.cpp" -type f -delete
find . -name "*.c" -type f -delete
exit_with="$(expr $?+$exit_with)"
cd ..
;;
--dir|-d)
echo "Deleting build directory..."
rm -rf build
exit_with="$(expr $?+$exit_with)"
;;
*|--all|-a)
clean --dir --bin --cython
;;
esac
shift
if [[ $# -gt 0 ]]
then
clean "$@"
fi
}
build() {
case $1 in
--force|-f)
clean
build
;;
*)
python setup.py build_ext -j 6 --inplace --define CYTHON_TRACE
exit_with="$(expr $?+$exit_with)"
;;
esac
}
doc() {
SPHINXBUILD="sphinx"
SOURCEDIR="source"
BUILDDIR="./build/html"
BUILDER="dirhtml"
case $1 in
--clear|-c)
cd docs
rm -rf build
cd ..
;;
--live|-l)
./b clean -b
./b doc -c
cd docs
if command -v http-server
then
http-server -p 8001 --cors &
fi
sphinx-autobuild "$SOURCEDIR" "$BUILDDIR" -b $BUILDER $O --watch ../
cd ..
if [[ -d build ]]
then
echo "Restoring binary files..."
./b b >/dev/null
fi
;;
*|--save|-s)
./b clean -b
./b doc -c
cd docs
python -m $SPHINXBUILD -T -b $BUILDER "$SOURCEDIR" "$BUILDDIR"
touch build/html/_modules/robots.txt
cd ..
if [[ -d build ]]
then
echo "Restoring binary files..."
./b b >/dev/null
fi
;;
esac
shift
if [[ $# -gt 0 ]]
then
doc "$@"
fi
}
tests() {
case $1 in
*)
build
if [ -z "$1" ]
then
pytest --cov=rubato tests
else
pytest --cov=rubato tests | grep "$1"
fi
exit_with="$(expr $?+$exit_with)"
;;
esac
}
ogdir="$( pwd )"
cd "$( dirname -- "$0" )"
case $1 in
help|--help|-h)
help_text
;;
build|b)
shift
build "$@"
;;
demo|dem)
./b b
cd demo
./_run_all.sh
;;
clean|c)
shift
clean "$@"
;;
docs|doc)
shift
doc "$@"
;;
lint|l)
./b clean -b
echo "Linting Code..."
pylint rubato
exit_with="$(expr $?+$exit_with)"
if [[ -d build ]]
then
echo "Restoring binary files..."
./b b >/dev/null
exit_with="$(expr $?+$exit_with)"
fi
;;
test|t)
shift
tests "$@"
;;
setup|s)
pip install Cython==3.0.0a11
python setup.py egg_info
pip install --upgrade `grep -v '^\[' *.egg-info/requires.txt`
exit_with="$(expr $?+$exit_with)"
build -f
exit_with="$(expr $?+$exit_with)"
pip install -e .
exit_with="$(expr $?+$exit_with)"
;;
precommit|pre)
./b clean
./b doc
./b l
echo "Building rubato..."
./b t -b >/dev/null
./b t -n
cd demo
./_run_all.sh
cd ..
;;
pypi)
clean
rm -rf dist
python -m build
exit_with="$(expr $?+$exit_with)"
;;
publish-wheels|wheels)
shift
if [[ $# -eq 0 ]]
then
echo "No version specified"
exit 1
fi
rm -rf dist
read -p "Confirm version $1? [y/N]: " -r response
if [[ $response =~ ^[Yy]$ ]]
then
BRANCH="$(git branch --show-current)"
git checkout "$1"
clean
echo "Building wheels..."
python -m build
echo "Uploading wheels..."
python -m twine upload dist/*.whl
git checkout "$BRANCH"
else
echo "Aborting..."
fi
;;
*)
help_text "$@"
;;
esac
cd "$ogdir"
if [[ $exit_with -ne 0 ]]
then
exit 1
else
exit 0
fi