Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Fletd server for desktop apps with a light-weight Python shim #838

Merged
merged 32 commits into from
Jan 16, 2023

Conversation

FeodorFitsner
Copy link
Contributor

@FeodorFitsner FeodorFitsner commented Jan 9, 2023

This PR is the implementation of a new Flet desktop architecture.

It replaces Fletd server written in Go with a light-weight shim written in Python which results to:

  1. Only 2 system processes to run Flet app: Python interpreter and Flutter client.
  2. Less communication overhead (minus two network hops between Python and Fletd) and lower latency (shim uses TCP on Windows and Unix domain sockets on macOS/Linux).
  3. Shim binds to 127.0.0.1 on Windows by default which is more secure by default.
  4. The size of a standalone app bundle produced by flet pack reduced by ~8 MB.

The implementation paves the way to support Pyodide, iOS and Android.

Other notable changes:

  • All controls loading resources from web URLs are able to load from local files, by providing a full path within the file system, and from assets directory by providing relative path: Image.src, Audio.src, Page.fonts, Container.image_src. For desktop apps a path in src property could be one of the following:
    • A path relative to assets directory, with or without starting slash, for example: /image.png or image.png. The name of artifact dir should not be included.
    • An absolute path within a computer file system, e.g. C:\projects\app\assets\image.png or /Users/john/images/picture.png.
    • A full URL, e.g. https://mysite.com/images/pic.png.
    • Add page.on_error = lambda e: print("Page error:", e.data) to see failing images.
  • flet Python package has separated into two packages: flet-core and flet.
  • switched from PDM to Poetry.
  • beartype removed everywhere.
  • Faster mouse wheel scrolling on Windows.

💥 Breaking changes:

  • Default routing scheme changed from "hash" to "path" (no /#/ at the end of app URL). Use ft.app(main, route_url_strategy="hash") to get original behavior.
  • OAuth authentication is not supported anymore in standalone desktop Flet apps.

* Poetry files added

* Run poetry in CI

* Build with poetry

* poetry install

* New project structure with flet_core

* Break everything into 2 packages

* simplified init from flet_core

* Fix CI

* Remove beartype tests

* get rid of beartype

* All python tasks

* Patch version

* build wheels

* Fix patching

* Run all jobs

* Add "assetsDir" to a client

* support assets_dir in desktop apps

* Fix Studio build

* Fix Dart imports

* Update README.md
@hololeo
Copy link

hololeo commented Jan 13, 2023

"Sorry GO"

Sorry GO
You got to go
You were strong and reliable.
And faithful and dependable

So Sorry GO
Sad to see you go

@FeodorFitsner
Copy link
Contributor Author

It's still there with us though, as Fletd is needed for web apps.

But we could rewrite that in Python either (FastAPI?).

@FeodorFitsner FeodorFitsner merged commit a6a95aa into main Jan 16, 2023
@FeodorFitsner FeodorFitsner deleted the fletd-in-python branch January 16, 2023 03:25
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.

2 participants