-
Notifications
You must be signed in to change notification settings - Fork 192
Add iOS builds #281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add iOS builds #281
Conversation
Looks like its build fine here on GH 👍 |
The problem with iOS is that you can't just run a Python interpreter, so you always need to create an app that bundles the Python interpreter with your Python library. It should be possible through either BeeWare (the maintainer is awesome and has done a lot of the work making iOS builds possible at all) or Kivy (no idea about them, never used it) to automatically create an app, launch Xcode, and run tests on the iOS simulator. I thought it might be complicated, but the BeeWare docs say:
So that might be worth exploring! |
Found this discussion on cibuildwheel pypa/cibuildwheel#2363 that make it sound like something is possible. |
curl https://files.pythonhosted.org/packages/8b/f1/672d303ddf17c24fc83afd712316fda78dc6fce1cd53011b839483e1ecc8/cffi-1.17.1-cp313-cp313-macosx_11_0_arm64.whl -L -o cffi-1.17.1-py3-none-any.whl && \ | ||
pip install cffi-1.17.1-py3-none-any.whl && \ | ||
# install the rest of the dependencies | ||
python -m pip install setuptools wheel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like these are also in CIBW_BEFORE_BUILD just below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, true! It was part of a matrix before, but I've moved it to an iOS only job so we really need CIBW_BEFORE_BUILD
or CIBW_BEFORE_BUILD_IOS
.
|
||
- name: Build wheels | ||
run: python -m cibuildwheel | ||
env: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can set PYMUNK_BUILD_SLIM: 1
here, just like done on wasm/Pypodide. It will exclude the examples from the wheel which if I understand it correctly are not useful anyway, or are they?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, you're right!
CIBW_BUILD_VERBOSITY: 1 | ||
CIBW_BEFORE_BUILD_IOS: | | ||
# download wheel and pretend that it's compatible with the current platform settings | ||
curl https://files.pythonhosted.org/packages/8b/f1/672d303ddf17c24fc83afd712316fda78dc6fce1cd53011b839483e1ecc8/cffi-1.17.1-cp313-cp313-macosx_11_0_arm64.whl -L -o cffi-1.17.1-py3-none-any.whl && \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if cffi also build a ios wheel, then this hack would not be needed, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not quite - BeeWare actually already provides iOS wheels (which are necessary to run Pymunk because there is also a runtime dependency), but this is just for building the wheel. Here, cibuildwheel actually tries to install the iOS wheel, but we want the macOS wheel. The proper solution is for cibuildwheel to install host platform wheels for the build step instead of target platform wheel.
- name: Build wheels | ||
run: python -m cibuildwheel | ||
env: | ||
IPHONEOS_DEPLOYMENT_TARGET: "23.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this one for, and why 23.0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. My other project depend on newer iOS SDK versions but I guess pymunk can down much lower than that. I think the minimum supported version in PEP730 is 12.0.
Experimental builds for iOS using
main
branch ofcibuildwheel
. Tested using Beeware Python 3.13 on a real iOS device. Addresses #276.