build(android): consume serious_python native-mmap packaging + --android-extract-packages#6595
Merged
Merged
Conversation
…t-packages option
- Build template: point serious_python git ref at android-native-mmap; drop the stale
packaging{jniLibs{useLegacyPackaging=true; keepDebugSymbols}} block from the Android
app build.gradle.kts (native modules now load mmap'd from the APK; modern packaging at
minSdk 23+ is all that's needed).
- flet-cli: add --android-extract-packages CLI flag + [tool.flet.android].extract_packages
(cross-platform [tool.flet].extract_packages fallback), a built-in
ANDROID_DEFAULT_EXTRACT_PACKAGES set (certifi), merged and exported as
SERIOUS_PYTHON_ANDROID_EXTRACT_PACKAGES for the serious_python package step. Mirrors the
existing --source-packages -> SERIOUS_PYTHON_ALLOW_SOURCE_DISTRIBUTIONS flow.
The serious_python_android Gradle split (which partitions site-packages into the stored sitepackages.zip vs the extracted extract.zip) runs during `flutter build`, not the `serious_python package` step. Set SERIOUS_PYTHON_ANDROID_EXTRACT_PACKAGES on build_env (resolved once into self.android_extract_packages) so the default set (certifi) and user list actually reach the split — previously it was set on the package step's env and silently ignored, leaving extract.zip empty. Add the "Android extract packages" publish-docs section (resolution order, CLI + pyproject example), a CHANGELOG entry, and allowlist `certifi` in typos. Verified end-to-end on an arm64 emulator via both `flet build apk` and `flet build aab` (bundletool split install): numpy mmap'd from the APK, certifi extracted to disk, flet icons.json read from the stored zip, flet.version resolved, app launched.
Deploying flet-website-v2 with
|
| Latest commit: |
6693b32
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://5ceac8c8.flet-website-v2.pages.dev |
| Branch Preview URL: | https://android-native-mmap.flet-website-v2.pages.dev |
certifi reads cacert.pem via importlib.resources.as_file(), which extracts it to a temp file on demand, so certifi.where() works from inside the stored sitepackages.zip (verified: imported via zipimport, where() returns a valid 234KB cacert.pem). It does not need to ship extracted. Make ANDROID_DEFAULT_EXTRACT_PACKAGES empty — the common data-bundling packages use importlib.resources (zip-safe). The --android-extract-packages / [tool.flet.android].extract_packages mechanism stays for genuinely path-hungry packages (those reading data via __file__ / pkg_resources). Update docs and CHANGELOG accordingly.
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.
Summary
Makes
flet build apk/aabconsume serious_python's new Android packaging (see flet-dev/serious-python#210): native modules memory-mapped from the APK, pure Python in storedzipimportzips, nouseLegacyPackaging.android-native-mmapbranch; the appbuild.gradle.ktsdrops the now-stalepackaging { jniLibs { useLegacyPackaging = true; keepDebugSymbols += … } }block (modern packaging applies by default atminSdk 23+).--android-extract-packagesCLI flag +[tool.flet.android].extract_packages(with a[tool.flet].extract_packagesfallback) to ship "path-hungry" packages extracted to disk. A built-in default set (certifi) is always extracted; the user list is merged on top. The resolved list is exported asSERIOUS_PYTHON_ANDROID_EXTRACT_PACKAGESon the flutter build env, where the serious_python Gradle split consumes it.fletitself is already zip-safe: icons load viaimportlib.resources;version.pyshort-circuits__file__/git/.fvmrcon mobile — no changes needed.Verification
Built a real Flet UI app and ran it on an arm64 emulator via both
flet build apkandflet build aab(bundletool split install). All green on both paths:numpyextension mmap'd from the APK /split_config.arm64_v8a.apk(83 native.soin the ABI config split, zero in master)certifiextracted to…/files/flet/py/extract/certifi/cacert.pemicons.jsonread from the storedsitepackages.zipviaimportlib.resourcesflet.versionresolved; UI launched (ft.Iconrendered)Note for release
The template currently pins serious_python to the
android-native-mmaptest branch — flip to the mergeddart-bridge(or a tagged serious_python release) before shipping, and carry the same Gradle/pubspec edits into the releasedflet-build-template.zip.Depends on flet-dev/serious-python#210.
Summary by Sourcery
Adopt serious_python’s new Android native-mmap packaging in the Flet Android build template and add configuration for extracting path-dependent Python packages on Android builds.
New Features:
Enhancements:
Documentation:
Chores: