Skip to content

Commit 44b94aa

Browse files
committed
ci: refactor wheel build workflow and move configuration to pyproject.toml
1 parent 1bcc5bc commit 44b94aa

2 files changed

Lines changed: 42 additions & 103 deletions

File tree

.github/workflows/build-and-release.yaml

Lines changed: 19 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -11,56 +11,20 @@ jobs:
1111
runs-on: ${{ matrix.os }}
1212
strategy:
1313
matrix:
14-
os: [ubuntu-22.04, windows-2022, macos-14, macos-15]
14+
os: [ubuntu-22.04, windows-2022, macos-15]
1515

1616
steps:
17-
- uses: actions/checkout@v4
17+
- uses: actions/checkout@v6
1818
with:
1919
submodules: "recursive"
2020

21-
# Used to host cibuildwheel
22-
- uses: actions/setup-python@v5
23-
with:
24-
python-version: "3.9"
25-
26-
- name: Install dependencies (Linux/MacOS)
27-
if: runner.os != 'Windows'
28-
run: |
29-
python -m pip install --upgrade pip
30-
python -m pip install uv
31-
RUST_LOG=trace python -m uv pip install -e .[all] --verbose
32-
shell: bash
33-
34-
- name: Install dependencies (Windows)
35-
if: runner.os == 'Windows'
36-
env:
37-
RUST_LOG: trace
38-
run: |
39-
python -m pip install --upgrade pip
40-
python -m pip install uv
41-
python -m uv pip install -e .[all] --verbose
42-
shell: cmd
43-
4421
- name: Build wheels
45-
uses: pypa/cibuildwheel@v2.22.0
46-
env:
47-
# Keep repair disabled by default for non-Linux platforms in this job.
48-
CIBW_REPAIR_WHEEL_COMMAND: ""
49-
# Linux needs auditwheel repair so manylinux and musllinux wheels are
50-
# published with distinct platform tags instead of generic linux tags.
51-
CIBW_REPAIR_WHEEL_COMMAND_LINUX: "auditwheel repair -w {dest_dir} {wheel}"
52-
# Skip cibuildwheel's default i686 sidecar and keep Linux release
53-
# wheels on a portable x86_64 CPU baseline.
54-
CIBW_ARCHS_LINUX: "auto64"
55-
CIBW_ENVIRONMENT_LINUX: CMAKE_ARGS="-DGGML_NATIVE=off"
56-
# Keep macOS release wheels on a portable CPU baseline instead of
57-
# inheriting the hosted runner's native flags.
58-
CIBW_ENVIRONMENT_MACOS: CMAKE_ARGS="-DGGML_NATIVE=off"
22+
uses: pypa/cibuildwheel@v3.4.0
5923
with:
6024
package-dir: .
6125
output-dir: wheelhouse
6226

