Skip to content

Commit baa14fc

Browse files
Update PyPI workflow to build and publish Rust wheels across platforms
Build prebuilt wheels for linux (x86_64, aarch64), macOS (x86_64, aarch64), and Windows (x64) for Python 3.10-3.13. Users get the native extension without needing Rust installed. Also adds vector-db-benchmark-rs as an optional dependency (pip install vector-benchmark[rust]). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 2219a3a commit baa14fc

2 files changed

Lines changed: 117 additions & 10 deletions

File tree

.github/workflows/publish-pypi.yml

Lines changed: 114 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,75 @@ on:
55
workflow_dispatch: # Allow manual triggering
66

77
jobs:
8-
pypi:
9-
name: Publish to PyPI
8+
# Build the Rust native extension wheels for each platform/arch
9+
build-rust-wheels:
10+
name: Build Rust wheels (${{ matrix.os }}, ${{ matrix.target }})
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
include:
16+
# Linux x86_64
17+
- os: ubuntu-latest
18+
target: x86_64
19+
# Linux aarch64
20+
- os: ubuntu-latest
21+
target: aarch64
22+
# macOS x86_64
23+
- os: macos-13
24+
target: x86_64
25+
# macOS aarch64 (Apple Silicon)
26+
- os: macos-14
27+
target: aarch64
28+
# Windows x86_64
29+
- os: windows-latest
30+
target: x64
31+
steps:
32+
- uses: actions/checkout@v4
33+
34+
- name: Set up Python
35+
uses: actions/setup-python@v5
36+
with:
37+
python-version: '3.10'
38+
39+
- name: Build wheels
40+
uses: PyO3/maturin-action@v1
41+
with:
42+
target: ${{ matrix.target }}
43+
args: --release --out dist --interpreter 3.10 3.11 3.12 3.13
44+
manylinux: auto
45+
working-directory: rust
46+
47+
- name: Upload wheels
48+
uses: actions/upload-artifact@v4
49+
with:
50+
name: wheels-${{ matrix.os }}-${{ matrix.target }}
51+
path: rust/dist/*.whl
52+
53+
# Build the Rust sdist (fallback for platforms without prebuilt wheels)
54+
build-rust-sdist:
55+
name: Build Rust sdist
56+
runs-on: ubuntu-latest
57+
steps:
58+
- uses: actions/checkout@v4
59+
60+
- name: Build sdist
61+
uses: PyO3/maturin-action@v1
62+
with:
63+
command: sdist
64+
args: --out dist
65+
working-directory: rust
66+
67+
- name: Upload sdist
68+
uses: actions/upload-artifact@v4
69+
with:
70+
name: rust-sdist
71+
path: rust/dist/*.tar.gz
72+
73+
# Build the main Python package
74+
build-python:
75+
name: Build Python package
1076
runs-on: ubuntu-latest
11-
environment:
12-
name: pypi
13-
url: https://pypi.org/p/vector-benchmark
14-
permissions:
15-
contents: read
16-
id-token: write
1777
steps:
1878
- uses: actions/checkout@v4
1979

@@ -37,7 +97,51 @@ jobs:
3797
pip install twine
3898
twine check dist/*
3999
40-
- name: Publish to PyPI
100+
- name: Upload Python dist
101+
uses: actions/upload-artifact@v4
102+
with:
103+
name: python-dist
104+
path: dist/*
105+
106+
# Publish everything to PyPI
107+
publish:
108+
name: Publish to PyPI
109+
runs-on: ubuntu-latest
110+
needs: [build-rust-wheels, build-rust-sdist, build-python]
111+
environment:
112+
name: pypi
113+
url: https://pypi.org/p/vector-benchmark
114+
permissions:
115+
contents: read
116+
id-token: write
117+
steps:
118+
- name: Download all artifacts
119+
uses: actions/download-artifact@v4
120+
with:
121+
path: all-dist
122+
123+
- name: Collect dist files
124+
run: |
125+
mkdir -p dist
126+
# Rust wheels and sdist
127+
find all-dist/wheels-* -name '*.whl' -exec cp {} dist/ \; 2>/dev/null || true
128+
find all-dist/rust-sdist -name '*.tar.gz' -exec cp {} dist/ \; 2>/dev/null || true
129+
# Python package
130+
cp all-dist/python-dist/* dist/
131+
echo "Packages to publish:"
132+
ls -la dist/
133+
134+
- name: Publish Rust extension to PyPI
135+
uses: PyO3/maturin-action@v1
136+
with:
137+
command: upload
138+
args: --non-interactive --skip-existing dist/vector_db_benchmark_rs*
139+
140+
- name: Publish Python package to PyPI
41141
env:
42142
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
43-
run: poetry publish
143+
run: |
144+
pip install poetry
145+
# Publish only the Python package (already built)
146+
pip install twine
147+
twine upload --skip-existing dist/vector_benchmark* dist/vector-benchmark*

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ psycopg = {extras = ["binary"], version = "^3.1.17"}
5353
pgvector = "^0.2.4"
5454
ml-dtypes = "^0.4.0"
5555
boto3 = "^1.39.4"
56+
vector-db-benchmark-rs = {version = ">=0.1.0", optional = true}
5657

58+
[tool.poetry.extras]
59+
rust = ["vector-db-benchmark-rs"]
5760

5861
[tool.poetry.group.dev.dependencies]
5962
pre-commit = "^2.20.0"

0 commit comments

Comments
 (0)