Skip to content

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,49 @@ jobs:
with:
path: ./wheelhouse/*.whl
retention-days: 7

build_ios:
name: Build wheels for iOS
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4.2.2
with:
submodules: true

- name: Set up Python
uses: actions/setup-python@v5.5.0
with:
python-version: "3.x"

- name: Install cibuildwheel
run: |
python -m pip install -U pip
# Use main branch until iOS support is released.
# python -m pip install cibuildwheel==3.0.0
python -m pip install git+https://github.com/pypa/cibuildwheel.git

- name: Build wheels
run: python -m cibuildwheel
env:
Copy link
Owner

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?

Copy link
Author

Choose a reason for hiding this comment

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

no, you're right!

IPHONEOS_DEPLOYMENT_TARGET: "23.0"
Copy link
Owner

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?

Copy link
Author

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.

CIBW_PLATFORM: ios
CIBW_ARCHS: auto
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 && \
Copy link
Owner

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?

Copy link
Author

@marcpabst marcpabst Apr 28, 2025

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.

pip install cffi-1.17.1-py3-none-any.whl && \
# install the rest of the dependencies
python -m pip install setuptools wheel
Copy link
Owner

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?

Copy link
Author

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.

CIBW_BEFORE_BUILD:
python -m pip install setuptools wheel cffi
CIBW_XBUILD_TOOLS : "curl pkg-config tar"
CIBW_BUILD_FRONTEND: "pip; args: --no-build-isolation"

- uses: actions/upload-artifact@v4
if: ${{ github.ref == 'refs/heads/master' }}
with:
name: cibw-wheels-ios-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl
retention-days: 7
Loading