Skip to content

Pin flet and its extensions to the Flet CLI version when building and publishing - #7047

Open
ndonkoHenri wants to merge 3 commits into
flet-1.1.0from
fix/pin-flet-to-cli-version
Open

ndonkoHenri wants to merge 3 commits into
flet-1.1.0from
fix/pin-flet-to-cli-version

Conversation

@ndonkoHenri

@ndonkoHenri ndonkoHenri commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #6894. A built app runs in a Flet client of the CLI's version, but its Python packages were installed as declared. flet create writes flet>=<version>, so a build, or a published site on every page load, could get a newer flet than its client and fail at runtime on anything that release changed, while flet run kept working.

What changes

flet build, flet debug, flet test and flet publish now install flet and the packages released with it at the CLI's version. Extras and markers are kept.

The app declares CLI Before Now
flet>=1.0.5 1.1.0 newest flet flet==1.1.0
flet-charts 1.1.0 newest flet-charts flet-charts==1.1.0
flet==0.86.3 1.1.0 builds a mismatched app stops with an explanation
flet from a path or URL, e.g. dev_packages any as declared as declared
  • requirements.txt: pip reads the file itself, so pins go next to it. A file using hashes is only checked, because pip rejects requirements without a hash.
  • flet publish: also adds [tool.flet.web].dependencies to the archive's requirements, and checks for conflicts before it clears dist. An extension listed only there would otherwise ask for a newer flet on page load, and an app in a [tool.flet.app].path subdirectory never installed them.

Please look at

  • FLET_PACKAGES is a new list to keep in sync. pip alone doesn't need it, but micropip does: with only flet pinned, a published site with an unpinned extension fails at startup once a newer release is out (reproduced in Chrome). A test fails if a folder in sdk/python/packages is missing from it, and it's in the extension checklist.
  • Behavior change: an app pinned to another flet, such as flet==1.0.4 under a 1.0.5 CLI, used to build and now stops. A third-party package that requires another flet version now fails in pip's resolver. Both used to ship the mismatch this fixes.
  • Not backportable as is: flet-notifications and flet-shadcn-ui have no 1.0.x releases.

Limits

  • CLIs already released are unchanged. A 1.0.5 CLI with flet>=1.0.5 should bundle 1.1.0 once it's out.
  • The conflict check runs at the packaging step, so on a fresh machine it comes after the Flutter setup.
  • A pin inside a -c constraints file ends in pip's error rather than ours.
  • flet = "^0.86.3" in Poetry is read as >=0.86.3, an existing bug, so it gets pinned instead of raising the conflict.

Testing

CLI 1.1.0.dev4 from source, Flutter 3.47.9:

Where What ran Result
macOS flet-cli tests 1168 passed, 1 skipped
macOS flet create app: build macos, then launched process stayed up (window not checked), both packages at the CLI's version
macOS same app: flet debug macos, flet test macos pass
macOS second build, then a dependency change installs skipped, then packages reinstalled
Android emulator (API 36) build apk, installed and launched app draws
iOS simulator build ios-simulator, installed and launched app draws
macOS build web on 19 project shapes: ranges, extras, markers, Poetry, no deps, BOM, UTF-16, nested files, conflicts, local packages see below
Chrome published sites with the CLI faked to 1.0.4 and 1.0.5 newest on PyPI: root layout, subdirectory, requirements.txt, markers, web-only extension load with flet and flet-charts at 1.0.4
Windows 11 ARM64 build windows (launched, window opened), build web with markers through dart.bat, UTF-16 file, conflict pass
Windows 11 ARM64 flet-cli tests 1156 passed, 12 skipped, 1 failed: test_warns_when_listed_file_is_missing, in a file this PR doesn't touch
Linux x64 (Rosetta) build linux, build web, conflict pass
Linux x64 (Rosetta) flet-cli tests 1165 passed, 3 skipped, 1 failed: test_run_assets_dir[web], needs flet-web, which wasn't installed there

Three web shapes failed the same way on unmodified 1.1.0.dev4: flet[all] on web, --no-cache-dir in requirements.txt, and ./mylib in [project].dependencies. A local flet checkout next to an unpinned extension also fails in pip's resolver; the pin leaves that list as declared.

Not run: signed release builds (ipa, aab), x64 Windows. The last fixes, for --hash in comments and file: includes, have unit tests on all three systems and real web builds on macOS only. The Windows desktop app showed a firewall prompt for Python on first launch; I left it unanswered and didn't compare it against a build without this change.

Reviewed by Codex twice and Claude once. Findings are fixed except the limits above.

Summary by Sourcery

Align packaged Flet dependencies with the CLI version across build and publish workflows to prevent client and Python package incompatibilities.

Bug Fixes:

  • Pin Flet and its released extensions to the CLI version during build, debug, test, and publish workflows to prevent runtime mismatches.
  • Reject dependency requirements that exclude the CLI's Flet version and preserve local or URL-based Flet dependencies.
  • Include web-specific dependencies when publishing apps from subdirectories and apply the same version compatibility checks.

Enhancements:

  • Expand requirements parsing to support nested files, constraints, editable and local dependencies, encodings, markers, extras, and hash-aware handling.
  • Maintain and validate the complete list of Flet packages that must be version-aligned.

Documentation:

  • Document Flet version alignment, conflict behavior, and exceptions for local or URL-based dependencies when publishing.

Tests:

  • Add comprehensive coverage for dependency parsing, version pinning, conflict detection, package coverage, hash handling, and dependency overrides.

… publishing

`flet build`, `flet debug` and `flet publish` produce an app that runs in a Flet
client of the CLI's version, but installed the app's dependencies as declared.
`flet create` declares `flet>=<version>`, so pip, and micropip on every page load
of a published site, picked the newest release and the app failed at runtime on
anything that release changed, while `flet run` kept working.

`flet` and the packages released with it are now pinned to the CLI's version,
keeping extras and markers. A requirement that excludes that version stops the
command with an explanation. Nothing is pinned when `flet` itself comes from a
path or URL, such as `dev_packages`. A `requirements.txt` with hashes is only
checked, because pip rejects requirements without a hash.

`flet publish` also adds `[tool.flet.web].dependencies` to the archive's
requirements. An extension listed only there would otherwise ask for a newer
`flet` on page load, and an app in a subdirectory never installed them at all.
Testing on real projects and two reviews found requirement forms that the pin
got wrong:

- A conflicting requirement with an environment marker no longer stops the
  command, because it may not apply to the target. pip decides.
- `flet` from a local checkout, a bare wheel filename, or a location followed by
  extras or a marker is left alone instead of getting a clashing pin.
- `requirements.txt` files with a byte order mark, including the UTF-16 that older
  PowerShell writes, are decoded, so their requirements get pinned.
- A `-r` inside a constraints file is read as requirements, and `file:` includes
  are read, as pip does. No `flet` pin is added next to any other URL include,
  which can't be read here.
- `--hash` in a comment no longer turns off the pin.

Also list `FLET_PACKAGES` in the extension checklist.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Deploying flet-website-v2 with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2356711
Status: ✅  Deploy successful!
Preview URL: https://3953c7a5.flet-website-v2.pages.dev
Branch Preview URL: https://fix-pin-flet-to-cli-version.flet-website-v2.pages.dev

View logs

@ndonkoHenri
ndonkoHenri marked this pull request as ready for review November 5, 2026 08:58

@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 ✨

This branch has not been deployed

No deployments
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: Runtime packaged application fails with misleading module 'flet' has no attribute 'ElevatedButton' error

1 participant