From 9e728a8acf0d24c62bd305b126b0a1f8f501259c Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Tue, 3 Jun 2025 23:35:51 -0400 Subject: [PATCH 1/7] ci: add android test Signed-off-by: Henry Schreiner --- .github/workflows/tests-cibw.yml | 31 +++++++++++++++++++++++++++---- tests/pyproject.toml | 3 +++ 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests-cibw.yml b/.github/workflows/tests-cibw.yml index cd05bf11c9..e706e3213b 100644 --- a/.github/workflows/tests-cibw.yml +++ b/.github/workflows/tests-cibw.yml @@ -22,7 +22,7 @@ jobs: submodules: true fetch-depth: 0 - - uses: pypa/cibuildwheel@v3.0 + - uses: mhsmith/cibuildwheel@android env: PYODIDE_BUILD_EXPORTS: whole_archive with: @@ -30,8 +30,12 @@ jobs: only: cp312-pyodide_wasm32 build-ios: - name: iOS wheel - runs-on: macos-latest + name: iOS wheel ${{ matrix.runs-on }} + runs-on: ${{ matrix.runs-on }} + strategy: + fail-fast: false + matrix: + runs-on: [macos-latest, macos-13] steps: - uses: actions/checkout@v4 with: @@ -40,8 +44,27 @@ jobs: - run: brew upgrade cmake - - uses: pypa/cibuildwheel@v3.0 + - uses: mhsmith/cibuildwheel@android env: CIBW_PLATFORM: ios with: package-dir: tests + + build-android: + name: Android wheel ${{ matrix.runs-on }} + runs-on: ${{ matrix.runs-on }} + strategy: + fail-fast: false + matrix: + runs-on: [macos-latest, macos-13, ubuntu-latest] + steps: + - uses: actions/checkout@v4 + with: + submodules: true + fetch-depth: 0 + + - uses: mhsmith/cibuildwheel@android + env: + CIBW_PLATFORM: android + with: + package-dir: tests diff --git a/tests/pyproject.toml b/tests/pyproject.toml index e58eb581ca..dbb693d753 100644 --- a/tests/pyproject.toml +++ b/tests/pyproject.toml @@ -33,3 +33,6 @@ pyodide.test-groups = ["numpy", "scipy"] ios.test-groups = ["numpy"] ios.xbuild-tools = ["cmake", "ninja"] ios.environment.PIP_EXTRA_INDEX_URL = "https://pypi.anaconda.org/beeware/simple" +android.test-groups = ["numpy"] +android.xbuild-tools = ["cmake", "ninja"] +android.environment.PIP_EXTRA_INDEX_URL = "https://chaquo.com/pypi-13.1" From 866bf0732a4426b4ceaff3708e6d8b80e9a1caee Mon Sep 17 00:00:00 2001 From: Malcolm Smith Date: Thu, 12 Jun 2025 04:57:17 +0100 Subject: [PATCH 2/7] Fix Android tests (#23) * Android tests working * Clarifications --- tests/env.py | 1 + tests/pyproject.toml | 4 +--- tests/test_exceptions.py | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/env.py b/tests/env.py index d234c425d4..95cc1ac611 100644 --- a/tests/env.py +++ b/tests/env.py @@ -6,6 +6,7 @@ import pytest +ANDROID = sys.platform.startswith("android") LINUX = sys.platform.startswith("linux") MACOS = sys.platform.startswith("darwin") WIN = sys.platform.startswith("win32") or sys.platform.startswith("cygwin") diff --git a/tests/pyproject.toml b/tests/pyproject.toml index dbb693d753..c91388ca0d 100644 --- a/tests/pyproject.toml +++ b/tests/pyproject.toml @@ -33,6 +33,4 @@ pyodide.test-groups = ["numpy", "scipy"] ios.test-groups = ["numpy"] ios.xbuild-tools = ["cmake", "ninja"] ios.environment.PIP_EXTRA_INDEX_URL = "https://pypi.anaconda.org/beeware/simple" -android.test-groups = ["numpy"] -android.xbuild-tools = ["cmake", "ninja"] -android.environment.PIP_EXTRA_INDEX_URL = "https://chaquo.com/pypi-13.1" +android.environment.ANDROID_API_LEVEL = "24" # Needed to include libc++ in the wheel. diff --git a/tests/test_exceptions.py b/tests/test_exceptions.py index 921540194a..79b3879034 100644 --- a/tests/test_exceptions.py +++ b/tests/test_exceptions.py @@ -76,7 +76,7 @@ def test_cross_module_exceptions(msg): # TODO: FIXME @pytest.mark.xfail( - "env.MACOS and env.PYPY", + "(env.MACOS and env.PYPY) or env.ANDROID", raises=RuntimeError, reason="See Issue #2847, PR #2999, PR #4324", strict=not env.PYPY, # PR 5569 From 40d6446847b72bb390748efec65b24c0282bf074 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 12 Jun 2025 00:29:17 -0400 Subject: [PATCH 3/7] ci: only use fork on Android Signed-off-by: Henry Schreiner --- .github/workflows/tests-cibw.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests-cibw.yml b/.github/workflows/tests-cibw.yml index e706e3213b..8a28658d50 100644 --- a/.github/workflows/tests-cibw.yml +++ b/.github/workflows/tests-cibw.yml @@ -22,7 +22,7 @@ jobs: submodules: true fetch-depth: 0 - - uses: mhsmith/cibuildwheel@android + - uses: pypa/cibuildwheel@3.0 env: PYODIDE_BUILD_EXPORTS: whole_archive with: @@ -44,7 +44,7 @@ jobs: - run: brew upgrade cmake - - uses: mhsmith/cibuildwheel@android + - uses: pypa/cibuildwheel@3.0 env: CIBW_PLATFORM: ios with: @@ -66,5 +66,6 @@ jobs: - uses: mhsmith/cibuildwheel@android env: CIBW_PLATFORM: android + CIBW_ENVIRONMENT_ANDROID: ANDROID_API_LEVEL="24" with: package-dir: tests From 62fc7dbaf92c5597c3d133f15e2f90d357761058 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 12 Jun 2025 00:29:36 -0400 Subject: [PATCH 4/7] ci: add wheel (missing) Signed-off-by: Henry Schreiner --- .github/workflows/tests-cibw.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/tests-cibw.yml b/.github/workflows/tests-cibw.yml index 8a28658d50..fa72995881 100644 --- a/.github/workflows/tests-cibw.yml +++ b/.github/workflows/tests-cibw.yml @@ -63,6 +63,8 @@ jobs: submodules: true fetch-depth: 0 + - run: pipx install wheel + - uses: mhsmith/cibuildwheel@android env: CIBW_PLATFORM: android From ff75e183fa34a0df66a30b60f27eeb29fd12001e Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 12 Jun 2025 00:36:05 -0400 Subject: [PATCH 5/7] ci: no patchelf? Signed-off-by: Henry Schreiner --- .github/workflows/tests-cibw.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests-cibw.yml b/.github/workflows/tests-cibw.yml index fa72995881..25f5a47b77 100644 --- a/.github/workflows/tests-cibw.yml +++ b/.github/workflows/tests-cibw.yml @@ -22,7 +22,7 @@ jobs: submodules: true fetch-depth: 0 - - uses: pypa/cibuildwheel@3.0 + - uses: pypa/cibuildwheel@v3.0 env: PYODIDE_BUILD_EXPORTS: whole_archive with: @@ -44,7 +44,7 @@ jobs: - run: brew upgrade cmake - - uses: pypa/cibuildwheel@3.0 + - uses: pypa/cibuildwheel@v3.0 env: CIBW_PLATFORM: ios with: @@ -63,7 +63,7 @@ jobs: submodules: true fetch-depth: 0 - - run: pipx install wheel + - run: pipx install wheel patchelf - uses: mhsmith/cibuildwheel@android env: From c137b4f324b2657cce100321689555d04d74eb31 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 12 Jun 2025 00:38:34 -0400 Subject: [PATCH 6/7] ci: forgot pyproject android mention Signed-off-by: Henry Schreiner --- .github/workflows/tests-cibw.yml | 1 + tests/pyproject.toml | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests-cibw.yml b/.github/workflows/tests-cibw.yml index 25f5a47b77..46729d840f 100644 --- a/.github/workflows/tests-cibw.yml +++ b/.github/workflows/tests-cibw.yml @@ -68,6 +68,7 @@ jobs: - uses: mhsmith/cibuildwheel@android env: CIBW_PLATFORM: android + # Needed to include C++ in the wheel CIBW_ENVIRONMENT_ANDROID: ANDROID_API_LEVEL="24" with: package-dir: tests diff --git a/tests/pyproject.toml b/tests/pyproject.toml index c91388ca0d..e58eb581ca 100644 --- a/tests/pyproject.toml +++ b/tests/pyproject.toml @@ -33,4 +33,3 @@ pyodide.test-groups = ["numpy", "scipy"] ios.test-groups = ["numpy"] ios.xbuild-tools = ["cmake", "ninja"] ios.environment.PIP_EXTRA_INDEX_URL = "https://pypi.anaconda.org/beeware/simple" -android.environment.ANDROID_API_LEVEL = "24" # Needed to include libc++ in the wheel. From 8e9e9aca44d56bbf44b8fc4d4d2b5e6b62041654 Mon Sep 17 00:00:00 2001 From: Malcolm Smith Date: Wed, 16 Jul 2025 12:59:01 +0100 Subject: [PATCH 7/7] Fix GHA configuration --- .github/workflows/tests-cibw.yml | 17 ++++++++++++++--- tests/pyproject.toml | 7 +++++-- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tests-cibw.yml b/.github/workflows/tests-cibw.yml index 46729d840f..dd939439f4 100644 --- a/.github/workflows/tests-cibw.yml +++ b/.github/workflows/tests-cibw.yml @@ -63,12 +63,23 @@ jobs: submodules: true fetch-depth: 0 + # GitHub Actions can't currently run the Android emulator on macOS. + - name: Skip Android tests on macOS + if: contains(matrix.runs-on, 'macos') + run: echo "CIBW_TEST_COMMAND=" >> "$GITHUB_ENV" + + # https://github.blog/changelog/2024-04-02-github-actions-hardware-accelerated-android-virtualization-now-available/ + - name: Enable KVM for Android emulator + if: contains(matrix.runs-on, 'ubuntu') + run: | + echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules + sudo udevadm control --reload-rules + sudo udevadm trigger --name-match=kvm + - run: pipx install wheel patchelf - - uses: mhsmith/cibuildwheel@android + - uses: mhsmith/cibuildwheel@android # TODO: update to a released version env: CIBW_PLATFORM: android - # Needed to include C++ in the wheel - CIBW_ENVIRONMENT_ANDROID: ANDROID_API_LEVEL="24" with: package-dir: tests diff --git a/tests/pyproject.toml b/tests/pyproject.toml index e58eb581ca..fa478122d3 100644 --- a/tests/pyproject.toml +++ b/tests/pyproject.toml @@ -1,5 +1,6 @@ -# Warning: this is currently used for pyodide, and is not a general out-of-tree -# builder for the tests (yet). Specifically, wheels can't be built from SDists. +# Warning: this is currently used to test cross-compilation, and is not a general +# out-of-tree builder for the tests (yet). Specifically, wheels can't be built from +# SDists. [build-system] requires = ["scikit-build-core"] @@ -29,6 +30,8 @@ test-sources = ["tests", "pyproject.toml"] test-command = "python -m pytest -o timeout=0 -p no:cacheprovider tests" environment.PIP_ONLY_BINARY = "numpy" environment.PIP_PREFER_BINARY = "1" + +android.environment.ANDROID_API_LEVEL = "24" # Needed to include libc++ in the wheel. pyodide.test-groups = ["numpy", "scipy"] ios.test-groups = ["numpy"] ios.xbuild-tools = ["cmake", "ninja"]