Repository navigation
Fix Linux desktop client flavor and cache, and warn about extensions the client lacks - #7030
Open
ndonkoHenri wants to merge 11 commits into
Open
ndonkoHenri wants to merge 11 commits into
ndonkoHenri wants to merge 11 commits into
Conversation
ensure_flet_desktop_package_installed() imports flet_desktop to compare versions, reinstalls on a mismatch, and left the old module in sys.modules. The first launch after upgrading flet then imported the replaced package. Drop the flet_desktop modules and invalidate the import caches after the reinstall.
…roblems
- Name the Linux client cache dir flet-desktop-{flavor}-{distro}-{version}.
Each distro build links that distro's libmpv soname, so a client cached
before an OS upgrade or a FLET_LINUX_DISTRO change is no longer reused.
- After the client exits, log install hints when the dynamic loader could
not start it (exit status 127).
- Warn when the Linux default light client is used while flet-audio or
flet-video is installed, since it has neither extension.
- Read [tool.flet].desktop_flavor from the started script's project too,
and export it as FLET_DESKTOP_FLAVOR from flet run, so starting the app
from another directory keeps the project's flavor.
A frozen executable is a file, so the started-script lookup treated the folder of a flet pack app as a project and could select a flavor other than the bundled one, which made the app download a vanilla client. Skip that lookup in frozen apps.
…ipt in flet run flet run only read [tool.flet].desktop_flavor from the script's own folder, so a script in a project subfolder, run from outside the project, opened the light client. Use the nearest pyproject.toml at or above the script.
…ads the flavor The nearest pyproject.toml at or above the script may belong to an enclosing project. If it can't be read or parsed, flet run died with a TOMLDecodeError before starting the app; now it is ignored.
A flet pack app also read the pyproject.toml of the directory it was started from, so starting it inside a project with desktop_flavor = "full" swapped its bundled light client for a downloaded full one.
Caching the build id hid glibc changes from the artifact tests, which vary the detected version per case.
The check reads the client's extensions from its AOT snapshot, caches them in the client's folder and compares them with the extensions the app imports, so it covers every extension and platform instead of only Audio and Video with the light Linux client. The extension helpers move from flet-cli to flet-desktop to be shared with flet pack. The exit-127 hint names libmpv and GStreamer only for the full flavor.
Contributor
|
Sorry @ndonkoHenri, you've used your own review budget of 250,000 diff characters for the last 7 days. You can request another review in 1 day and 9 hours by commenting |
This was
linked to
issues
Oct 31, 2026
Deploying flet-website-v2 with
|
| Latest commit: |
504dd02
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://738931ae.flet-website-v2.pages.dev |
| Branch Preview URL: | https://fix-linux-desktop-client-fla.flet-website-v2.pages.dev |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the Linux desktop client problems behind #5311 and #6265: a stale client reused after an OS upgrade, and a
desktop_flavorsetting that was ignored depending on where the app was started from. It also makes Flet say what's wrong instead of failing silently: it warns when the app uses an extension the client doesn't include, on every desktop platform, and gives install hints when the Linux client can't load a shared library.1. Linux client cache is per distro (#5311)
Each Linux client build links its distro's
libmpv(libmpv.so.1on Debian 10/11 and Ubuntu 20.04/22.04,libmpv.so.2on Debian 12 and Ubuntu 24.04). The cache folder only had the flavor and version in its name,~/.flet/client/flet-desktop-{flavor}-{version}. After an OS upgrade, or after changingFLET_LINUX_DISTRO, Flet reused the build for the previous distro, and the full client then failed to start withlibmpv.so.1: cannot open shared object file(Linux Mint 21 → 22.1 in #5311).The folder is now
flet-desktop-{flavor}-{distro}-{version}, so a different distro gets its own download. The system glibc version is cached withfunctools.cache(not the build picked from it, so tests can still vary it).2.
desktop_flavoris read from the app's project (#6265)[tool.flet].desktop_flavorwas only read from thepyproject.tomlof the current working directory. With this layout:cd music-app && flet runcd ~ && flet run projects/music-appAudio.play()times outcd music-app/src && python main.py(or an IDE's Run)Now:
flet runreads the nearestpyproject.tomlat or above the script and exports itsdesktop_flavorasFLET_DESKTOP_FLAVORfor the client it opens, unless that variable is already set. The client is opened from theflet runprocess, whose working directory is whereflet runwas started, so the variable is how the setting reaches it.flet_desktopitself (used bypython main.py/ft.run()) checks the current directory first, then the nearestpyproject.tomlat or abovesys.argv[0].flet rundied with aTOMLDecodeError.flet packapps use onlyFLET_DESKTOP_FLAVOR. A frozen app is a file, so the script lookup treated its folder as a project. Apyproject.tomlnear the app, or in the folder it was started from, could pick a flavor other than the bundled one and make it download a vanilla client instead of using its own (patched icon and metadata).FLET_DESKTOP_FLAVORstill wins over all of the above. Resolution order: env var →pyproject.tomlin the current directory → nearest one at or above the script →lighton Linux,fullelsewhere.3. Warning when the client doesn't include an extension the app uses
With the light Linux client,
Audiocalls time out withTimeout waiting for invoke method listenerandVideoshowsUnknown control: Video, with nothing pointing at the client (#6121, #6265). The same happens on any platform with a third-party extension that the prebuilt client doesn't contain. Flet now logs, for example:For other clients the second sentence suggests building a client with
flet buildand starting the app from the project folder.How it works (
flet_desktop/__init__.py,__warn_missing_extensions, called right after the client is cached on Windows, macOS and Linux):lib/libapp.so,data/app.so,App.framework/App) keeps apackage:<name>/URI for every Dart library compiled into it. The snapshot is scanned once and the package names are stored in a.extensionsfile in the client's cache folder. The file is only trusted if it listsflet; otherwise the snapshot is scanned again.flutter/<package>/pubspec.yamlinto site-packages. If every such folder onsys.pathis in the client's list (the usual case), the check ends here, in about 1 ms.RECORDs map each missing Flutter package to the Python modules it ships (for editable installs, aflutter/<package>folder next to a<package>module counts). An extension is reported only if the app imports one of those modules: either it's already insys.modules, or the app's.pyfiles import it, found by parsing them withast(venvs, hidden folders,build,dist,node_modulesand symlinked folders are skipped). Underflet runthe app runs in a separate process, sorun.pypasses the script's folder asapp_dir. This scan takes ~140 ms and only runs when an installed extension is missing from the client.An installed but unused extension gives no warning. Any error in the check is logged at debug level and never stops the app.
The helpers that
flet packalready used for this (get_client_extensions,find_installed_extensions,find_imported_modules, …) move fromflet_cli/__pyinstaller/extensions.pytoflet_desktop/extensions.py, so both share them.flet packand its tests only change their import.4. Hint when the Linux client can't load a library (#2823)
When the client exits with status 127 (the dynamic loader couldn't load a shared library),
flet runandft.run()now log that a library could not be loaded (the loader's own error only names the library). With the full flavor, wherelibmpvor GStreamer is the usual cause, the hint gives theapt installcommand for them and suggestsFLET_DESKTOP_FLAVOR=lightfor apps that need none of the full client's extra extensions; otherwise it says to install the system package that provides the library.5. Load the reinstalled
flet-desktopafter a version-mismatch reinstallensure_flet_desktop_package_installed()importsflet_desktopto compare versions and reinstalls it on a mismatch, but the old modules stayed insys.modules. The first launch after upgradingfletthen ran the replaced package. Theflet_desktopmodules are now dropped and import caches invalidated after the reinstall.Docs
Video; the full client needslibmpvand GStreamer, with the runtime package names for Debian/Ubuntu by release, Fedora, openSUSE and Rocky/AlmaLinux 9 (which needsFLET_LINUX_DISTRO=debian12). The old advice to symlinklibmpv.sotolibmpv.so.1is removed;libmpv-devis only needed byflet build linux.flet-audio/flet-videoREADMEs: same light/full explanation and packages.FLET_LINUX_DISTROsection with the build → glibc → architectures →libmpvtable;FLET_DESKTOP_FLAVORdocuments where the setting is read from; each build is cached in its own folder.Testing
flet-desktopandflet-clitests pass (869 passed, 1 skipped), including the Linux artifact tests from Stop building the Debian 10 ARM64 desktop client #7018.Audio:flet runplay()times out as beforepython main.pyFLET_DESKTOP_FLAVOR=fullflet-audioinstalled but not importedThe
.extensionsfiles were written on first launch (144 packages for the full client, 135 for the light one) and read on later ones.Fixes #5311
Fixes #6265
Summary by Sourcery
Improve desktop client selection and diagnostics across platforms, with distro-aware Linux caching, project-aware flavor resolution, and actionable warnings for missing extensions and libraries.
New Features:
Bug Fixes:
Enhancements:
Documentation: