Skip to content

Commit e15305f

Browse files
authored
Update build-wheels-metal.yaml
1 parent 39e74ca commit e15305f

File tree

1 file changed

+38
-54
lines changed

1 file changed

+38
-54
lines changed

.github/workflows/build-wheels-metal.yaml

Lines changed: 38 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -6,79 +6,63 @@ permissions:
66
contents: write
77

88
jobs:
9-
define_matrix:
10-
name: Define Build Matrix
11-
runs-on: ubuntu-latest
12-
outputs:
13-
matrix: ${{ steps.set-matrix.outputs.matrix }}
14-
defaults:
15-
run:
16-
shell: pwsh
17-
18-
steps:
19-
- name: Define Job Output
20-
id: set-matrix
21-
run: |
22-
$matrix = @{
23-
'os' = @('macos-12', 'macos-13', 'macos-14')
24-
'pyver' = @('3.9', '3.10', '3.11', '3.12')
25-
}
26-
27-
$matrixOut = ConvertTo-Json $matrix -Compress
28-
Write-Output ('matrix=' + $matrixOut) >> $env:GITHUB_OUTPUT
29-
309
build_wheels:
31-
name: ${{ matrix.os }} Python ${{ matrix.pyver }}
32-
needs: define_matrix
10+
name: Build wheels on ${{ matrix.os }}
3311
runs-on: ${{ matrix.os }}
3412
strategy:
35-
matrix: ${{ fromJSON(needs.define_matrix.outputs.matrix) }}
36-
env:
37-
OSVER: ${{ matrix.os }}
13+
matrix:
14+
os: [macos-12, macos-13, macos-14]
3815

3916
steps:
4017
- uses: actions/checkout@v4
4118
with:
4219
submodules: "recursive"
4320

21+
# Used to host cibuildwheel
4422
- uses: actions/setup-python@v5
4523
with:
46-
python-version: ${{ matrix.pyver }}
24+
python-version: "3.12"
4725
cache: 'pip'
4826

49-
- name: Install Dependencies
27+
- name: Install dependencies
5028
run: |
51-
python -m pip install build wheel cmake
29+
python -m pip install --upgrade pip
30+
python -m pip install -e .[all]
5231
53-
- name: Build Wheel
54-
run: |
55-
XCODE15PATH="/Applications/Xcode_15.0.app/Contents/Developer"
56-
XCODE15BINPATH="${XCODE15PATH}/Toolchains/XcodeDefault.xctoolchain/usr/bin"
57-
export CMAKE_ARGS="-DLLAMA_NATIVE=off -DLLAMA_METAL=on"
58-
[[ "$OSVER" == "macos-13" ]] && export CC="${XCODE15BINPATH}/cc" && export CXX="${XCODE15BINPATH}/c++" && export MACOSX_DEPLOYMENT_TARGET="13.0"
59-
[[ "$OSVER" == "macos-12" ]] && export MACOSX_DEPLOYMENT_TARGET="12.0"
60-
# [[ "$OSVER" == "macos-11" ]] && export MACOSX_DEPLOYMENT_TARGET="11.0"
61-
62-
export CMAKE_OSX_ARCHITECTURES="arm64" && export ARCHFLAGS="-arch arm64"
63-
VERBOSE=1 python -m build --wheel
64-
65-
if [[ "$OSVER" == "macos-13" ]]; then
66-
export SDKROOT="${XCODE15PATH}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk"
67-
export MACOSX_DEPLOYMENT_TARGET="14.0"
68-
VERBOSE=1 python -m build --wheel
69-
fi
32+
- name: Build wheels
33+
uses: pypa/cibuildwheel@v2.17.0
34+
env:
35+
# disable repair
36+
CIBW_REPAIR_WHEEL_COMMAND: ""
37+
CIBW_ARCHS: "arm64"
38+
CIBW_ENVIRONMENT: CMAKE_ARGS="-DCMAKE_OSX_ARCHITECTURES=arm64 -DCMAKE_APPLE_SILICON_PROCESSOR=arm64 -DLLAMA_METAL=on"
39+
CIBW_BUILD: "cp39-* cp310-* cp311-* cp312-* pp39-* pp310-*"
40+
with:
41+
package-dir: .
42+
output-dir: wheelhouse
7043

71-
for file in ./dist/*.whl; do cp "$file" "${file/arm64.whl/aarch64.whl}"; done
44+
- uses: actions/upload-artifact@v4
45+
with:
46+
name: wheels-mac_${{ matrix.os }}
47+
path: ./wheelhouse/*.whl
7248

73-
# export CMAKE_OSX_ARCHITECTURES="x86_64" && export CMAKE_ARGS="-DLLAMA_NATIVE=off -DLLAMA_AVX=off -DLLAMA_AVX2=off -DLLAMA_FMA=off -DLLAMA_F16C=off -DLLAMA_METAL=on" && export ARCHFLAGS="-arch x86_64"
74-
# VERBOSE=1 python -m build --wheel
49+
release:
50+
name: Release
51+
needs: [build_wheels]
52+
runs-on: ubuntu-latest
7553

76-
# if [[ "$OSVER" == "macos-13" ]]; then
77-
# export SDKROOT="${XCODE15PATH}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk"
78-
# export MACOSX_DEPLOYMENT_TARGET="14.0"
79-
# VERBOSE=1 python -m build --wheel
80-
# fi
54+
steps:
55+
- uses: actions/download-artifact@v4
56+
with:
57+
merge-multiple: true
58+
path: dist
8159

60+
- uses: softprops/action-gh-release@v2
61+
with:
62+
files: dist/*
63+
env:
64+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
65+
8266
- uses: softprops/action-gh-release@v2
8367
with:
8468
files: dist/*

0 commit comments

Comments
 (0)