Repository navigation
Commit 0fadbfa
authored
recipe: thrift 0.25.0 (#126)
Adds Apache Thrift's Python runtime with its optional C++ codec, `thrift.protocol.fastbinary`, built for Android and iOS. Requested in [flet#6909](flet-dev/flet#6909).
- [Recipe](recipes/thrift)
- [Docs](recipes/thrift/README.md)
- [Example](recipes/thrift/examples/telemetry-rpc)
## Why a recipe
Upstream publishes desktop wheels only (cibuildwheel, since 0.24.0) and no pure-Python wheel, so `flet build` has nothing to install on mobile. The `source_packages` workaround suggested in the discussion builds the sdist for the build host instead. pip's isolated build drops serious_python's platform-faking `sitecustomize`, and pip never tag-checks a wheel it built itself. Verified on flet 1.0.3:
- The APK carries a macOS Mach-O as `lib/<abi>/libthrift-protocol-fastbinary.so` for all three ABIs.
- The iOS app ships a `.fwork` pointing at a framework that was never built.
- The app runs on thrift's pure-Python fallback. The `*Accelerated` protocols retry the broken load on every construction and ran 12–23x slower than the plain classes.
## Changes
- `CIBUILDWHEEL=1` makes `setup.py` fail when the extension doesn't compile, instead of building a pure-Python wheel.
- `mobile.patch` drops `setup.cfg`'s `[install] optimize = 1`. Its byte-compile step imports `distutils` in the cross interpreter and fails on 3.12+.
- Android depends on `flet-libcpp-shared` for `libc++_shared.so`.
- Skills:
- `new-mobile-recipe`: an optional extension is not "pure Python" for `source_packages`; new shape row for forcing optional extensions.
- `forge-error-catalogue`: the `source_packages` cause of the iOS lipo error, and the `setup.cfg` `[install] optimize` distutils failure.
- `local-recipe-testing`: concurrent iOS builds share `dist_ios`; give each its own `PUB_CACHE`.
## Validation
- **CI 6/6** with `mobile_test_pythons=ALL` ([run](https://github.com/ndonkoHenri/mobile-forge/actions/runs/37147858714)): 11 passed, EXIT 0, on cp312, cp313 and cp314 for Android and iOS.
- **Tests:**
- The codec loads, and the Accelerated protocols bind it.
- Output is byte-identical to pure Python, and round trips succeed.
- Loopback TCP (framed, buffered, bare) and HTTP (buffered, bare) calls count native encodes and decodes.
- All 11 fail against a pure-Python build, which is the negative control.
- **Wheels:** Android `DT_NEEDED` lists `libc++_shared.so` with 16 KB `LOAD` alignment; iOS slices are `MH_DYLIB`.
- **Example** built and run with flet 1.0.3 on an Android 14 arm64 emulator and an iOS 18.6 simulator: native codec active, RPC and declared exception working, 9–25x native gain for the example payload.
- **TLS probe** on both platforms: `TSSLSocket` with the default context verifies against Flet's certifi bundle, and self-signed or expired hosts are rejected.
- **Two adversarial review rounds** on the README, example and tests.
## Consumer notes
Gives Flet apps a native-speed Thrift client over TCP or HTTP; the generated code is produced on desktop. Install, transport setup, TLS and error handling are in the [recipe README](recipes/thrift/README.md), with a runnable [`telemetry-rpc` example](recipes/thrift/examples/telemetry-rpc).1 parent 90778e4 commit 0fadbfa
17 files changed
Lines changed: 1614 additions & 1 deletion
File tree
- .claude/skills
- forge-error-catalogue/references
- local-recipe-testing
- new-mobile-recipe
- recipes/thrift
- examples/telemetry-rpc
- src
- telemetry
- patches
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
247 | 247 | | |
248 | 248 | | |
249 | 249 | | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
250 | 259 | | |
251 | 260 | | |
252 | 261 | | |
| |||
765 | 774 | | |
766 | 775 | | |
767 | 776 | | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
768 | 791 | | |
769 | 792 | | |
770 | 793 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
204 | 204 | | |
205 | 205 | | |
206 | 206 | | |
| 207 | + | |
| 208 | + | |
207 | 209 | | |
208 | 210 | | |
209 | 211 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| |||
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
| 53 | + | |
52 | 54 | | |
53 | 55 | | |
54 | 56 | | |
| |||
70 | 72 | | |
71 | 73 | | |
72 | 74 | | |
| 75 | + | |
73 | 76 | | |
74 | 77 | | |
75 | 78 | | |
| |||
0 commit comments