Skip to content

Commit ef5bc4c

Browse files
committed
refactor: 切换到pyo3
1 parent 3f4be95 commit ef5bc4c

25 files changed

Lines changed: 1327 additions & 751 deletions

.cargo/config.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
1+
[alias]
2+
test-quick = "test --no-default-features"
13
[target.'cfg(all(windows, target_env = "msvc"))']
24
rustflags = ["-C", "target-feature=+crt-static"]
5+
6+
[env]
7+
PYO3_PYTHON = { value = ".venv/Scripts/python.exe", relative = true }

.github/workflows/CI.yml

Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
# This file is autogenerated by maturin v1.12.3
2+
# To update, run
3+
#
4+
# maturin generate-ci github
5+
#
6+
name: CI
7+
8+
on:
9+
push:
10+
branches:
11+
- main
12+
- master
13+
tags:
14+
- '*'
15+
pull_request:
16+
workflow_dispatch:
17+
18+
permissions:
19+
contents: read
20+
21+
jobs:
22+
linux:
23+
runs-on: ${{ matrix.platform.runner }}
24+
strategy:
25+
matrix:
26+
platform:
27+
- runner: ubuntu-22.04
28+
target: x86_64
29+
- runner: ubuntu-22.04
30+
target: x86
31+
- runner: ubuntu-22.04
32+
target: aarch64
33+
- runner: ubuntu-22.04
34+
target: armv7
35+
- runner: ubuntu-22.04
36+
target: s390x
37+
- runner: ubuntu-22.04
38+
target: ppc64le
39+
steps:
40+
- uses: actions/checkout@v6
41+
- uses: actions/setup-python@v6
42+
with:
43+
python-version: 3.x
44+
- name: Build wheels
45+
uses: PyO3/maturin-action@v1
46+
with:
47+
target: ${{ matrix.platform.target }}
48+
args: --release --out dist
49+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
50+
manylinux: auto
51+
- name: Build free-threaded wheels
52+
uses: PyO3/maturin-action@v1
53+
with:
54+
target: ${{ matrix.platform.target }}
55+
args: --release --out dist -i python3.14t
56+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
57+
manylinux: auto
58+
- name: Upload wheels
59+
uses: actions/upload-artifact@v5
60+
with:
61+
name: wheels-linux-${{ matrix.platform.target }}
62+
path: dist
63+
64+
musllinux:
65+
runs-on: ${{ matrix.platform.runner }}
66+
strategy:
67+
matrix:
68+
platform:
69+
- runner: ubuntu-22.04
70+
target: x86_64
71+
- runner: ubuntu-22.04
72+
target: x86
73+
- runner: ubuntu-22.04
74+
target: aarch64
75+
- runner: ubuntu-22.04
76+
target: armv7
77+
steps:
78+
- uses: actions/checkout@v6
79+
- uses: actions/setup-python@v6
80+
with:
81+
python-version: 3.x
82+
- name: Build wheels
83+
uses: PyO3/maturin-action@v1
84+
with:
85+
target: ${{ matrix.platform.target }}
86+
args: --release --out dist
87+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
88+
manylinux: musllinux_1_2
89+
- name: Build free-threaded wheels
90+
uses: PyO3/maturin-action@v1
91+
with:
92+
target: ${{ matrix.platform.target }}
93+
args: --release --out dist -i python3.14t
94+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
95+
manylinux: musllinux_1_2
96+
- name: Upload wheels
97+
uses: actions/upload-artifact@v5
98+
with:
99+
name: wheels-musllinux-${{ matrix.platform.target }}
100+
path: dist
101+
102+
windows:
103+
runs-on: ${{ matrix.platform.runner }}
104+
strategy:
105+
matrix:
106+
platform:
107+
- runner: windows-latest
108+
target: x64
109+
python_arch: x64
110+
- runner: windows-latest
111+
target: x86
112+
python_arch: x86
113+
- runner: windows-11-arm
114+
target: aarch64
115+
python_arch: arm64
116+
steps:
117+
- uses: actions/checkout@v6
118+
- uses: actions/setup-python@v6
119+
with:
120+
python-version: 3.13
121+
architecture: ${{ matrix.platform.python_arch }}
122+
- name: Build wheels
123+
uses: PyO3/maturin-action@v1
124+
with:
125+
target: ${{ matrix.platform.target }}
126+
args: --release --out dist
127+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
128+
- uses: actions/setup-python@v6
129+
with:
130+
python-version: 3.14t
131+
architecture: ${{ matrix.platform.python_arch }}
132+
- name: Build free-threaded wheels
133+
uses: PyO3/maturin-action@v1
134+
with:
135+
target: ${{ matrix.platform.target }}
136+
args: --release --out dist -i python3.14t
137+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
138+
- name: Upload wheels
139+
uses: actions/upload-artifact@v5
140+
with:
141+
name: wheels-windows-${{ matrix.platform.target }}
142+
path: dist
143+
144+
macos:
145+
runs-on: ${{ matrix.platform.runner }}
146+
strategy:
147+
matrix:
148+
platform:
149+
- runner: macos-15-intel
150+
target: x86_64
151+
- runner: macos-latest
152+
target: aarch64
153+
steps:
154+
- uses: actions/checkout@v6
155+
- uses: actions/setup-python@v6
156+
with:
157+
python-version: 3.x
158+
- name: Build wheels
159+
uses: PyO3/maturin-action@v1
160+
with:
161+
target: ${{ matrix.platform.target }}
162+
args: --release --out dist
163+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
164+
- name: Build free-threaded wheels
165+
uses: PyO3/maturin-action@v1
166+
with:
167+
target: ${{ matrix.platform.target }}
168+
args: --release --out dist -i python3.14t
169+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
170+
- name: Upload wheels
171+
uses: actions/upload-artifact@v5
172+
with:
173+
name: wheels-macos-${{ matrix.platform.target }}
174+
path: dist
175+
176+
sdist:
177+
runs-on: ubuntu-latest
178+
steps:
179+
- uses: actions/checkout@v6
180+
- name: Build sdist
181+
uses: PyO3/maturin-action@v1
182+
with:
183+
command: sdist
184+
args: --out dist
185+
- name: Upload sdist
186+
uses: actions/upload-artifact@v5
187+
with:
188+
name: wheels-sdist
189+
path: dist
190+
191+
release:
192+
name: Release
193+
runs-on: ubuntu-latest
194+
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
195+
needs: [linux, musllinux, windows, macos, sdist]
196+
permissions:
197+
# Use to sign the release artifacts
198+
id-token: write
199+
# Used to upload release artifacts
200+
contents: write
201+
# Used to generate artifact attestation
202+
attestations: write
203+
steps:
204+
- uses: actions/download-artifact@v6
205+
- name: Generate artifact attestation
206+
uses: actions/attest-build-provenance@v3
207+
with:
208+
subject-path: 'wheels-*/*'
209+
- name: Install uv
210+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
211+
uses: astral-sh/setup-uv@v7
212+
- name: Publish to PyPI
213+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
214+
run: uv publish 'wheels-*/*'
215+
env:
216+
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}

.github/workflows/main.yml

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

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ target
1919
# and can be added to the global gitignore or merged into this file. For a more nuclear
2020
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
2121
#.idea/
22+
.venv

.vscode/launch.json

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

.vscode/settings.json

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

0 commit comments

Comments
 (0)