63-
- uses: actions/upload-artifact@v4
27+
- uses: actions/upload-artifact@v7
6428
with:
6529
name: wheels-${{ matrix.os }}
6630
path: ./wheelhouse/*.whl
@@ -69,25 +33,17 @@ jobs:
6933
name: Build arm64 wheels
7034
runs-on: ubuntu-24.04-arm
7135
steps:
72-
- uses: actions/checkout@v4
36+
- uses: actions/checkout@v6
7337
with:
7438
submodules: "recursive"
7539

7640
- name: Build wheels
77-
uses: pypa/cibuildwheel@v2.22.0
78-
env:
79-
CIBW_SKIP: "*musllinux* pp*"
80-
CIBW_REPAIR_WHEEL_COMMAND: ""
81-
CIBW_ARCHS: "aarch64"
82-
# Keep native arm64 builds on a portable CPU baseline instead of
83-
# tuning wheels to the hosted runner.
84-
CIBW_ENVIRONMENT: CMAKE_ARGS="-DGGML_NATIVE=off"
85-
CIBW_BUILD: "cp38-* cp39-* cp310-* cp311-* cp312-*"
41+
uses: pypa/cibuildwheel@v3.4.0
8642
with:
8743
output-dir: wheelhouse
8844

8945
- name: Upload wheels as artifacts
90-
uses: actions/upload-artifact@v4
46+
uses: actions/upload-artifact@v7
9147
with:
9248
name: wheels_arm64
9349
path: ./wheelhouse/*.whl
@@ -99,90 +55,51 @@ jobs:
9955
fail-fast: false
10056
matrix:
10157
shard:
102-
- name: cp310
103-
build: "cp310-*"
104-
artifact: wheels_riscv64_cp310
105-
- name: cp311
106-
build: "cp311-*"
107-
artifact: wheels_riscv64_cp311
108-
- name: cp312
109-
build: "cp312-*"
110-
artifact: wheels_riscv64_cp312
111-
- name: cp313
112-
build: "cp313-*"
113-
artifact: wheels_riscv64_cp313
114-
- name: cp314
115-
build: "cp314-*"
116-
artifact: wheels_riscv64_cp314
58+
- name: manylinux
59+
build: "*manylinux*"
11760
steps:
118-
- uses: actions/checkout@v4
61+
- uses: actions/checkout@v6
11962
with:
12063
submodules: "recursive"
12164

12265
- name: Set up QEMU
123-
uses: docker/setup-qemu-action@v3
66+
uses: docker/setup-qemu-action@v4
12467
with:
12568
platforms: linux/riscv64
12669

12770
- name: Build wheels
128-
uses: pypa/cibuildwheel@v3.1.2
71+
uses: pypa/cibuildwheel@v3.4.0
12972
env:
130-
CIBW_SKIP: "*musllinux* pp*"
131-
CIBW_REPAIR_WHEEL_COMMAND: ""
13273
CIBW_ARCHS: "riscv64"
13374
# Build riscv64 wheels against a conservative baseline instead of
13475
# enabling RVV-related extensions from the build container.
13576
CIBW_ENVIRONMENT: CMAKE_ARGS="-DGGML_NATIVE=off -DGGML_RVV=off -DGGML_RV_ZFH=off -DGGML_RV_ZVFH=off -DGGML_RV_ZICBOP=off -DGGML_RV_ZIHINTPAUSE=off"
136-
# Split the emulated riscv64 build into one Python version per job
137-
# to minimize wall-clock time without changing the release artifacts.
13877
CIBW_BUILD: ${{ matrix.shard.build }}
13978
with:
14079
output-dir: wheelhouse
14180

14281
- name: Upload wheels as artifacts
143-
uses: actions/upload-artifact@v4
82+
uses: actions/upload-artifact@v7
14483
with:
145-
name: ${{ matrix.shard.artifact }}
84+
name: wheels_riscv64_${{ matrix.shard.name }}
14685
path: ./wheelhouse/*.whl
14786

14887
build_sdist:
14988
name: Build source distribution
15089
runs-on: ubuntu-latest
15190

15291
steps:
153-
- uses: actions/checkout@v4
92+
- uses: actions/checkout@v6
15493
with:
15594
submodules: "recursive"
15695

157-
- uses: actions/setup-python@v5
158-
with:
159-
python-version: "3.9"
160-
161-
- name: Install dependencies (Linux/MacOS)
162-
if: runner.os != 'Windows'
163-
run: |
164-
python -m pip install --upgrade pip
165-
python -m pip install uv
166-
RUST_LOG=trace python -m uv pip install -e .[all] --verbose
167-
python -m uv pip install build
168-
shell: bash
169-
170-
- name: Install dependencies (Windows)
171-
if: runner.os == 'Windows'
172-
env:
173-
RUST_LOG: trace
174-
run: |
175-
python -m pip install --upgrade pip
176-
python -m pip install uv
177-
python -m uv pip install -e .[all] --verbose
178-
python -m uv pip install build
179-
shell: cmd
96+
- uses: astral-sh/setup-uv@v7
18097

18198
- name: Build source distribution
18299
run: |
183-
python -m build --sdist
100+
uv build --sdist
184101
185-
- uses: actions/upload-artifact@v4
102+
- uses: actions/upload-artifact@v7
186103
with:
187104
name: sdist
188105
path: ./dist/*.tar.gz
@@ -194,7 +111,7 @@ jobs:
194111
runs-on: ubuntu-latest
195112

196113
steps:
197-
- uses: actions/download-artifact@v4
114+
- uses: actions/download-artifact@v8
198115
with:
199116
merge-multiple: true
200117
path: dist

pyproject.toml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = ["scikit-build-core[pyproject]>=0.9.2"]
2+
requires = ["scikit-build-core[wheels]>=0.12.2"]
33
build-backend = "scikit_build_core.build"
44

55
[project]
@@ -92,3 +92,25 @@ ignore = ["E712"]
9292

9393
[tool.pytest.ini_options]
9494
testpaths = "tests"
95+
96+
[tool.cibuildwheel]
97+
archs = ["auto64"]
98+
# llama.cpp requires glibc 2.31+. manylinux_2_34 is the oldest manylinux image with glibc 2.31.
99+
# see all manylinux images here: https://github.com/pypa/manylinux
100+
manylinux-x86_64-image = "manylinux_2_34"
101+
manylinux-aarch64-image = "manylinux_2_34"
102+
skip = "*musllinux*" # Segmentation fault occurs on musllinux python 3.10+
103+
test-sources = ["tests", "vendor"]
104+
test-command = "pytest -v ./tests"
105+
test-extras = ["test"]
106+
test-skip = "*_riscv64" # riscv64 cannot install test packages (e.g. numpy, scipy, pydantic-core, hf-xet, etc.)
107+
108+
[tool.cibuildwheel.linux]
109+
before-build = "command -v dnf && dnf install -y openssl-devel || (command -v apk && apk add --no-cache openssl-dev) || true"
110+
repair-wheel-command = "auditwheel repair --exclude 'libcu*' -w {dest_dir} {wheel}" # don't bundle CUDA libraries
111+
112+
[tool.cibuildwheel.linux.environment]
113+
CMAKE_ARGS = "-DGGML_NATIVE=OFF"
114+
115+
[tool.cibuildwheel.macos.environment]
116+
CMAKE_ARGS = "-DGGML_NATIVE=OFF"

0 commit comments

Comments
 (0)