Skip to content

Commit a038147

Browse files
committed
Python: Use cibuildwheel for iOS wheel builds
Replace the manual iOS cross-compilation setup (mobile-forge, PYO3_CONFIG_FILE, custom RUSTFLAGS, _PYTHON_HOST_PLATFORM) with cibuildwheel v3, which handles iOS Python framework setup and maturin integration automatically. This avoids the pyo3 0.28 issue where extension-module now forces -lpython linking on iOS (PR slint-ui#5605), which conflicts with iOS's framework packaging.
1 parent 0a2b006 commit a038147

File tree

2 files changed

+14
-46
lines changed

2 files changed

+14
-46
lines changed

.github/workflows/upload_pypi.yaml

Lines changed: 10 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -75,32 +75,12 @@ jobs:
7575
path: api/python/slint/wheelhouse/*.whl
7676

7777
ios_binaries:
78-
strategy:
79-
matrix:
80-
target:
81-
- aarch64-apple-ios-sim
82-
- aarch64-apple-ios
83-
include:
84-
- target: aarch64-apple-ios-sim
85-
sim_suffix: SIM_
86-
python_sim_suffix: _x86_64-simulator
87-
arch: arm64
88-
sdk_name: iphonesimulator
89-
tag: ios_13_0_arm64_iphonesimulator
90-
- target: aarch64-apple-ios
91-
arch: arm64
92-
sdk_name: iphoneos
93-
tag: ios_13_0_arm64_iphoneos
94-
9578
runs-on: macos-14
9679
steps:
9780
- uses: actions/checkout@v6
9881
- uses: ./.github/actions/setup-rust
9982
with:
100-
target: aarch64-apple-ios
101-
- uses: actions/setup-python@v6
102-
with:
103-
python-version: '3.13'
83+
target: "aarch64-apple-ios aarch64-apple-ios-sim"
10484
- uses: baptiste0928/cargo-install@v3
10585
with:
10686
crate: taplo-cli
@@ -115,36 +95,20 @@ jobs:
11595
rm Cargo.toml.new
11696
taplo get -f Cargo.toml features.default
11797
118-
- run: |
119-
export GIT_LFS_SKIP_SMUDGE=1
120-
git clone https://github.com/beeware/mobile-forge.git
121-
cd mobile-forge
122-
source ./setup-iOS.sh 3.13
123-
PYTHONDIR="$PWD/support/3.13/iOS/Python.xcframework/ios-arm64${{ matrix.python_sim_suffix}}"
124-
echo PYTHONDIR="$PYTHONDIR" >> $GITHUB_ENV
125-
OSX_SDKROOT=$(xcrun --sdk macosx --show-sdk-path)
126-
echo "OSX_SDKROOT=$OSX_SDKROOT" >> $GITHUB_ENV
127-
IOS_SDKROOT=$(xcrun --sdk ${{ matrix.sdk_name }} --show-sdk-path)
128-
echo "IOS_SDKROOT=$IOS_SDKROOT" >> $GITHUB_ENV
129-
echo "PYO3_CROSS_PYTHON_VERSION=3.13" >> $GITHUB_ENV
130-
echo "SDKROOT=$OSX_SDKROOT" >> $GITHUB_ENV
131-
echo "PYO3_CROSS_LIB_DIR=$PYTHONDIR" >> $GITHUB_ENV
132-
echo CARGO_TARGET_AARCH64_APPLE_IOS_${{ matrix.sim_suffix }}RUSTFLAGS="-C link-arg=-isysroot -C link-arg=$IOS_SDKROOT -C link-arg=-arch -C link-arg=${{ matrix.arch }} -C link-arg=-miphoneos-version-min=14.0 -C link-arg=-F -C link-arg=$PYTHONDIR -C link-arg=-framework -C link-arg=Python" >> $GITHUB_ENV
133-
134-
- name: Build a binary wheel
135-
uses: PyO3/maturin-action@v1
136-
env:
137-
_PYTHON_HOST_PLATFORM: ${{ matrix.tag }}
98+
- name: Build iOS wheels
99+
uses: pypa/cibuildwheel@v3.4.0
138100
with:
139-
working-directory: api/python/slint
140-
target: ${{ matrix.target }}
141-
args: --release --out wheelhouse --interpreter 3.13
101+
package-dir: api/python/slint
102+
output-dir: wheelhouse
103+
env:
104+
CIBW_PLATFORM: ios
105+
CIBW_ARCHS: arm64_iphoneos arm64_iphonesimulator
142106

143107
- name: Store the distribution packages
144108
uses: actions/upload-artifact@v7
145109
with:
146-
name: python-package-distributions-${{ matrix.target }}
147-
path: api/python/slint/wheelhouse/*.whl
110+
name: python-package-distributions-ios
111+
path: wheelhouse/*.whl
148112

149113
build_source_package:
150114
name: Build source package

api/python/slint/pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ cache-keys = [{ file = "pyproject.toml" }, { file = "Cargo.toml" }, { file = "**
5050
# Uncomment to build rust code in development mode
5151
# config-settings = { build-args = '--profile=dev' }
5252

53+
[tool.cibuildwheel.ios]
54+
# Expose Rust toolchain to the restricted iOS build environment
55+
xbuild-tools = ["rustc", "cargo", "rustup", "cc", "ar"]
56+
5357
[tool.maturin]
5458
editable-profile = "dev"
5559
# added so it includes in wheel build to overrite the default behavior of not including untracked files

0 commit comments

Comments
 (0)