Skip to content

Add Android wheels support via cibuildwheel - #283

Open
pawank925 wants to merge 5 commits into
openzim:mainfrom
pawank925:android-wheels
Open

pawank925 wants to merge 5 commits into
openzim:mainfrom
pawank925:android-wheels

Conversation

@pawank925

@pawank925 pawank925 commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Build Android and wheels with CPython 3.13+. Download prebuilt libzim Android binaries, adjust packaging/rpaths for Android toolchain. Add opt-in Android job to wheels CI.

thanks to @benoit74 for suggestion

Closes #167

@codecov

codecov Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.09%. Comparing base (e6af0b4) to head (f4eecc2).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #283   +/-   ##
=======================================
  Coverage   94.09%   94.09%           
=======================================
  Files           1        1           
  Lines         542      542           
=======================================
  Hits          510      510           
  Misses         32       32           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Build Android arm64_v8a and x86_64 wheels with CPython 3.13+. Download
prebuilt libzim Android binaries and adjust packaging/rpaths for Android
toolchain. Add opt-in Android job to CI wheels workflow.

Closes openzim#167
Comment thread .github/workflows/CI-wheels.yaml Outdated
Comment thread .github/workflows/CI-wheels.yaml Outdated
Comment thread pyproject.toml Outdated
Comment thread setup.py Outdated
steps:
- uses: actions/checkout@v7

- name: Build Android wheels

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this working straight on ubuntu-26.04 while we have to setup QEMU for normal linux wheels? Should we drop QEMU from normal linux wheels?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Android wheels are cross-compiled with the NDK on the host, so nothing arm64 has to run and QEMU is not involved. The Linux aarch64 wheels are different: cibuildwheel builds them inside an arm64 manylinux container, so on an x86_64 runner QEMU is what allows that container to run at all. Dropping QEMU would only work with native arm64 runners (or by cross-compiling Linux aarch64 ourselves), so I would keep it for the Linux job.

@pawank925

Copy link
Copy Markdown
Contributor Author

Addressed the review feedback.

  • Use a frozenset for Android triplets and a mapping dict (removed noqa).
  • Drop duplicate LIBZIM_DL_VERSION from [tool.cibuildwheel.android].
  • Build Android wheels in CI on PRs/pushes (removed experimental label and manual dispatch gate).

@pawank925
pawank925 marked this pull request as draft October 23, 2026 09:04
@pawank925
pawank925 marked this pull request as ready for review October 23, 2026 09:16
@pawank925

pawank925 commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor Author

hit a blocker while getting the Android wheel to actually build: the published Android libzim binaries are reader-only, so the extension cannot link its writer bindings.

Evidence (arm64 archives from download.openzim.org/release/libzim):

Archive include/zim/writer/ _ZN3zim6writer* symbols
libzim_android-arm64-9.2.3-2 yes 201
libzim_android-arm64-9.8.2-1 no 0

Linux/macOS archives still ship the writer headers and symbols.

libzim/libwrapper.cpp includes <zim/writer/item.h> and binds zim::writer::Creator, so with 9.8.2-1 the build fails at compile time (zim/writer/item.h: No such file or directory), and even if the headers were supplied it would fail at link because the symbols are absent.

Options:

  1. Publish Android libzim builds with writer enabled (preferred; consistent with other platforms).
  2. Build libzim from source for Android in this CI (cross-compiling xapian/ICU/zstd/lzma for the NDK). Large, likely out of scope for this PR.
  3. Ship a reader-only Android wheel by compiling out the writer API. Breaking API, not recommended.

@benoit74

Copy link
Copy Markdown
Contributor

@kelson42 any reason to have limited Android libzim builds to "reader-only"? Where should I open an issue?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build and publish wheels for common Android architectures

2 participants