Skip to content

BLD: Add support for building iOS wheels - #28759

Merged
rgommers merged 51 commits into
numpy:mainfrom
freakboy3742:ios-support
Jul 17, 2026
Merged

BLD: Add support for building iOS wheels#28759
rgommers merged 51 commits into
numpy:mainfrom
freakboy3742:ios-support

Conversation

@freakboy3742

@freakboy3742 freakboy3742 commented Apr 18, 2025

Copy link
Copy Markdown
Contributor

Adds iOS as a test and release target for NumPy.

UPDATE: 17 July 2026 This PR is now ready for review. PR body reflects current status.

In an environment where:

  • Xcode and the iOS SDK is installed, with all licences accepted.
  • cibuildwheel 4.1.0 is installed
  • ninja is available on the path

This branch will build and test accelerated iOS simulator wheels:

CIBW_PLATFORM=ios CIBW_ENVIRONMENT="IPHONEOS_DEPLOYMENT_TARGET=17.0" cibuildwheel --arch arm64_iphonesimulator

You can also specify arm64_iphoneos for device wheels, or x86_64_iphonesimulator for simulator wheels on older hardware.

The build will also work without the IPHONEOS_DEPLOYMENT_TARGET definition, but with the older LP64 version of accelerate (this is the analog of the MACOSX_DEPLOYMENT_TARGET=14.0 configuration, except that there isn't a pre-compiled openBLAS for iOS to fall back on). To build with a lower minimum iOS version, run:

CIBW_PLATFORM=ios CIBW_BUILD="cp3*" CIBW_CONFIG_SETTINGS="setup-args=-Duse-ilp64=false setup-args=-Dallow-noblas=true build-dir=build" cibuildwheel --archs arm64_iphonesimulator

@rgommers

Copy link
Copy Markdown
Member

Thanks @freakboy3742. This looks pretty clean. The vendored-meson changes are integrated in the main branch of this repo now that gh-28860 is merged. I'd be fine with merging the npy_cblas.h and numpy/meson.build changes in this PR separate if that helps you, those changes look good to go.

@freakboy3742

Copy link
Copy Markdown
Contributor Author

And update; after discussions on the mesonbuild/meson-python#731, some additional changes to meson (mesonbuild/meson#14541) and CPython (python/cpython#133184) were identified. I'm working on getting those changes upstreamed.

@henryiii

Copy link
Copy Markdown
Contributor

cibuildwheel 3.0 out. :)

@freakboy3742

Copy link
Copy Markdown
Contributor Author

cibuildwheel 3.0 out. :)

Awesome! A new meson-python release is only remaining blocker.

@freakboy3742

freakboy3742 commented Jul 29, 2025

Copy link
Copy Markdown
Contributor Author

Status update: With the current main branch of meson-python, numpy/meson#22 applied to the meson-python branch, and the current main branch of cibuildwheel, this passes the full test suite on iOS under both Python 3.13 and 3.14.

The changes to the test suite changes involve:

  1. making test skips that were WASM-specific into a more generic test skip when subprocess isn't available, or
  2. making known macOS-specific test skips generic to all Apple platforms.

On top of those changes, there's one specific change to ctypes handling to account for the odd way that iOS handles dynamic loading, and one workaround for a pytest issue (related to getuser() and the creation of temporary files).

Comment thread numpy/testing/_private/utils.py Outdated
@rgommers

Copy link
Copy Markdown
Member

The test changes seem fine to me.

@freakboy3742

Copy link
Copy Markdown
Contributor Author

I've added CI workflows, and updated cibuildwheel and vendored-meson versions; the meson-python release is the only outstanding TODO.

I've updated the description of the PR to reflect current status, and a couple of notable design decisions.

"version with a fix (0.3.33.112) or BLAS metadata is not "
"sufficient to identify the BLAS implementation."
)
raise

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.

This modification isn't iOS specific - I've added it because of this build failure on Android.

(Tagging @mhsmith for visibility)

@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.

This looks very close, only a few minor things in the diff. The main remaining issue is the CI config: you're adding 6 jobs here, which is fine for testing on this PR, but it's way too much to merge - I already see the CI queue backing up because of the limited macOS runner concurrency. Two points

  1. There's no need to duplicate testing of the same platform/blas config between ios.yml and wheels.yml. The former even invokes cibuildwheel anyway, so it looks like a 100% duplication.
  2. I wouldn't test the path with no Accelerate linkage in CI, that's of very limited real-world value and pretty unlikely to regress anyway.

