Skip to content

BLD: Add Android support - #30412

Merged
rgommers merged 21 commits into
numpy:mainfrom
mhsmith:android
Jul 16, 2026
Merged

rgommers merged 21 commits into
numpy:mainfrom
mhsmith:android

Conversation

@mhsmith

@mhsmith mhsmith commented Dec 10, 2025 •

Copy link
Copy Markdown
Contributor

@mhsmith

mhsmith commented Dec 17, 2025 •

Copy link
Copy Markdown
Contributor Author

The 2.3.2-1 wheels here were built using the following procedure:

  • Use a Linux or Mac machine.
  • Check out this PR.
  • cd to the top-level directory of this repository.
  • git submodule update --init
  • Create and activate a Python 3.13 virtual environment.
  • Run pip install git+https://github.com/mhsmith/cibuildwheel@android-numpy
  • Run cibuildwheel --only cp313-android_ARCH, where ARCH is either arm64_v8a or x86_64.
  • cibuildwheel will attempt to run the test suite on an Android emulator. If you don't want that, set the environment variable CIBW_TEST_SKIP="*".

These wheels pass the entire test suite except for:

  • A number of tests involving floating point exceptions which are expected to occur but don't. The discussion in #29724 indicates this may be caused by slight differences between compilers.
  • 3 tests called test_legacy_pickle, due to bugs in how the testbed handles .gz files. I have a fix for this in python/cpython#142912, which I'll eventually include in the cibuildwheel PR.

On Chaquopy 17, this workaround is required.

@rgommers rgommers left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @mhsmith! It's fine to keep this PR open for reference if that's useful to you, however note that we're unlikely to do another 2.3.x release and even if we did, we'd want the changes to land in main first.

The test suite changes all seem fine, I'd be happy to merge those in a separate PR to main (possibly together with the related changes for iOS, to avoid the duplication).

The hardcoding of longdouble for Android (and iOS) also seems okay and fine to merge separately.

The wheel build changes I'd prefer to not merge, at least until everything upstream is ready and then we can reassess.

@mhsmith

mhsmith commented Dec 30, 2025 •

Copy link
Copy Markdown
Contributor Author

Thanks: I intend to create a set of similar PRs for numpy, pandas, scipy, and scikit-learn, so I can produce wheels of known versions for some Chaquopy users I'm working with. Once these PRs are fully working, I'll retarget them to the main branch of each project to enable them to release Android wheels on PyPI.

Comment thread pyproject.toml Resolved
Comment thread .github/workflows/macos.yml Resolved
@mhsmith
mhsmith changed the base branch from maintenance/2.3.x to main June 25, 2026 00:04
@rgommers

Copy link
Copy Markdown
Member

I'd still be happy to merge all the test changes separately.

In case you haven't seen it yet, we now have NEP 57 — NumPy platform support, defining CPython-like support tiers. It may be reasonable for this PR to aim to promote Android to Tier 3 by adding a CI job, similar to the current Emscripten one.

@mhsmith

mhsmith commented Jul 4, 2026

Copy link
Copy Markdown
Contributor Author

A number of tests involving floating point exceptions which are expected to occur but don't.

These tests can be divided into two groups:

  • Those that only fail for the longdouble type. This was previously seen on FreeBSD (#24876).
  • Those involving division by zero, that fail for all floating point types. This was previously seen on macOS (#19316).

I've marked all of these tests as xfail on Android.

@mhsmith

mhsmith commented Jul 4, 2026

Copy link
Copy Markdown
Contributor Author

This PR is now ready for review. Since the only supported way of building for Android is via cibuildwheel, I think it's enough to add a matrix entry in wheels.yml, rather than adding a whole separate workflow file.

The iOS PR #28759 is also complete, though it's currently blocked on numpy/meson#25.

In case you haven't seen it yet, we now have NEP 57 — NumPy platform support, defining CPython-like support tiers. It may be reasonable for this PR to aim to promote Android to Tier 3 by adding a CI job, similar to the current Emscripten one.

Yes, I'd like to do that. As I understand it, the procedure would be to merge this PR to enable the CI job, and then submit a PR against NEP 57?

@mhsmith
mhsmith marked this pull request as ready for review July 4, 2026 01:16
@rgommers

Copy link
Copy Markdown
Member

Working on integrating the iOS fix now.

As I understand it, the procedure would be to merge this PR to enable the CI job, and then submit a PR against NEP 57?

It'd be fine to do it in this same PR as well, might be even better since the merging of this PR is effectively the Tier 3 promotion.

I think it's enough to add a matrix entry in wheels.yml, rather than adding a whole separate workflow file.

Agreed.

@rgommers rgommers left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks @mhsmith for getting this to the finish line! I'll fix the last minor thing and merge conflict now to see if CI is still happy.

# runner. So we build for ARM on a non-ARM runner, which will skip the tests.
- [ubuntu-24.04, android_arm64_v8a]
- [ubuntu-24.04, android_x86_64]
python: ["cp313"]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I thought about it for a bit; this is okay - it's usually set to the lowest supported Python version, but that's also covered by other jobs, so given that Android requires >=3.13, this is the easiest way to achieve that.

if [[ $OPENBLAS == "android" ]]; then
python -m pip install \
--target $pkgconf_path \
--index-url https://chaquo.com/pypi-upstream/ \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is fine for this file; we wouldn't like it in numpy/numpy-release, but that has its own cibw_before_build.sh which doesn't have to be in sync with this one.

Comment thread pyproject.toml Resolved
@rgommers

Copy link
Copy Markdown
Member

Wheel build job times of 2 minutes for android-arm64_v8a (no tests run, hence very fast) and 11 minutes for android-x86_64 are not a concern, easily fast enough. So we're all set here I think. Let's hit the green button here and add the Tier 3 entry in a follow-up PR.

Thanks again @mhsmith!

@rgommers
rgommers merged commit f67f65a into numpy:main Jul 16, 2026
91 checks passed
@rgommers rgommers added this to the 2.6.0 Release milestone Jul 16, 2026
rgommers added a commit to rgommers/numpy that referenced this pull request Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

36 - Build Build related PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Android Support

2 participants