Skip to content

apk: assemble owns the app folder; leftovers of older builds are removed and excluded - #2109

Merged
trissim merged 1 commit into
mainfrom
fork-apk-stale-packages
Nov 18, 2026
Merged

trissim merged 1 commit into
mainfrom
fork-apk-stale-packages

Conversation

@trissim

@trissim trissim commented Nov 18, 2026

Copy link
Copy Markdown

The APK build on main (c4e25bd), run in the shared app folder, failed the bytecode check: 30 modules under watchdog/ had no .opt-1.pyc. watchdog had left the import closure, but its folder from an older build was still in the app folder. assemble.py only removed stale copies of recipe-built packages, and buildozer.spec excluded nothing, so any package that dropped out of the closure kept shipping as stale source. The same was true of the 16 Nov deployment/ folder.

The fix:

  • tools/android/app_folder.py declares, in one place, every entry the folder holds besides the closure. For each entry it records who writes it and whether the APK ships it:
    • shipped: main.py, profile.json, cacert.pem, wal, __pycache__;
    • build-only: jar, buildozer.spec, keepalive.aar, closure.json, .build.lock, build.log, .buildozer, bin, toadcomms-*.apk.
  • assemble.py now:
    • removes every entry that is neither the closure's nor declared, plus the top-level __pycache__, which it recompiles;
    • then fails if the folder it laid out holds anything else.
  • buildozer.spec.in: source.exclude_dirs (jar, .buildozer, bin) and source.exclude_patterns are filled from the declared build-only entries. This keeps closure.json out of the APK; it used to ship because buildozer includes .json files.
  • bundle_check.py treats every entry not declared as a shipped package.
  • check.sh plants an older build's leftovers before assembling: a package and a module that left the closure, the module's bytecode, and a deployment/recipes/…/__init__.py. It fails if any of them survives.

Proof, from the full tools/android/check.sh run once on this head:

  • Dirty folder: the scratch app folder started dirtied like the shared one. It held copies of its stale state/ and pysidedeploy.spec, a watchdog/ package, a shiboken6/ source copy, and the build's own .buildozer/, build.log, .build.lock and APK.
  • Assemble: it removed deployment, left_closure_module.py, left_closure_package, pysidedeploy.spec, shiboken6, state, watchdog and __pycache__, then printed "assemble removed every planted leftover".
  • Rest of the check: "shipped bytecode is cpython-314.opt-1.pyc"; every application action has a summary; bundle check 15/15 baseline; "shipped app ran every view kind and bound key on a scratch bus". Exit 0.
  • Folder afterwards: it holds exactly the 38 closure packages and modules plus the declared entries. No closure entry is missing and nothing undeclared remains. .buildozer/ and build.log were kept.
  • Not covered: buildozer itself was not run, since this fork builds no APKs. The exclusions are checked as written into the spec, not through a buildozer packing run.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3

…s are removed

The app folder is reused between builds, and assemble.py removed only source copies of
recipe-built packages, so a package that left the closure (watchdog) and an earlier layout's
folder (deployment/, recipes and jars from 16 Nov) kept shipping: buildozer packs every file
under the folder whose extension it includes, and the spec excluded nothing.

app_folder.py declares every entry the folder holds besides the closure, with who writes it
and whether the APK ships it. assemble.py removes every entry that is neither the closure's
nor declared (and the top-level bytecode folder, which it compiles afresh), then fails if the
laid-out folder holds anything else. buildozer.spec's source.exclude_dirs and
source.exclude_patterns are the declared entries that do not ship. bundle_check reads the
shipped packages as the entries not declared. check.sh plants an older build's leftovers (a
departed package, module and its bytecode, a stale layout folder) before assembling and fails
if any survives.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant