feat(build): cache flet-build-template.zip; share FLET_CACHE_DIR with Gradle#6558
Merged
Conversation
…CACHE_DIR with Gradle Fixes #6555. Add a small on-disk cache for the build template zip downloaded by `flet build` / `flet debug`. The template at a versioned release URL is immutable, so caching is "use if present, else download once" — no revalidation needed. The download bypasses cookiecutter's network fetch and writes to <cache>/build-template/v<flet-version>/flet-build-template.zip via urllib + atomic .tmp + os.replace; cookiecutter then unpacks the local zip path directly. Cache root resolution: $FLET_CACHE_DIR if set, otherwise ~/.flet/cache. The resolved root is exported back into os.environ so the Gradle child process (serious_python_android >= 1.0.1) lands its Python dist tarballs under the same root by default, fixing the multi-minute "downloadDistArchive_*" delay on every Android debug build. Bumps the bundled build template's serious_python pin from 1.0.0 to 1.0.1 so the new persistent Python-tarball cache + conditional-GET revalidation in serious_python_android 1.0.1 is picked up. Custom --template URLs and the local-dev template path are unchanged — the cache layer only engages for the default versioned-release URL. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Deploying flet-website-v2 with
|
| Latest commit: |
50ef0d0
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://10369a7c.flet-website-v2.pages.dev |
| Branch Preview URL: | https://template-cache.flet-website-v2.pages.dev |
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
Fixes #6555 —
flet debug androidwas re-downloading bothflet-build-template.zipand the threepython-android-dart-3.12-<abi>.tar.gztarballs on every build. This PR is the CLI half; the Gradle half ships in flet-dev/serious-python#208 (serious_python_android 1.0.1).urllib+ atomic.tmp+os.replace. cookiecutter is then handed the local zip path (it unpacks identically to a remote URL). Custom--templateURLs and the local-dev template path are untouched — the cache layer only engages for the default versioned-release URL. The status message still prints the remote URL so users see what's being used; the per-project hash stamp also keys on the remote URL, not the machine-local path.$FLET_CACHE_DIR(or~/.flet/cache) and exports it back toos.environ, so the Gradle child process inherits it andserious_python_android>= 1.0.1 lands its Python dist tarballs under the same root by default. No new flag needed.serious_pythonpin bump in the bundled build template (1.0.0→1.0.1) so the Gradle-side caching from flet-dev/serious-python#208 is actually picked up.sdk/python/packages/flet-cli/src/flet_cli/utils/template_cache.py(~40 LOC, stdlib only, no new deps).Test plan
rm -rf ~/.flet/cache && flet debug android -vvagainst a sample app — confirm~/.flet/cache/build-template/v<version>/flet-build-template.zipand~/.flet/cache/python-build/v3.12/python-android-dart-3.12-*.tar.gzare created and the build succeeds.downloadDistArchive_*tasks should complete via 304 conditional GETs.FLET_CACHE_DIRoverride:FLET_CACHE_DIR=/tmp/flet-cache flet debug android— confirm both the template zip and the three tarballs land under/tmp/flet-cache/.--templateuntouched: pass--template <some-git-url>— confirm the caching layer is not engaged and cookiecutter goes straight to the git URL as before.Companion PR
Merge alongside flet-dev/serious-python#208 (release
serious_python_android1.0.1 with the matching Gradle-side caching).🤖 Generated with Claude Code
Summary by Sourcery
Cache the default Android build template and unify the cache location with Gradle to speed up repeated builds and adopt the latest serious_python Android caching behavior.
New Features:
flet-build-template.zipso subsequentflet build/flet debugruns reuse a locally stored template instead of re-downloading it.Enhancements:
FLET_CACHE_DIR, ensuring the CLI and Gradle-based Android tooling use the same cache directory for build artifacts.serious_python1.0.1 so builds leverage its improved Python distribution caching and revalidation.Documentation: