-
Notifications
You must be signed in to change notification settings - Fork 6
234 lines (212 loc) · 7.9 KB
/
python.yml
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
name: Python
# spell-checker:ignore armv,autodoc,awalsh,CIBW,gnueabihf,jakebailey,musleabihf
# spell-checker:ignore pkgs,pydata,pyproject,pythonx86,pythonarm64
# spell-checker:ignore sdist,stubtest,xwin
on:
push:
paths:
- .github/workflows/python.yml
- bindings/python/**
- pyproject.toml
- crates/**
- "!crates/oxidd-cli/**"
- "!crates/oxidd-ffi-c/**"
- Cargo.*
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
jobs:
linux:
name: Lint, Test, Doc & Build Wheels for Linux
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: |
pypy3.9
pypy3.10
3.x
- name: Build
run: python -m pip install maturin[zig] mypy ruff -e '.[docs,test]'
- name: Ruff check
run: ruff check --output-format=github
- name: Ruff format check
run: ruff format --check
- name: mypy
run: mypy
- name: stubtest
run: python -m mypy.stubtest oxidd._oxidd
- uses: jakebailey/pyright-action@v2
- name: Test
run: pytest
- name: Sphinx
run: |
mkdir -p target/python/autodoc/oxidd
cp bindings/python/oxidd/*.py target/python/autodoc/oxidd
cp bindings/python/oxidd/_oxidd.pyi target/python/autodoc/oxidd/_oxidd.py
PYTHONPATH=target/python/autodoc sphinx-build bindings/python/doc target/python/doc
- name: Add Rust targets to build wheels
run: |
rustup target add \
x86_64-unknown-linux-gnu x86_64-unknown-linux-musl \
i686-unknown-linux-gnu i686-unknown-linux-musl \
aarch64-unknown-linux-gnu aarch64-unknown-linux-musl \
armv7-unknown-linux-gnueabihf armv7-unknown-linux-musleabihf
- name: Build wheels
run: |
manylinux=manylinux2014
musllinux=musllinux_1_2
maturin sdist --out dist
for target in x86_64-unknown-linux-gnu i686-unknown-linux-gnu aarch64-unknown-linux-gnu armv7-unknown-linux-gnueabihf; do
maturin build --release --out dist --compatibility $manylinux --zig --target $target
done
for target in x86_64-unknown-linux-musl i686-unknown-linux-musl aarch64-unknown-linux-musl armv7-unknown-linux-musleabihf; do
maturin build --release --out dist --compatibility $musllinux --zig --target $target
done
for pypy in pypy3.9 pypy3.10; do
for target in x86_64-unknown-linux-gnu i686-unknown-linux-gnu aarch64-unknown-linux-gnu; do
maturin build --release --out dist --interpreter $pypy --compatibility $manylinux --zig --target $target
done
for target in x86_64-unknown-linux-musl i686-unknown-linux-musl aarch64-unknown-linux-musl; do
maturin build --release --out dist --interpreter $pypy --compatibility $musllinux --zig --target $target
done
done
- name: Test wheels
run: |
run_tests() {
$1 -m venv .venv-$1
.venv-$1/bin/pip install "${2}[test]"
.venv-$1/bin/pytest
}
run_tests python3 dist/oxidd-*-cp*-manylinux*_x86_64*.whl
run_tests pypy3.9 dist/oxidd-*-pp39-*-manylinux*_x86_64*.whl
run_tests pypy3.10 dist/oxidd-*-pp310-*-manylinux*_x86_64*.whl
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: python-wheels-linux
path: dist
- name: Deploy Docs
if: ${{ github.repository == 'OxiDD/oxidd' && github.ref == 'refs/heads/main' }}
working-directory: target/python/doc
run: |
mkdir -p ~/.ssh
echo "$KNOWN_HOSTS" >> ~/.ssh/known_hosts
ssh-agent sh -c "echo '$KEY' | ssh-add - && tar -cvz . | ssh -l '$USER' -p '$PORT' '$HOST' /extract-api.sh python dev"
env:
HOST: ${{ secrets.WEBSITE_SSH_HOST }}
USER: ${{ secrets.WEBSITE_SSH_USER }}
PORT: ${{ secrets.WEBSITE_SSH_PORT }}
KEY: ${{ secrets.WEBSITE_SSH_KEY }}
KNOWN_HOSTS: ${{ secrets.WEBSITE_SSH_KNOWN_HOSTS }}
mac:
name: Build wheels for macOS
runs-on: ${{ matrix.os.image }}
strategy:
matrix:
os:
- { arch: x86_64, image: macos-13 }
- { arch: arm64, image: macos-14 }
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: |
pypy3.9
pypy3.10
3.x
- name: Install Python build dependencies
run: python -m pip install maturin ruff
- name: Build CPython wheel
run: maturin build --release --out dist
- name: Build PyPy 3.9 wheel
run: maturin build --release --out dist --interpreter pypy3.9
- name: Build PyPy 3.10 wheel
run: maturin build --release --out dist --interpreter pypy3.10
- name: Test wheels
run: |
run_tests() {
$1 -m venv .venv-$1
.venv-$1/bin/pip install "${2}[test]"
.venv-$1/bin/pytest
}
run_tests python3 dist/oxidd-*-cp*-*.whl
run_tests pypy3.9 dist/oxidd-*-pp39-*.whl
run_tests pypy3.10 dist/oxidd-*-pp310-*.whl
- uses: actions/upload-artifact@v4
with:
name: python-wheels-mac-${{ matrix.os.arch }}
path: dist
win:
name: Build wheels for Windows
runs-on: windows-2022
steps:
- uses: actions/checkout@v4
- name: Install Rust targets
run: rustup target add x86_64-pc-windows-msvc i686-pc-windows-msvc aarch64-pc-windows-msvc
- name: Install Maturin
uses: baptiste0928/cargo-install@v3
with:
crate: maturin
args: --no-default-features # this is the important part: we don't want xwin
- uses: actions/setup-python@v5
with:
python-version: |
pypy3.9
pypy3.10
3.x
- name: Install Python (i686)
run: nuget install pythonx86 -OutputDirectory .python
- name: Install Python (aarch64)
run: nuget install pythonarm64 -OutputDirectory .python
- name: Install Python build dependencies
run: python -m pip install ruff
- name: Build CPython wheel (x86_64)
run: maturin build --release --out dist
- name: Build PyPy 3.9 wheel (x86_64)
run: maturin build --release --out dist --interpreter "$(where.exe pypy3.9)"
- name: Build PyPy 3.10 wheel (x86_64)
run: maturin build --release --out dist --interpreter "$(where.exe pypy3.10)"
- name: Build CPython wheel (i686)
run: maturin build --release --out dist --interpreter "$(get-item .python\pythonx86*\tools\python.exe)" --target i686-pc-windows-msvc
- name: Build CPython wheel (aarch64)
run: |
$env:PYO3_CROSS_LIB_DIR = "$(get-item .python\pythonarm64*\tools\libs)"
maturin build --release --out dist --target aarch64-pc-windows-msvc
- name: Test
run: |
python -m venv .venv-cp
pypy3.9 -m venv .venv-pp39
pypy3.10 -m venv .venv-pp310
foreach ($py in 'cp', 'pp39', 'pp310') {
& ".venv-$py\Scripts\pip.exe" install "$(get-item dist\oxidd-*-$py*-*amd64.whl)[test]"
& ".venv-$py\Scripts\pytest.exe"
}
& "$(get-item .python\pythonx86*\tools\python.exe)" -m venv .venv-cp-i686
.venv-cp-i686\Scripts\pip.exe install "$(get-item dist\oxidd-*-cp*-*win32.whl)[test]"
.venv-cp-i686\Scripts\pytest.exe
- uses: actions/upload-artifact@v4
with:
name: python-wheels-win
path: dist
release:
name: Release
needs: [linux, mac, win]
if: ${{ github.repository == 'OxiDD/oxidd' && startsWith(github.ref, 'refs/tags/') }}
environment:
name: release
url: https://pypi.org/p/oxidd
permissions:
id-token: write
runs-on: ubuntu-24.04
steps:
- uses: actions/download-artifact@v4
with:
path: dist
pattern: python-wheels-*
merge-multiple: true
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1