You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: build.sh
+49-19Lines changed: 49 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,6 @@
1
+
#!/bin/bash
2
+
set -Eeuo pipefail
3
+
1
4
# this build script is quite forceful about setup - make sure not to mess up the system python
2
5
PYTHON_VENV=$(python -c "import sys; sys.stdout.write('1') if hasattr(sys, 'real_prefix') or sys.base_prefix != sys.prefix else sys.stdout.write('0')")
3
6
if [ "$PYTHON_VENV"== 0 ];then
@@ -8,34 +11,60 @@ fi
8
11
module=${PWD##*/}# get module name - relies on directory name == module name
9
12
module=${module:-/}
10
13
11
-
printf"\nPreparing environment for %s…\n""$module"
12
-
python -m pip install --quiet --upgrade pip
13
-
python -m pip install --quiet setuptools wheel twine mypy sphinx # we don't have a requirements.txt, so easiest just to be sure build dependencies exist every time
14
-
rm -rf dist
15
14
rm -rf build
15
+
rm -rf dist
16
+
17
+
# check and upload built files with whatever python binary is globally set; use custom pyenv pyoslog versions below for building
18
+
python -m pip install --quiet --upgrade pip
19
+
python -m pip install --quiet twine
20
+
21
+
if [ "${1:-0}"=='all' ];then
22
+
versions=(36 37 38 39 310) # run as "./build.sh all" to build with all reasonable python versions
23
+
else
24
+
versions=(default)
25
+
fi
26
+
foriin"${versions[@]}";do
27
+
printf"\nBuilding %s with Python %s\n""$module""$i"
$python_binary -m pip install --quiet setuptools wheel coverage mypy sphinx # we don't have a requirements.txt, so easiest just to be sure build dependencies exist every time
# (the system mode can be restored to default afterwards via: `sudo log config --mode 'level:default'`)
47
+
printf'\nRunning tests and checking coverage for %s…\n'"$module"
48
+
$python_binary -m pip install --quiet pyobjc-framework-OSLog # separated from other installations because it will fail on unsupported platforms
49
+
(cd tests &&$python_binary -m coverage run -m unittest) # note re: test output - we selectively skip tests where they need a macOS version above our minimum
50
+
set +e # in environments we can't test (e.g., no OSLog framework) we don't care if coverage fails
51
+
(cd tests &&$python_binary -m coverage html --include '*/pyoslog/*' --omit '*test*')
52
+
set -e
25
53
26
-
printf'\nBuilding documentation for %s…\n'"$module"
0 commit comments