@@ -12,13 +12,61 @@ set -o nounset # abort on unbound variable
12
12
set -o pipefail # don't hide errors within pipes
13
13
14
14
# For current versions see https://devguide.python.org/versions/
15
- # PYTHON_VERSIONS=('3.9' '3.10' '3.11' '3.12')
16
- PYTHON_VERSIONS=(' 3.11' )
15
+ PYTHON_VERSIONS=(' 3.6' ' 3.7' ' 3.8' ' 3.9' ' 3.10' ' 3.11' ' 3.12' ' 3.13' )
16
+ # PYTHON_VERSIONS=('3.11' '3.12' '3.13')
17
+ # PYTHON_VERSIONS=('3.7')
18
+ # PYTHON_VERSIONS=('3.9' '3.10')
19
+ # PYTHON_VERSIONS=('3.6' '3.7' '3.8' '3.9' '3.10')
20
+ # PYTHON_VERSIONS=('3.8' '3.9' '3.10')
17
21
# Used for venvs
18
22
PYTHON_VENV_ROOT=" ${HOME} /pyenvs"
19
23
PROJECT_NAME=" PyExtPatt"
20
24
# CPP_EXECUTABLE="PyExtPatt"
21
25
26
+ usage ()
27
+ {
28
+ echo " usage: build_all.sh [-d] [-r] [-h, --help]"
29
+ echo " options:"
30
+ echo " -h, --help Print help and exit."
31
+ echo " -d Build documentation (slow)."
32
+ echo " -r Remove and rebuild all virtual environments."
33
+ }
34
+
35
+ # If -h or --help print help.
36
+ for arg in " $@ "
37
+ do
38
+ if [ " $arg " == " --help" ] || [ " $arg " == " -h" ]
39
+ then
40
+ usage
41
+ exit
42
+ fi
43
+ done
44
+
45
+ OPT_REMOVE_REBUILD_VENVS=false
46
+ OPT_BUILD_DOCUMENTATION=false
47
+
48
+ if [[ " $# " -gt 0 ]]; then
49
+ # while [ -n "$1" ]; do # while loop starts
50
+ # case "$1" in
51
+ # -r) OPT_REMOVE_REBUILD_VENVS=true ;; # Remove existing venvs and rebuild them.
52
+ # -d) OPT_BUILD_DOCUMENTATION=true ;; # Build documentation.
53
+ # --)
54
+ # shift # The double dash which separates options from parameters
55
+ # break
56
+ # ;;
57
+ # *) break;;
58
+ # esac
59
+ # shift
60
+ # done
61
+ for arg in " $@ "
62
+ do
63
+ case " $arg " in
64
+ -r) OPT_REMOVE_REBUILD_VENVS=true ;; # Remove existing venvs and rebuild them.
65
+ -d) OPT_BUILD_DOCUMENTATION=true ;; # Build documentation.
66
+ esac
67
+ done
68
+ fi
69
+
22
70
# printf "%-8s %8s %10s %10s %12s\n" "Ext" "Files" "Lines" "Words" "Bytes"
23
71
24
72
# build_cpp() {
@@ -55,6 +103,19 @@ create_virtual_environments() {
55
103
echo " ---> Creating virtual environment at: ${venv_path} "
56
104
" python${version} " -m venv " ${venv_path} "
57
105
fi
106
+ # https://stackoverflow.com/questions/42997258/virtualenv-activate-script-wont-run-in-bash-script-with-set-euo
107
+ set +u
108
+ source " ${venv_path} /bin/activate"
109
+ set -u
110
+ echo " ---> Python version:"
111
+ python -VV
112
+ echo " ---> Installing everything via pip:"
113
+ pip install -U pip setuptools wheel
114
+ pip install -r requirements.txt
115
+ # Needed for uploading to pypi
116
+ pip install twine
117
+ echo " ---> Result of pip install:"
118
+ pip list
58
119
done
59
120
}
60
121
@@ -82,20 +143,22 @@ create_and_test_bdist_wheel() {
82
143
# Control will enter here if directory doesn't exist.
83
144
echo " ---> Creating virtual environment at: ${venv_path} "
84
145
" python${version} " -m venv " ${venv_path} "
146
+ else
147
+ echo " ---> EXISTING Virtual environment at: ${venv_path} "
85
148
fi
86
149
# https://stackoverflow.com/questions/42997258/virtualenv-activate-script-wont-run-in-bash-script-with-set-euo
87
150
set +u
88
151
source " ${venv_path} /bin/activate"
89
152
set -u
90
153
echo " ---> Python version:"
91
154
python -VV
92
- echo " ---> Installing everything via pip:"
93
- pip install -U pip setuptools wheel
94
- pip install -r requirements.txt
95
- # Needed for uploading to pypi
96
- pip install twine
97
- echo " ---> Result of pip install:"
98
- pip list
155
+ # echo "---> Installing everything via pip:"
156
+ # pip install -U pip setuptools wheel
157
+ # pip install -r requirements.txt
158
+ # # Needed for uploading to pypi
159
+ # pip install twine
160
+ # echo "---> Result of pip install:"
161
+ # pip list
99
162
echo " ---> Running python setup.py develop:"
100
163
# MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ python setup.py develop
101
164
python setup.py develop
@@ -106,6 +169,8 @@ create_and_test_bdist_wheel() {
106
169
# pytest tests --runslow --benchmark-sort=name
107
170
# pytest tests -v
108
171
echo " ---> Running setup for bdist_wheel:"
172
+ # Need wheel otherwise bdist_wheel "error: invalid command 'bdist_wheel'"
173
+ pip install wheel
109
174
python setup.py bdist_wheel
110
175
done
111
176
}
@@ -140,8 +205,9 @@ report_all_versions_and_setups() {
140
205
# Control will enter here if directory doesn't exist.
141
206
echo " ---> Creating virtual environment at: ${venv_path} "
142
207
" python${version} " -m venv " ${venv_path} "
208
+ else
209
+ echo " ---> EXISTING Virtual environment at: ${venv_path} "
143
210
fi
144
- echo " ---> Virtual environment at: ${venv_path} "
145
211
# https://stackoverflow.com/questions/42997258/virtualenv-activate-script-wont-run-in-bash-script-with-set-euo
146
212
set +u
147
213
source " ${venv_path} /bin/activate"
@@ -159,6 +225,7 @@ show_results_of_dist() {
159
225
echo " ---> dist/:"
160
226
ls -l " dist"
161
227
echo " ---> twine check dist/*:"
228
+ pip install twine
162
229
twine check dist/*
163
230
# Test from Test PyPi
164
231
# pip install -i https://test.pypi.org/simple/orderedstructs
@@ -176,18 +243,26 @@ show_results_of_dist() {
176
243
echo " ===> Removing build/ and dist/"
177
244
# rm --recursive --force -- "build" "dist"
178
245
rm -rf -- " build" " dist"
246
+
247
+ if [ $OPT_REMOVE_REBUILD_VENVS = true ]; then
179
248
echo " ===> Removing virtual environments"
180
249
remove_virtual_environments
181
250
echo " ===> Creating virtual environments"
182
251
create_virtual_environments
252
+ fi
253
+
183
254
echo " ===> Creating binary wheels"
184
255
create_and_test_bdist_wheel
185
256
echo " ===> Creating source distribution"
186
257
create_sdist
187
258
echo " ===> All versions and setups:"
188
259
report_all_versions_and_setups
260
+
261
+ if [ $OPT_BUILD_DOCUMENTATION = true ]; then
189
262
echo " ===> Building documentation:"
190
263
create_documentation
264
+ fi
265
+
191
266
echo " ===> dist/ result:"
192
267
show_results_of_dist
193
268
# deactivate_virtual_environment
0 commit comments