Skip to content

Commit 9e9ab5e

Browse files
committed
Fix python wheel build and workflows
1 parent 973af21 commit 9e9ab5e

8 files changed

Lines changed: 910 additions & 177 deletions

File tree

.github/workflows-in/api.ys

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
!yamlscript/v0
2+
3+
python-preamble-job =::
4+
runs-on: ${{matrix.config.os}}
5+
strategy:
6+
fail-fast: false
7+
matrix:
8+
config:
9+
- {pythonv: '3.13', os: ubuntu-latest}
10+
- {pythonv: '3.13', os: macos-13}
11+
python-preamble-job-win =::
12+
runs-on: ${{matrix.config.os}}
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
config:
17+
- {pythonv: '3.13', os: windows-latest}
18+
19+
20+
setup-env-win =::
21+
- name: setup env (Visual Studio)
22+
uses: TheMrMilchmann/setup-msvc-dev@v3
23+
with:
24+
arch: ${{matrix.config.vsenvarch}}
25+
26+
27+
python-preamble-steps =::
28+
- name: install python ${{matrix.config.pythonv}}
29+
uses: actions/setup-python@v5
30+
with:
31+
python-version: ${{matrix.config.pythonv}}
32+
- name: deps
33+
run: |
34+
if [[ "${{matrix.config.os}}" == macos* ]] ; then
35+
brew install swig
36+
elif [[ "${{matrix.config.os}}" == windows* ]] ; then
37+
choco install swig
38+
fi
39+
pip install build deprecation pytest
40+
pip install -r requirements.txt
41+
42+
43+
defn python-wheel-steps(name create-wheel-cmd)::
44+
- name:: "------------------- $name"
45+
run: rm -rf build/ dist/
46+
- name:: "create wheel with $create-wheel-cmd"
47+
run:: |
48+
$create-wheel-cmd
49+
- name: install wheel
50+
run: pip install dist/*.whl
51+
- name: test with pytest
52+
run: python -m pytest -vvv api/python/tests
53+
54+
55+
python-wheel-tests =::
56+
- :: python-wheel-steps('using setup.py' 'python setup.py bdist_wheel -v')
57+
- :: python-wheel-steps('using pip' 'pip wheel -w dist/ .')
58+
- :: python-wheel-steps('using pypa/build' 'python -m build --wheel')
59+
60+
61+
python-bare-tests =::
62+
- name: configure
63+
run: |
64+
cmake -B build/py \
65+
-D CMAKE_BUILD_TYPE=Release \
66+
-D BUILD_SHARED_LIBS=ON \
67+
-D RYML_DEFAULT_CALLBACK_USES_EXCEPTIONS=ON \
68+
-D RYML_BUILD_API=ON \
69+
-D RYML_API_TESTS=ON \
70+
-D RYML_BUILD_TESTS=ON
71+
- name: build
72+
run: |
73+
cmake --build build/py -j -v --target ryml-api-python3
74+
cp -fv api/python/ryml/__init__.py build/py/api/python3/.
75+
ls -lFpAR build/py/api/python3/*
76+
- name: test with ctest
77+
run: |
78+
export PYTHONPATH=`pwd`/build/py/api/python3:$PYTHONPATH
79+
cmake --build build/py -j -v --target ryml-api-test-python3
80+
- name: test with pytest
81+
run: |
82+
export PYTHONPATH=`pwd`/build/py/api/python3:$PYTHONPATH
83+
python -m pytest -vvv api/python/tests
84+
85+
86+
---
87+
!yamlscript/v0:
88+
89+
:use common: :all
90+
:: workflow-setup()
91+
92+
jobs:
93+
94+
#----------------------------------------------------
95+
# verify that we can explicitly run the python API
96+
# without creating or installing a wheel
97+
pybare:
98+
:: setup-job('api' 'pybare')
99+
name: pybare/${{matrix.config.pythonv}}/${{matrix.config.os}}
100+
:: python-preamble-job
101+
steps:
102+
- :: checkout-action
103+
- :: python-preamble-steps
104+
- :: python-bare-tests
105+
pybarewin:
106+
:: setup-job('api' 'pybarewin')
107+
name: pybare/${{matrix.config.pythonv}}/${{matrix.config.os}}
108+
:: python-preamble-job-win
109+
steps:
110+
- :: checkout-action
111+
- :: python-preamble-steps
112+
- :: setup-env-win
113+
- :: python-bare-tests
114+
115+
#----------------------------------------------------
116+
# run tests with built+installed wheels
117+
pywheel:
118+
:: setup-job('api' 'pywheel')
119+
name: pywheel/${{matrix.config.pythonv}}/${{matrix.config.os}}
120+
:: python-preamble-job
121+
env:
122+
CMAKE_FLAGS: -DCMAKE_BUILD_TYPE=Release -DCMAKE_VERBOSE_MAKEFILES=ON
123+
steps:
124+
- :: checkout-action
125+
- :: python-preamble-steps
126+
- :: python-wheel-tests
127+
pywheelwin:
128+
:: setup-job('api' 'pywheel_win')
129+
name: pywheel/${{matrix.config.pythonv}}/${{matrix.config.os}}
130+
:: python-preamble-job-win
131+
env:
132+
CMAKE_FLAGS: -DCMAKE_BUILD_TYPE=Release -DCMAKE_VERBOSE_MAKEFILES=ON
133+
steps:
134+
- :: checkout-action
135+
- :: python-preamble-steps
136+
- :: setup-env-win
137+
- :: python-wheel-tests

0 commit comments

Comments
 (0)