Skip to content

Fix flet build not reinstalling packages after requirements.txt changes - #6996

Open
ndonkoHenri wants to merge 4 commits into
flet-1.1.0from
fix/requirements-txt-rebuild-6994
Open

ndonkoHenri wants to merge 4 commits into
flet-1.1.0from
fix/requirements-txt-rebuild-6994

Conversation

@ndonkoHenri

@ndonkoHenri ndonkoHenri commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #6994.

flet build skips reinstalling the app's packages (--skip-site-packages) when a hash of the package arguments hasn't changed since the last build. Two holes in that check made builds silently ship the wrong packages:

  • requirements.txt edits were invisible. Only the file's path is in the package arguments (pip reads the file itself), and its contents were added to the hash only under -vv. Adding or changing a dependency kept the previous build's packages. Projects with dependencies in pyproject.toml weren't affected, since each dependency is its own argument.
  • site-packages was never checked. If build/site-packages was deleted while build/.hash stayed (for example a CI cache restoring one but not the other), pip was still skipped and the app shipped without any third-party packages, failing at import.

Changes:

  • read_requirements_file_text() (flet_cli/utils/project_dependencies.py) returns the text of requirements.txt plus the files it includes with -r/--requirement or -c/--constraint, resolved relative to the including file. URLs and missing files are skipped, and files that include each other are read once. Its output always goes into the hash; -vv now only controls logging it.
  • _site_packages_missing() (build_base.py): pip is skipped only when the directory serious_python installs into exists and isn't empty: build/site-packages on native platforms, build/flutter/build/site-packages on web.

Testing

Three consecutive builds of a requirements.txt app (flet only), unmodified flet-1.1.0 CLI vs this branch:

Step flet-1.1.0 (web) This branch (web and macOS)
1. Build pip runs pip runs
2. Add tabulate to requirements.txt, rebuild pip skipped, tabulate missing pip runs, tabulate installed
3. Delete site-packages, rebuild pip skipped, app has no packages pip reinstalls everything
4. Rebuild with no changes pip skipped (cache still works)

New unit tests cover read_requirements_file_text() (include spellings, nesting, cycles, URLs/missing files, editing only an included file). The flet-cli suite passes.

Summary by Sourcery

Make flet build reliably refresh application packages when dependency files or cached package artifacts change.

Bug Fixes:

  • Ensure flet build reinstalls packages when requirements.txt or its included files change.
  • Restore missing or empty site-packages before completing a build instead of relying solely on the dependency hash.

Enhancements:

  • Add requirements-file content tracking for nested requirement and constraint includes, while preserving build caching when dependencies and artifacts are unchanged.

Tests:

  • Add coverage for requirements-file includes, cycles, environment-variable paths, URLs, missing files, and dependency edits.
  • Add coverage for detecting missing packages across native, web, Android, iOS, and platform-specific architectures.

…gone

`flet build` skips reinstalling the app's packages when a hash of the
package arguments is unchanged. For requirements.txt those arguments hold
only the file's path, and its contents entered the hash only with -vv, so
adding or changing a dependency kept the previous build's packages. The
check also never looked at site-packages, so deleting it while build/.hash
stayed produced an app without its packages.

Always hash the text of requirements.txt and of the files it includes with
-r/-c, and skip installing only when site-packages exists and isn't empty.

Fixes #6994
@ndonkoHenri
ndonkoHenri requested review from FeodorFitsner and a balanced review from Copilot October 23, 2026 23:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Deploying flet-website-v2 with  Cloudflare Pages  Cloudflare Pages

Latest commit: 629b2db
Status: ✅  Deploy successful!
Preview URL: https://a143a2ce.flet-website-v2.pages.dev
Branch Preview URL: https://fix-requirements-txt-rebuild.flet-website-v2.pages.dev

View logs

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.

bug: [packaging] editing requirements.txt does not trigger pip reinstall (stale hash), produces APK with missing/empty site-packages

3 participants