Skip to content

Commit ff08962

Browse files
fix(build): preserve flutter-packages on --skip-site-packages incremental builds (#6634)
register_flutter_extensions() unconditionally wiped the permanent build/flutter-packages directory before repopulating it only when the temp dir exists. On incremental builds the package hash is unchanged, so serious_python is invoked with --skip-site-packages and does not copy Flutter packages to the temp dir. The absent temp dir then meant the wiped extensions were never restored, breaking 'flutter build web' (unresolved web plugins such as audioplayers_web, camera_web, etc.). Track when the package step ran with --skip-site-packages and skip the wipe/move in that case, keeping the previous build's extension copy. A removed extension changes the package requirements, flips the hash, and takes the full (non-skip) path that still clears stale extensions. Regression from #6608.
1 parent d1e8c03 commit ff08962

1 file changed

Lines changed: 20 additions & 5 deletions

File tree

sdk/python/packages/flet-cli/src/flet_cli/commands/build_base.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ def __init__(self, parser: argparse.ArgumentParser) -> None:
8989
self.flutter_dir: Optional[Path] = None
9090
self.flutter_packages_dir = None
9191
self.flutter_packages_temp_dir = None
92+
self.site_packages_skipped = False
9293
self.platforms = {
9394
"windows": {
9495
"package_platform": "Windows",
@@ -1637,11 +1638,20 @@ def register_flutter_extensions(self):
16371638
# when the app has no Flutter extensions — so always clear the old copy
16381639
# first, otherwise an extension removed since the previous build (e.g.
16391640
# dropping flet-video) would linger here and stay in the built app.
1640-
if self.flutter_packages_dir.exists():
1641-
shutil.rmtree(self.flutter_packages_dir, ignore_errors=True)
1642-
if self.flutter_packages_temp_dir.exists():
1643-
# copy packages from temp to permanent location
1644-
shutil.move(self.flutter_packages_temp_dir, self.flutter_packages_dir)
1641+
#
1642+
# Skip this when the package step ran with --skip-site-packages: in that
1643+
# mode serious_python does not repopulate the temp dir, so an absent temp
1644+
# dir means "unchanged" rather than "no extensions". Wiping here would
1645+
# delete the previous build's extensions and never restore them, breaking
1646+
# the Flutter build (unresolved web plugins). A removed extension changes
1647+
# the package requirements, flips the package hash, and takes the full
1648+
# (non-skip) path above instead.
1649+
if not self.site_packages_skipped:
1650+
if self.flutter_packages_dir.exists():
1651+
shutil.rmtree(self.flutter_packages_dir, ignore_errors=True)
1652+
if self.flutter_packages_temp_dir.exists():
1653+
# copy packages from temp to permanent location
1654+
shutil.move(self.flutter_packages_temp_dir, self.flutter_packages_dir)
16451655

16461656
if self.flutter_packages_dir.exists():
16471657
self.update_status("[bold blue]Registering Flutter user extensions...")
@@ -2380,6 +2390,11 @@ def package_python_app(self):
23802390
if not dev_packages_configured:
23812391
if not hash.has_changed():
23822392
package_args.append("--skip-site-packages")
2393+
# serious_python skips copying Flutter packages to the temp dir
2394+
# under --skip-site-packages, so register_flutter_extensions must
2395+
# keep (not wipe) the permanent flutter-packages copy from the
2396+
# previous build.
2397+
self.site_packages_skipped = True
23832398
else:
23842399
if self.flutter_packages_dir.exists():
23852400
shutil.rmtree(self.flutter_packages_dir, ignore_errors=True)

0 commit comments

Comments
 (0)