Repository navigation
recipe: thrift 0.25.0 - #126
Merged
Merged
Conversation
Apache Thrift's Python runtime with its optional C++ codec, thrift.protocol.fastbinary, built for Android and iOS. Requested in flet-dev/flet#6909. Upstream ships desktop wheels only and no pure-Python wheel. The source_packages workaround compiles the codec for the build host, so the app carries a macOS binary and runs on thrift's pure-Python fallback. - CIBUILDWHEEL=1 makes setup.py fail instead of silently building a pure-Python wheel when the extension doesn't compile. - mobile.patch drops setup.cfg's [install] optimize, whose byte-compile step needs distutils in the cross interpreter. - Android depends on flet-libcpp-shared for libc++_shared.so. Tests cover the codec loading and agreeing with pure Python, plus loopback TCP and HTTP calls showing which transports decode natively. All of them fail against a pure-Python build. README and a telemetry-rpc example included.
… workaround [skip ci] - new-mobile-recipe: an optional C extension is not "pure Python"; source_packages compiles it for the build host and ships it to the phone. New shape row for forcing optional extensions. - forge-error-catalogue: that cause under the iOS lipo entry, and the setup.cfg `[install] optimize` distutils failure. - local-recipe-testing: flet 1.0.3 defaults, concurrent iOS builds sharing dist_ios, and finishing an iOS build on Xcode 27 (deployment target 13.0 rejected).
Second adversarial pass over the docs and example: - Size-qualified speedups and fallback cost (5–30x for small structs). - Native decoding needs a buffering transport for TSSLSocket and THttpClient too, not just TSocket. - THttpClient raises unwrapped OSError; example catches (TException, OSError). New "Failures" subsection. - Snippets run standalone; usage ends in a Flet control.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds Apache Thrift's Python runtime with its optional C++ codec,
thrift.protocol.fastbinary, built for Android and iOS. Requested in flet#6909.Why a recipe
Upstream publishes desktop wheels only (cibuildwheel, since 0.24.0) and no pure-Python wheel, so
flet buildhas nothing to install on mobile. Thesource_packagesworkaround suggested in the discussion builds the sdist for the build host instead. pip's isolated build drops serious_python's platform-fakingsitecustomize, and pip never tag-checks a wheel it built itself. Verified on flet 1.0.3:lib/<abi>/libthrift-protocol-fastbinary.sofor all three ABIs..fworkpointing at a framework that was never built.*Acceleratedprotocols retry the broken load on every construction and ran 12–23x slower than the plain classes.Changes
CIBUILDWHEEL=1makessetup.pyfail when the extension doesn't compile, instead of building a pure-Python wheel.mobile.patchdropssetup.cfg's[install] optimize = 1. Its byte-compile step importsdistutilsin the cross interpreter and fails on 3.12+.flet-libcpp-sharedforlibc++_shared.so.new-mobile-recipe: an optional extension is not "pure Python" forsource_packages; new shape row for forcing optional extensions.forge-error-catalogue: thesource_packagescause of the iOS lipo error, and thesetup.cfg[install] optimizedistutils failure.local-recipe-testing: concurrent iOS builds sharedist_ios; give each its ownPUB_CACHE.Validation
mobile_test_pythons=ALL(run): 11 passed, EXIT 0, on cp312, cp313 and cp314 for Android and iOS.DT_NEEDEDlistslibc++_shared.sowith 16 KBLOADalignment; iOS slices areMH_DYLIB.TSSLSocketwith the default context verifies against Flet's certifi bundle, and self-signed or expired hosts are rejected.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, with a runnable
telemetry-rpcexample.