It looks to me like two CI jobs is the way to go here: one for arm64_iphoneos and one for arm64_iphonesimulator. Two wheels.yml entries would cover that, meaning the ios.yml can be removed completely, unless I am missing something here.

Comment thread .github/workflows/ios.yml Outdated
Comment thread .github/workflows/ios.yml Outdated
Comment thread numpy/_core/tests/test_multithreading.py Outdated
Comment thread pyproject.toml Outdated
Comment thread pyproject.toml Outdated
Comment thread pyproject.toml Outdated
Comment thread .github/workflows/wheels.yml Outdated
@freakboy3742

Copy link
Copy Markdown
Contributor Author

I've merged with main as of today - and this PR is finally ready for review 🎉

There's one fix in this PR that isn't related to iOS - I got a test failure on Android that appears to be caused by a multithreading issue with OpenBlas - see the comment inline.

I've also been able to fix the issue with x86-64 simulator support. The downside: the x86-64 simulator CI pass is slow - it takes 40+ minutes to run the test suite. This is a combination of a known issue with GitHub Actions, and the fact that x86-64 macOS hardware is older and slower. As a result, a CI pass running python 3.13, 3.14 and 3.15 takes over 2 hours.

That's obviously a significant choke point on limited macOS runners. Given that x86-64 support on macOS (and thus iOS) is deprecated and near EOL anyway, I've opted to keep the code to support x86-64 iOS simulators in place (as it was essentially 2 lines of Meson config), but removed the CI configuration.

@rgommers

Copy link
Copy Markdown
Member

Our comments just crossed:)

I've opted to keep the code to support x86-64 iOS simulators in place (as it was essentially 2 lines of Meson config), but removed the CI configuration.

This sounds like the right call. We have support for lots of legacy and niche platforms, and we'll continue to accept patches as needed, but we indeed can't cover everything in CI.

@mattip

mattip commented Jul 17, 2026

Copy link
Copy Markdown
Member

I got a test failure on Android that appears to be caused by a multithreading issue with OpenBlas - see the #28759 (comment).

We are at 0.3.33.201, and OpenBLAS just released 0.3.24, I will be updating our build soon to 0.3.24. What do I need to do to get scipy-openblas to build the needed wheels?

@freakboy3742

Copy link
Copy Markdown
Contributor Author

I got a test failure on Android that appears to be caused by a multithreading issue with OpenBlas - see the #28759 (comment).

We are at 0.3.33.201, and OpenBLAS just released 0.3.24, I will be updating our build soon to 0.3.24. What do I need to do to get scipy-openblas to build the needed wheels?

I'll have to defer to @mhsmith on that one - the OpenBLAS package is currently being installed from a ChaquoPy wheel store, providing 0.3.33. I'm not familiar with the process for publishing to that store.

@freakboy3742

Copy link
Copy Markdown
Contributor Author

... and we have a green board!

@rgommers I think I've addressed all your comments; let me know if you need anything else to land this!

@rgommers

Copy link
Copy Markdown
Member

Thanks @freakboy3742. The last commits all look good. The main remaining thing is the one in my review comment above. You still have 5 CI jobs here, including 2 quite slow ones. I think a sparse test matrix of 2 jobs is appropriate at this point.

@freakboy3742

Copy link
Copy Markdown
Contributor Author

Thanks @freakboy3742. The last commits all look good. The main remaining thing is the one in my review comment above. You still have 5 CI jobs here, including 2 quite slow ones. I think a sparse test matrix of 2 jobs is appropriate at this point.

My apologies - between the overlapped responses I misunderstood the request on that one.

I've now removed the ios workflow, and modified the wheels workflow to run 2 jobs - one sim, one device, both arm64 and ILP64 ACCELERATE_NEW_LAPACK enabled.

@rgommers rgommers added this to the 2.6.0 Release milestone Jul 17, 2026

@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.

Awesome, in it goes Thanks again @freakboy3742!

@rgommers
rgommers merged commit ec6b2b2 into numpy:main Jul 17, 2026
93 checks passed
rgommers added a commit to rgommers/numpy that referenced this pull request Jul 17, 2026
@freakboy3742
freakboy3742 deleted the ios-support branch July 18, 2026 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants