Skip to content

Commit e2cb5a4

Browse files
committed
ci: refactor wheel build workflow and move configuration to pyproject.toml
1 parent f54421b commit e2cb5a4

File tree

2 files changed

+43
-100
lines changed

2 files changed

+43
-100
lines changed

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

Lines changed: 19 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -11,53 +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-
# disable repair
48-
CIBW_REPAIR_WHEEL_COMMAND: ""
49-
# Skip cibuildwheel's default i686 sidecar and keep Linux release
50-
# wheels on a portable x86_64 CPU baseline.
51-
CIBW_ARCHS_LINUX: "auto64"
52-
CIBW_ENVIRONMENT_LINUX: CMAKE_ARGS="-DGGML_NATIVE=off"
53-
# Keep macOS release wheels on a portable CPU baseline instead of
54-
# inheriting the hosted runner's native flags.
55-
CIBW_ENVIRONMENT_MACOS: CMAKE_ARGS="-DGGML_NATIVE=off"
22+
uses: pypa/cibuildwheel@v3.4.0
5623
with:
5724
package-dir: .
5825
output-dir: wheelhouse
5926

60-
- uses: actions/upload-artifact@v4
27+
- uses: actions/upload-artifact@v7
6128
with:
6229
name: wheels-${{ matrix.os }}
6330
path: ./wheelhouse/*.whl
@@ -66,25 +33,17 @@ jobs:
6633
name: Build arm64 wheels
6734
runs-on: ubuntu-24.04-arm
6835
steps:
69-
- uses: actions/checkout@v4
36+
- uses: actions/checkout@v6
7037
with:
7138
submodules: "recursive"
7239

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

8645
- name: Upload wheels as artifacts
87-
uses: actions/upload-artifact@v4
46+
uses: actions/upload-artifact@v7
8847
with:
8948
name: wheels_arm64
9049
path: ./wheelhouse/*.whl
@@ -96,90 +55,51 @@ jobs:
9655
fail-fast: false
9756
matrix:
9857
shard:
99-
- name: cp310
100-
build: "cp310-*"
101-
artifact: wheels_riscv64_cp310
102-
- name: cp311
103-
build: "cp311-*"
104-
artifact: wheels_riscv64_cp311
105-
- name: cp312
106-
build: "cp312-*"
107-
artifact: wheels_riscv64_cp312
108-
- name: cp313
109-
build: "cp313-*"
110-
artifact: wheels_riscv64_cp313
111-
- name: cp314
112-
build: "cp314-*"
113-
artifact: wheels_riscv64_cp314
58+
- name: manylinux
59+
build: "*manylinux*"
11460
steps:
115-
- uses: actions/checkout@v4
61+
- uses: actions/checkout@v6
11662
with:
11763
submodules: "recursive"
11864

11965
- name: Set up QEMU
120-
uses: docker/setup-qemu-action@v3
66+
uses: docker/setup-qemu-action@v4
12167
with:
12268
platforms: linux/riscv64
12369

12470
- name: Build wheels
125-
uses: pypa/cibuildwheel@v3.1.2
71+
uses: pypa/cibuildwheel@v3.4.0
12672
env:
127-
CIBW_SKIP: "*musllinux* pp*"
128-
CIBW_REPAIR_WHEEL_COMMAND: ""
12973
CIBW_ARCHS: "riscv64"
13074
# Build riscv64 wheels against a conservative baseline instead of
13175
# enabling RVV-related extensions from the build container.
13276
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"
133-
# Split the emulated riscv64 build into one Python version per job
134-
# to minimize wall-clock time without changing the release artifacts.
13577
CIBW_BUILD: ${{ matrix.shard.build }}
13678
with:
13779
output-dir: wheelhouse
13880

13981
- name: Upload wheels as artifacts
140-
uses: actions/upload-artifact@v4
82+
uses: actions/upload-artifact@v7
14183
with:
142-
name: ${{ matrix.shard.artifact }}
84+
name: wheels_riscv64_${{ matrix.shard.name }}
14385
path: ./wheelhouse/*.whl
14486

14587
build_sdist:
14688
name: Build source distribution
14789
runs-on: ubuntu-latest
14890

14991
steps:
150-
- uses: actions/checkout@v4
92+
- uses: actions/checkout@v6
15193
with:
15294
submodules: "recursive"
15395

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

17898
- name: Build source distribution
17999
run: |
180-
python -m build --sdist
100+
uv build --sdist
181101
182-
- uses: actions/upload-artifact@v4
102+
- uses: actions/upload-artifact@v7
183103
with:
184104
name: sdist
185105
path: ./dist/*.tar.gz
@@ -191,7 +111,7 @@ jobs:
191111
runs-on: ubuntu-latest
192112

193113
steps:
194-
- uses: actions/download-artifact@v4
114+
- uses: actions/download-artifact@v8
195115
with:
196116
merge-multiple: true
197117
path: dist

pyproject.toml

Lines changed: 24 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]
@@ -63,6 +63,7 @@ all = [
6363

6464
[tool.scikit-build]
6565
wheel.packages = ["llama_cpp"]
66+
wheel.py-api = "py3"
6667
cmake.verbose = true
6768
cmake.minimum-version = "3.21"
6869
minimum-version = "0.5.1"
@@ -91,3 +92,25 @@ ignore = ["E712"]
9192

9293
[tool.pytest.ini_options]
9394
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)