Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e2fa97f

Browse filesBrowse files
committed
chore: add github workflow for cross-platform wheels
1 parent 08b16af commit e2fa97f
Copy full SHA for e2fa97f

File tree

Expand file treeCollapse file tree

3 files changed

+134
-1
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+134
-1
lines changed

‎.github/workflows/wheels.yml

Copy file name to clipboard
+111Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
name: Build Wheels
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
tags:
7+
- "*"
8+
9+
jobs:
10+
build_macos_wheels:
11+
name: Build wheels on ${{matrix.os}}-${{matrix.arch}}
12+
runs-on: ${{matrix.os}}
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
include:
17+
- {os: macos-13, arch: x86_64, build: "*"}
18+
- {os: macos-14, arch: arm64, build: "*"}
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
with:
23+
submodules: "recursive"
24+
25+
- name: Build wheels
26+
uses: pypa/cibuildwheel@v2.17.0
27+
if: matrix.arch == 'arm64'
28+
env:
29+
CIBW_ARCHS: ${{ matrix.arch }}
30+
CIBW_BUILD: ${{ matrix.build }}
31+
CIBW_BUILD_FRONTEND: build
32+
CIBW_ENVIRONMENT_MACOS: CMAKE_ARGS='-DLLAMA_METAL=on' DYLD_LIBRARY_PATH="$(pwd)/llama_cpp"
33+
with:
34+
config-file: ./pyproject.toml
35+
36+
- name: Build wheels
37+
uses: pypa/cibuildwheel@v2.17.0
38+
if: matrix.arch == 'x86_64'
39+
env:
40+
CIBW_ARCHS: ${{ matrix.arch }}
41+
CIBW_BUILD: ${{ matrix.build }}
42+
CIBW_BUILD_FRONTEND: build
43+
CIBW_ENVIRONMENT_MACOS: CMAKE_ARGS='-DLLAMA_METAL=off' DYLD_LIBRARY_PATH="$(pwd)/llama_cpp"
44+
with:
45+
config-file: ./pyproject.toml
46+
47+
48+
- uses: actions/upload-artifact@v4
49+
with:
50+
name: cibw-wheels-${{matrix.os}}-${{matrix.arch}}-${{strategy.job-index}}
51+
path: ./wheelhouse/*.whl
52+
53+
54+
build_linux_wheels:
55+
name: Build wheels on ${{matrix.os}}-${{matrix.arch}}
56+
runs-on: ${{matrix.os}}
57+
strategy:
58+
fail-fast: true
59+
matrix:
60+
include:
61+
- {os: ubuntu-latest, arch: x86_64, build: "*"}
62+
- {os: ubuntu-latest, arch: aarch64, build: "*[61]-manylinux_aarch64"}
63+
- {os: ubuntu-latest, arch: aarch64, build: "*[72]-manylinux_aarch64"}
64+
- {os: ubuntu-latest, arch: aarch64, build: "*[83]-manylinux_aarch64"}
65+
- {os: ubuntu-latest, arch: aarch64, build: "*[94]-manylinux_aarch64"}
66+
- {os: ubuntu-latest, arch: aarch64, build: "*[05]-manylinux_aarch64"}
67+
68+
steps:
69+
- uses: actions/checkout@v4
70+
with:
71+
submodules: "recursive"
72+
73+
- name: Set up QEMU
74+
if: matrix.arch == 'aarch64'
75+
uses: docker/setup-qemu-action@v3
76+
with:
77+
platforms: arm64
78+
79+
- name: Build wheels
80+
uses: pypa/cibuildwheel@v2.17.0
81+
env:
82+
CIBW_ARCHS: ${{ matrix.arch }}
83+
CIBW_BUILD: ${{ matrix.build }}
84+
CIBW_BUILD_FRONTEND: build
85+
CIBW_SKIP: '*-musllinux*'
86+
with:
87+
config-file: ./pyproject.toml
88+
89+
90+
- uses: actions/upload-artifact@v4
91+
with:
92+
name: cibw-wheels-${{matrix.os}}-${{matrix.arch}}-${{strategy.job-index}}
93+
path: ./wheelhouse/*.whl
94+
95+
96+
build_sdist:
97+
name: Build source distribution
98+
runs-on: ubuntu-latest
99+
100+
steps:
101+
- uses: actions/checkout@v4
102+
with:
103+
submodules: "recursive"
104+
105+
- name: Build sdist
106+
run: pipx run build --sdist
107+
108+
- uses: actions/upload-artifact@v4
109+
with:
110+
name: cibw-sdist
111+
path: dist/*.tar.gz

‎.gitignore

Copy file name to clipboardExpand all lines: .gitignore
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ share/python-wheels/
4242
.installed.cfg
4343
*.egg
4444
MANIFEST
45+
wheelhouse/
4546

4647
# PyInstaller
4748
# Usually these files are written by a python script from a template
@@ -178,3 +179,4 @@ cython_debug/
178179

179180
# downloaded model .bin files
180181
docker/open_llama/*.bin
182+
install/

‎pyproject.toml

Copy file name to clipboardExpand all lines: pyproject.toml
+21-1Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ requires = ["scikit-build-core[pyproject]>=0.5.1"]
33
build-backend = "scikit_build_core.build"
44

55
[project]
6-
name = "llama_cpp_python"
6+
name = "llama_cpp_python-cross"
77
dynamic = ["version"]
88
description = "Python bindings for the llama.cpp library"
99
readme = "README.md"
@@ -73,3 +73,23 @@ Changelog = "https://llama-cpp-python.readthedocs.io/en/latest/changelog/"
7373

7474
[tool.pytest.ini_options]
7575
testpaths = "tests"
76+
77+
[tool.cibuildwheel]
78+
before-all = "uname -a"
79+
80+
[tool.cibuildwheel.linux]
81+
manylinux-aarch64-image = "quay.io/pypa/manylinux_2_28_aarch64:latest"
82+
manylinux-x86_64-image = "quay.io/pypa/manylinux_2_28_x86_64:latest"
83+
before-all = [
84+
"uname -a",
85+
"yum install -y wget openblas-devel",
86+
"wget https://dl.fedoraproject.org/pub/epel/8/Everything/$(uname -m)/Packages/c/ccache-3.7.7-1.el8.$(uname -m).rpm",
87+
"rpm -Uvh *.rpm",
88+
"dnf install -y ccache",
89+
]
90+
91+
[tool.cibuildwheel.linux.environment]
92+
LIBRARY_PATH = "/project/llama_cpp"
93+
LD_LIBRARY_PATH = "/project/llama_cpp"
94+
RUNPATH = "/project/llama_cpp"
95+
CMAKE_ARGS = "-DLLAMA_BLAS=ON -DLLAMA_BLAS_VENDOR=OpenBLAS"

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.