Parallel builds on one machine can bundle each other's Python app (staging lives in the plugin's folder in the shared pub cache)
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 38/100
Rechercherichtung
Start with src/serious_python/bin/package_command.dart, src/serious_python_darwin/darwin/sync_site_packages.sh and stage_spm.sh, then inspect src/serious_python_android/android/build.gradle.kts and the reproduction steps. Compare how iOS, macOS and Android stage generated app data in the shared pub cache. Done means concurrent builds cannot package another project's app or partially written artifacts; the issue offers several possible fixes but does not specify a single design.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
What happens
Two builds of serious_python apps that run at the same time on one machine can ship each other's Python app. Nothing fails or warns: the app installs, starts and runs the other project's code.
We hit it three times in one evening (serious_python 5.0.0 through flet build ios-simulator from Flet 1.1, Flutter 3.47.7, Xcode 27, iOS 26.5 simulator), building one Flet app from several git worktrees in parallel:
- a build's own
build/python-app/(itsSERIOUS_PYTHON_APP) held a new module,ui/badges.pyc, but the installedRunner.app/serious_python_darwin_serious_python_darwin.bundle/app/did not; ~/.pub-cache/hosted/pub.dev/serious_python_darwin-5.0.0/darwin/dist_ios/app/had been rewritten a minute after that build packaged its app, by a parallel build in another worktree, and the installed bundle matched that copy;- in another case the app crashed at start on the other worktree's config file; the traceback paths named the other worktree's
build/site-packages.
Why
serious_python stages each app inside the plugin's own package directory, and Flutter resolves plugins from the pub cache, which every Flutter project on the machine shares. The per-project inputs (SERIOUS_PYTHON_APP, SERIOUS_PYTHON_SITE_PACKAGES) are fine; the shared copy they are staged into is not.
iOS and macOS (code at 16bceeb, identical to the published 5.0.0):
- The
packagecommand stages the processed app toSERIOUS_PYTHON_APP(per project), then runsprepare_spm.shinside the plugin'sdarwin/directory, which_resolveDarwinDir()finds through the project'spackage_config.json, i.e. in the pub cache:
https://github.com/flet-dev/serious-python/blob/16bceeb92851022aec9ad6ef24616a0831dc2ba6/src/serious_python/bin/package_command.dart#L593-L602
https://github.com/flet-dev/serious-python/blob/16bceeb92851022aec9ad6ef24616a0831dc2ba6/src/serious_python/bin/package_command.dart#L689-L741 sync_site_packages.shrsyncs$SERIOUS_PYTHON_APPinto$script_dir/dist_ios/appanddist_macos/app, and the site-packages and the frameworks built from them intodist_ios/site-packagesanddist_ios/site-xcframeworks:
https://github.com/flet-dev/serious-python/blob/16bceeb92851022aec9ad6ef24616a0831dc2ba6/src/serious_python_darwin/darwin/sync_site_packages.sh#L9-L22- Under Swift Package Manager (Flutter's default since 3.44),
stage_spm.shcopiesdist_ios/{stdlib,site-packages,app}into the package'sSources/serious_python_darwin/Resources/and the extension frameworks intoextra-xcframeworks/, whichPackage.swiftbundles as.copy("Resources/app")and binary targets:
https://github.com/flet-dev/serious-python/blob/16bceeb92851022aec9ad6ef24616a0831dc2ba6/src/serious_python_darwin/darwin/stage_spm.sh#L33-L48
https://github.com/flet-dev/serious-python/blob/16bceeb92851022aec9ad6ef24616a0831dc2ba6/src/serious_python_darwin/darwin/serious_python_darwin/Package.swift#L94-L104 - Under CocoaPods, the podspec's resource bundle points at the same folder:
https://github.com/flet-dev/serious-python/blob/16bceeb92851022aec9ad6ef24616a0831dc2ba6/src/serious_python_darwin/darwin/serious_python_darwin.podspec#L76-L82 - Xcode copies those folders into the app later, during
flutter build, which takes minutes. Another project'spackagestep in that window overwrites them, and the first build bundles the second one's app (and its site-packages and frameworks, which differ when the requirements differ).
Android has the same race, with a shorter window. serious_python_android's Gradle tasks write app.zip, stdlib.zip, sitepackages.zip and extract.zip to file("src/main/assets") and the native libraries to src/main/jniLibs/<abi>, paths relative to the plugin's project directory, which is its folder in the pub cache:
https://github.com/flet-dev/serious-python/blob/16bceeb92851022aec9ad6ef24616a0831dc2ba6/src/serious_python_android/android/build.gradle.kts#L151
https://github.com/flet-dev/serious-python/blob/16bceeb92851022aec9ad6ef24616a0831dc2ba6/src/serious_python_android/android/build.gradle.kts#L423-L454
AGP merges them into the APK later in the same Gradle run, so two Gradle builds whose preBuild and asset merge overlap can package each other's app.zip (or a half-written one). On the machine above, ~/.pub-cache/hosted/pub.dev/serious_python_android-5.0.0/android/src/main/assets/app.zip is simply the last app any project built.
Steps to reproduce
- Two Flet apps (or two copies of one) whose
main.pydiffer, for example one that shows "A" and one that shows "B". - Start
flet build ios-simulatorin both, a few seconds apart, with the default~/.pub-cache. - In each project compare the packaged app with what the bundle holds:
One of them reports the other project's files (onlydiff -rq build/python-app build/ios-simulator/*.app/serious_python_darwin_serious_python_darwin.bundle/app.keepshould differ). Running both apps shows the same letter.
Workaround
A pub cache per project: PUB_CACHE=<project>/build/pub-cache flet build .... On APFS, mkdir -p build && cp -cR ~/.pub-cache build/pub-cache makes it in a few seconds without using disk space. With it, each bundle's app/ matched its own build/python-app/ (checked on iOS and Android).
Suggested fix
Stage per Flutter project, never in the plugin's own folder:
- Android: write the generated zips and libraries under the plugin's Gradle build directory, which Flutter already places inside each app's
build/, and add them as source directories, for exampleval assetsDir = layout.buildDirectory.dir("generated/serious_python/assets")withandroid.sourceSets["main"].assets.srcDir(assetsDir), and the same forjniLibs. No layout change for callers. - iOS and macOS: the app tree is the part that changes on every build, and a SwiftPM resource must live inside its package, so either:
- take the app out of the plugin package: copy
$SERIOUS_PYTHON_APPinto the app bundle at build time (a script phase reading the variable thatflet buildalready passes toflutter build), and let the runtime look forapp/there; or - stage into a per-project copy of the plugin's
darwin/directory (SERIOUS_PYTHON_DARWIN_DIRalready overrides where staging happens) and have the caller point Flutter at that copy, e.g.flet buildwriting adependency_overridespath underbuild/.
- take the app out of the plugin package: copy
- At least, detect it: record a hash of
SERIOUS_PYTHON_APPwhen staging and compare it with what was bundled at the end of the build (or haveflet buildcomparebuild/python-appwith the bundle'sapp/), and fail with a clear message instead of shipping the wrong app.
Written by Claude Code (AI agent).
- Vorherrschende Sprache
- Dart
- Sterne
- 325
- Forks
- 46
- Ø Merge
- 19 Std. 50 Min.
- Gemergte PRs (30 T.)
- 4
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus flet-dev/serious-python
-
Bump minimum iOS to 15.0 and macOS 12.0Evtl. vergeben @FeodorFitsner hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 55/100
flet-dev/serious-python#254 ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 45/100
flet-dev/serious-python#226 ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 35/100
flet-dev/serious-python#169 ·
-
iOS Build Failure: Missing site-xcframeworks Directory in serious_python_darwin PhaseScriptExecutionOffen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 42/100
flet-dev/serious-python#168 ·
-
Update docs for site-packagesEvtl. wieder frei @FeodorFitsner hat das vor 575 Tagen übernommen, und es ist kein Pull Request offen. Offendocumentation
flet-dev/serious-python#157 · 1 Kommentar · 1 zugewiesene Person ·
Alle Issues in flet-dev/serious-python
Ähnliche Issues
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
jhomlala/betterplayer#1599 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
AimesSoft/NipaPlay-Reload#1021 ·
Maintainer antworten meist innerhalb von 1 Tag
-
enhancement triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
fluttercommunity/plus_plugins#4004 ·
Maintainer antworten meist innerhalb von 1 Tag
-
agent:ready bug P2 · 中 健壮性 区域: 启动与合规 待验证 隐私与合规
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
ASDW51/DanmuFloat#106 ·
Maintainer antworten meist innerhalb von 1 Tag
-
c: proposal p: go_router package team-ecosystem
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 60/100
flutter/flutter#194542 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag