Skip to content

Commit 73c6e33

Browse files
authored
feat: add stable Python binding 🎉 (#1049)
1 parent ed79fcb commit 73c6e33

File tree

127 files changed

+1535
-863
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+1535
-863
lines changed
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
name: Run Tests
1+
name: Build & Test
22

33
on:
44
push:
5-
branches: [v2]
5+
branches:
6+
- main
67
pull_request:
7-
branches: [v2]
88

99
jobs:
1010
test:
@@ -36,8 +36,12 @@ jobs:
3636
run: rustup target add ${{ matrix.target }}
3737
- name: Cache Rust
3838
uses: Swatinem/rust-cache@v2
39+
- name: Install Nextest
40+
run: cargo install cargo-nextest
3941
- name: Build CLI
40-
run: cargo build --verbose --locked --release --target ${{ matrix.target }}
42+
run: cargo build -p cli --verbose --locked --target ${{ matrix.target }}
43+
- name: Run tests
44+
run: cargo nextest run -p cli -p odict --all-features --verbose --target ${{ matrix.target }}
4145
- uses: actions/upload-artifact@v4
4246
if: ${{ failure() }}
4347
with:

.github/workflows/lib-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
uses: dtolnay/rust-toolchain@stable
2121
- name: Cache Rust
2222
uses: Swatinem/rust-cache@v2
23-
- name: Build CLI
23+
- name: Build library
2424
run: cargo publish -p odict
2525
- uses: actions/upload-artifact@v4
2626
if: ${{ failure() }}

.github/workflows/node.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ permissions:
99
id-token: write
1010
'on':
1111
workflow_dispatch:
12+
pull_request:
1213
push:
14+
branches:
15+
- main
1316
tags:
1417
- "node-*"
1518
concurrency:
@@ -115,7 +118,7 @@ jobs:
115118
uses: actions/upload-artifact@v4
116119
with:
117120
name: bindings-${{ matrix.settings.target }}
118-
path: bindings/node/*.node
121+
path: node/*.node
119122
if-no-files-found: error
120123

121124
build-freebsd:
@@ -163,7 +166,7 @@ jobs:
163166
uses: actions/upload-artifact@v4
164167
with:
165168
name: bindings-freebsd
166-
path: bindings/node/*.node
169+
path: node/*.node
167170
if-no-files-found: error
168171
test-macOS-windows-binding:
169172
name: Test bindings on ${{ matrix.settings.target }} - node@${{ matrix.node }}
@@ -202,7 +205,7 @@ jobs:
202205
uses: actions/download-artifact@v4
203206
with:
204207
name: bindings-${{ matrix.settings.target }}
205-
path: bindings/node
208+
path: node
206209
- name: List packages
207210
run: ls -R .
208211
shell: bash
@@ -261,7 +264,7 @@ jobs:
261264
uses: actions/download-artifact@v4
262265
with:
263266
name: bindings-${{ matrix.target }}
264-
path: bindings/node
267+
path: node
265268
- name: List packages
266269
run: ls -R .
267270
shell: bash
@@ -275,7 +278,7 @@ jobs:
275278
with:
276279
image: ${{ steps.docker.outputs.IMAGE }}
277280
options: -v ${{ steps.docker.outputs.PNPM_STORE_PATH }}:${{ steps.docker.outputs.PNPM_STORE_PATH }} -v ${{ github.workspace }}:${{ github.workspace }} -w ${{ github.workspace }} --platform ${{ steps.docker.outputs.PLATFORM }}
278-
run: cd bindings/node && npm run test
281+
run: cd node && npm run test
279282
publish:
280283
name: Publish
281284
runs-on: ubuntu-latest
@@ -297,13 +300,13 @@ jobs:
297300
- name: Download all artifacts
298301
uses: actions/download-artifact@v4
299302
with:
300-
path: bindings/node/artifacts
303+
path: node/artifacts
301304
- name: create npm dirs
302305
run: pnpm --filter="@odict/node" create-dirs
303306
- name: Move artifacts
304307
run: pnpm --filter="@odict/node" artifacts
305308
- name: List packages
306-
run: ls -R ./bindings/node/npm
309+
run: ls -R ./node/npm
307310
shell: bash
308311
- uses: olegtarasov/get-tag@v2.1.3
309312
id: tagName

.github/workflows/python.yml

Lines changed: 258 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,258 @@
1+
# This file is autogenerated by maturin v1.7.8
2+
# To update, run
3+
#
4+
# maturin generate-ci github -m python/Cargo.toml -o .github/workflows/python.yml --pytest
5+
#
6+
name: Python bindings
7+
8+
on:
9+
push:
10+
branches:
11+
- main
12+
tags:
13+
- 'python*'
14+
pull_request:
15+
workflow_dispatch:
16+
17+
permissions:
18+
contents: read
19+
20+
jobs:
21+
linux:
22+
runs-on: ${{ matrix.platform.runner }}
23+
strategy:
24+
matrix:
25+
platform:
26+
- runner: ubuntu-22.04
27+
target: x86_64
28+
- runner: ubuntu-22.04
29+
target: x86
30+
- runner: ubuntu-22.04
31+
target: aarch64
32+
- runner: ubuntu-22.04
33+
target: armv7
34+
- runner: ubuntu-22.04
35+
target: s390x
36+
- runner: ubuntu-22.04
37+
target: ppc64le
38+
steps:
39+
- uses: actions/checkout@v4
40+
- uses: actions/setup-python@v5
41+
with:
42+
python-version: 3.x
43+
- name: Build wheels
44+
uses: PyO3/maturin-action@v1
45+
with:
46+
target: ${{ matrix.platform.target }}
47+
args: --release --out dist --find-interpreter --manifest-path python/Cargo.toml
48+
sccache: 'true'
49+
manylinux: auto
50+
- name: Upload wheels
51+
uses: actions/upload-artifact@v4
52+
with:
53+
name: wheels-linux-${{ matrix.platform.target }}
54+
path: dist
55+
- name: pytest
56+
if: ${{ startsWith(matrix.platform.target, 'x86_64') }}
57+
shell: bash
58+
run: |
59+
set -e
60+
python3 -m venv .venv
61+
source .venv/bin/activate
62+
pip install pyodict --find-links dist --force-reinstall
63+
pip install pytest
64+
pip install syrupy
65+
cd python && pytest
66+
- name: pytest
67+
if: ${{ !startsWith(matrix.platform.target, 'x86') && matrix.platform.target != 'ppc64' }}
68+
uses: uraimo/run-on-arch-action@v2
69+
with:
70+
arch: ${{ matrix.platform.target }}
71+
distro: ubuntu22.04
72+
githubToken: ${{ github.token }}
73+
install: |
74+
apt-get update
75+
apt-get install -y --no-install-recommends python3 python3-pip
76+
pip3 install -U pip pytest syrupy
77+
run: |
78+
set -e
79+
pip3 install pyodict --find-links dist --force-reinstall
80+
cd python && pytest
81+
82+
musllinux:
83+
runs-on: ${{ matrix.platform.runner }}
84+
strategy:
85+
matrix:
86+
platform:
87+
- runner: ubuntu-22.04
88+
target: x86_64
89+
- runner: ubuntu-22.04
90+
target: x86
91+
- runner: ubuntu-22.04
92+
target: aarch64
93+
- runner: ubuntu-22.04
94+
target: armv7
95+
steps:
96+
- uses: actions/checkout@v4
97+
- uses: actions/setup-python@v5
98+
with:
99+
python-version: 3.x
100+
- name: Build wheels
101+
uses: PyO3/maturin-action@v1
102+
with:
103+
target: ${{ matrix.platform.target }}
104+
args: --release --out dist --find-interpreter --manifest-path python/Cargo.toml
105+
sccache: 'true'
106+
manylinux: musllinux_1_2
107+
- name: Upload wheels
108+
uses: actions/upload-artifact@v4
109+
with:
110+
name: wheels-musllinux-${{ matrix.platform.target }}
111+
path: dist
112+
- name: pytest
113+
if: ${{ startsWith(matrix.platform.target, 'x86_64') }}
114+
uses: addnab/docker-run-action@v3
115+
with:
116+
image: alpine:latest
117+
options: -v ${{ github.workspace }}:/io -w /io
118+
run: |
119+
set -e
120+
apk add py3-pip py3-virtualenv
121+
python3 -m virtualenv .venv
122+
source .venv/bin/activate
123+
pip install pyodict --no-index --find-links dist --force-reinstall
124+
pip install pytest
125+
pip install syrupy
126+
cd python && pytest
127+
- name: pytest
128+
if: ${{ !startsWith(matrix.platform.target, 'x86') }}
129+
uses: uraimo/run-on-arch-action@v2
130+
with:
131+
arch: ${{ matrix.platform.target }}
132+
distro: alpine_latest
133+
githubToken: ${{ github.token }}
134+
install: |
135+
apk add py3-virtualenv
136+
run: |
137+
set -e
138+
python3 -m virtualenv .venv
139+
source .venv/bin/activate
140+
pip install pytest
141+
pip install syrupy
142+
pip install pyodict --find-links dist --force-reinstall
143+
cd python && pytest
144+
145+
windows:
146+
runs-on: ${{ matrix.platform.runner }}
147+
strategy:
148+
matrix:
149+
platform:
150+
- runner: windows-latest
151+
target: x64
152+
- runner: windows-latest
153+
target: x86
154+
steps:
155+
- uses: actions/checkout@v4
156+
- uses: actions/setup-python@v5
157+
with:
158+
python-version: 3.x
159+
architecture: ${{ matrix.platform.target }}
160+
- name: Build wheels
161+
uses: PyO3/maturin-action@v1
162+
with:
163+
target: ${{ matrix.platform.target }}
164+
args: --release --out dist --find-interpreter --manifest-path python/Cargo.toml
165+
sccache: 'true'
166+
- name: Upload wheels
167+
uses: actions/upload-artifact@v4
168+
with:
169+
name: wheels-windows-${{ matrix.platform.target }}
170+
path: dist
171+
- name: pytest
172+
if: ${{ !startsWith(matrix.platform.target, 'aarch64') }}
173+
shell: bash
174+
run: |
175+
set -e
176+
python3 -m venv .venv
177+
source .venv/Scripts/activate
178+
pip install pyodict --find-links dist --force-reinstall
179+
pip install pytest
180+
pip install syrupy
181+
cd python && pytest
182+
183+
macos:
184+
runs-on: ${{ matrix.platform.runner }}
185+
strategy:
186+
matrix:
187+
platform:
188+
- runner: macos-13
189+
target: x86_64
190+
- runner: macos-14
191+
target: aarch64
192+
steps:
193+
- uses: actions/checkout@v4
194+
- uses: actions/setup-python@v5
195+
with:
196+
python-version: 3.x
197+
- name: Build wheels
198+
uses: PyO3/maturin-action@v1
199+
with:
200+
target: ${{ matrix.platform.target }}
201+
args: --release --out dist --find-interpreter --manifest-path python/Cargo.toml
202+
sccache: 'true'
203+
- name: Upload wheels
204+
uses: actions/upload-artifact@v4
205+
with:
206+
name: wheels-macos-${{ matrix.platform.target }}
207+
path: dist
208+
- name: pytest
209+
run: |
210+
set -e
211+
python3 -m venv .venv
212+
source .venv/bin/activate
213+
pip install pyodict --find-links dist --force-reinstall
214+
pip install pytest
215+
pip install syrupy
216+
cd python && pytest
217+
218+
sdist:
219+
runs-on: ubuntu-latest
220+
steps:
221+
- uses: actions/checkout@v4
222+
- name: Build sdist
223+
uses: PyO3/maturin-action@v1
224+
with:
225+
command: sdist
226+
args: --out dist --manifest-path python/Cargo.toml
227+
- name: Upload sdist
228+
uses: actions/upload-artifact@v4
229+
with:
230+
name: wheels-sdist
231+
path: dist
232+
233+
release:
234+
name: Release
235+
runs-on: ubuntu-latest
236+
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
237+
needs: [linux, musllinux, windows, macos, sdist]
238+
permissions:
239+
# Use to sign the release artifacts
240+
id-token: write
241+
# Used to upload release artifacts
242+
contents: write
243+
# Used to generate artifact attestation
244+
attestations: write
245+
steps:
246+
- uses: actions/download-artifact@v4
247+
- name: Generate artifact attestation
248+
uses: actions/attest-build-provenance@v1
249+
with:
250+
subject-path: 'wheels-*/*'
251+
- name: Publish to PyPI
252+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
253+
uses: PyO3/maturin-action@v1
254+
env:
255+
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
256+
with:
257+
command: upload
258+
args: --non-interactive --skip-existing wheels-*/*

.github/workflows/test.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)