diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 89fb710f..9103b8af 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -145,32 +145,45 @@ jobs: path: wheelhouse/*.whl name: wheels-ios-${{ matrix.runs-on }} - # build_android_wheels: - # name: Android ${{ matrix.runs-on }} - # runs-on: ${{ matrix.runs-on }} - # strategy: - # fail-fast: false - # matrix: - # runs-on: [ubuntu-latest, macos-latest] - # steps: - # - uses: actions/checkout@v4 - # with: - # fetch-depth: 0 - # submodules: true - # - # - uses: mhsmith/cibuildwheel@android - # env: - # CIBW_PLATFORM: android - # - # - name: Verify clean directory - # run: git diff --exit-code - # shell: bash - # - # - name: Upload wheels - # uses: actions/upload-artifact@v4 - # with: - # path: wheelhouse/*.whl - # name: wheels-android-${{ matrix.runs-on }} + build_android_wheels: + name: Android ${{ matrix.runs-on }} + runs-on: ${{ matrix.runs-on }} + strategy: + fail-fast: false + matrix: + runs-on: [ubuntu-latest, macos-latest] + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + submodules: true + + # 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 + + - uses: pypa/cibuildwheel@v3.1 + env: + CIBW_PLATFORM: android + + - name: Verify clean directory + run: git diff --exit-code + shell: bash + + - name: Upload wheels + uses: actions/upload-artifact@v4 + with: + path: wheelhouse/*.whl + name: wheels-android-${{ matrix.runs-on }} upload_all: name: Upload if release diff --git a/pyproject.toml b/pyproject.toml index 25c8f504..068cd28e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -208,11 +208,11 @@ xbuild-tools = ["cmake", "ninja"] test-command = "python -m pytest --benchmark-disable tests" environment.PIP_EXTRA_INDEX_URL = "https://pypi.anaconda.org/beeware/simple/" -# [tool.cibuildwheel.android] -# build-frontend = "build" -# xbuild-tools = ["cmake", "ninja"] -# test-command = "pytest --benchmark-disable tests" -# environment.PIP_EXTRA_INDEX_URL = "https://chaquo.com/pypi-13.1" +[tool.cibuildwheel.android] +build-frontend = "build" +test-command = "python -m pytest --benchmark-disable tests" +environment.ANDROID_API_LEVEL = "24" +environment.PIP_EXTRA_INDEX_URL = "https://chaquo.com/pypi-13.1" [[tool.cibuildwheel.overrides]] select = "pp310-macosx_arm64"