Skip to content

Commit 10f7cb4

Browse files
ci: add Android wheels / tests (#173)
* ci: add Android wheels / tests * style: pre-commit fixes * Update cibw-cc.yaml * Update pyproject.toml * Update cibw-cc.yaml * chore: use commit with fix Signed-off-by: Henry Schreiner <[email protected]> * fix: android level for C++ Signed-off-by: Henry Schreiner <[email protected]> * fix: add patchelf Signed-off-by: Henry Schreiner <[email protected]> * Update cibw-cc.yaml * ci: pull in config from pybind11's tests Signed-off-by: Henry Schreiner <[email protected]> --------- Signed-off-by: Henry Schreiner <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent cc95553 commit 10f7cb4

File tree

2 files changed

+43
-23
lines changed

2 files changed

+43
-23
lines changed

.github/workflows/cibw-cc.yaml

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,46 +4,62 @@ on:
44
workflow_dispatch:
55
pull_request:
66
branches:
7-
- master
7+
- master
88

99
concurrency:
1010
group: ${{ github.workflow }}-${{ github.ref }}
1111
cancel-in-progress: true
1212

13+
1314
jobs:
14-
build-pyodide:
15-
name: Pyodide
16-
runs-on: ubuntu-latest
15+
build:
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
include:
20+
- platform: android
21+
os: macos-13
22+
- platform: android
23+
os: macos-latest
24+
- platform: ios
25+
os: macos-latest
26+
archs: all
27+
- platform: pyodide
28+
os: ubuntu-latest
29+
30+
name: ${{ matrix.platform }} on ${{ matrix.os }}
31+
runs-on: ${{ matrix.os }}
32+
1733
steps:
1834
- uses: actions/checkout@v4
1935

2036
- uses: actions/setup-python@v5
2137

22-
- uses: pypa/[email protected]
23-
env:
24-
CIBW_PLATFORM: pyodide
38+
- if: matrix.platform == 'ios'
39+
run: brew upgrade cmake
2540

26-
- uses: actions/upload-artifact@v4
27-
with:
28-
name: wheels-pyodide
29-
path: dist/*.whl
41+
# GitHub Actions can't currently run the Android emulator on macOS.
42+
- name: Skip Android tests on macOS
43+
if: runner.os == 'macOS'
44+
run: echo "CIBW_TEST_COMMAND=" >> "$GITHUB_ENV"
3045

31-
build-ios:
32-
name: iOS
33-
runs-on: macos-latest
34-
steps:
35-
- uses: actions/checkout@v4
36-
37-
- uses: actions/setup-python@v5
46+
# https://github.blog/changelog/2024-04-02-github-actions-hardware-accelerated-android-virtualization-now-available/
47+
- name: Enable KVM for Android emulator
48+
if: runner.os == 'Linux' && matrix.platform == 'android'
49+
run: |
50+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
51+
sudo udevadm control --reload-rules
52+
sudo udevadm trigger --name-match=kvm
3853
39-
- run: brew upgrade cmake
54+
- if: matrix.platform == 'android'
55+
run: pipx install patchelf
4056

41-
- uses: pypa/cibuildwheel@v3.1
57+
- uses: pypa/cibuildwheel@63bdd4f043a77f1bd23b2ba9376972b6dc7b4779
4258
env:
43-
CIBW_PLATFORM: ios
44-
CIBW_ARCHS: all
59+
CIBW_PLATFORM: ${{ matrix.platform }}
60+
CIBW_ARCHS: ${{ matrix.archs || 'auto' }}
4561

4662
- uses: actions/upload-artifact@v4
4763
with:
48-
name: wheels-ios
64+
name: wheels-${{ matrix.platform }}-${{ matrix.os }}
4965
path: dist/*.whl

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ build-frontend = {name = "build", args = ["--exports", "whole_archive"]}
6262
build-frontend = "build"
6363
xbuild-tools = ["cmake", "ninja"]
6464

65+
[tool.cibuildwheel.android]
66+
build-frontend = "build"
67+
environment.ANDROID_API_LEVEL = "24"
68+
6569
[tool.ruff.lint]
6670
extend-select = [
6771
"B", # flake8-bugbear

0 commit comments

Comments
 (0)