Thank you for your interest in contributing to Flet!
git clone https://github.com/flet-dev/flet
(Invoke-WebRequest -Uri https://raw.githubusercontent.com/pdm-project/pdm/main/install-pdm.py -UseBasicParsing).Content | python -
Enable PEP 582:
pdm --pep582
Run refreshenv
after installing PDM on Windows or restart terminal.
brew install pdm
Enable PEP 582:
pdm --pep582 >> ~/.zprofile
Restart the terminal session to take effect.
cd sdk/python
To install all Flet dependencies and enable the project as editable package run:
pdm install
Create hello.py
file with a minimal Flet program:
import flet
from flet import Page, Text
def main(page: Page):
page.add(Text("Hello, world!"))
flet.app(target=main)
and then run it:
python3 hello.py
During the first run Flet Server (fletd
) and Flet Client (flet
) executables will be downloaded from Flet GitHub releases to a user temp directory and then started from there. The version of release to download from is taken from flet/version.py
file.
You should see a new native OS window opened with "Hello, world!" in it.
Pytest should be run with pdm run
:
pdm run pytest
The project uses Black formatting style. All .py
files in a PR must be black-formatted.
IDE-specific Black integration guides:
Enable "pylance" type checking in VS Code.
Open user settings, search by "pylance", scroll down to Python > Analysis: Type checking mode section. Enable basic mode.
VS Code includes "isort" by default.
Add the following to user's settings.json
:
"[python]": {
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
},
"python.sortImports.args": [
"--trailing-comma",
"--use-parentheses",
"--line-width",
"88",
"--multi-line",
"3",
"--float-to-top"
],
All isort command line options can be found here.
pre-commit is a dev dependency of Flet and is automatically installed by pdm install
.
To install the pre-commit hooks run: pre-commit install
.
Once installed, everytime you commit, pre-commit will run the configured hooks against changed files.
When you run python3 hello.py, you might encounter an error like this:
FileNotFoundError: [Error 2] No such file or directory: '/var/folders/xm/cyv42vbs27gff3s39vy97rx00000gn/T/fletd-0.1.50/fletd'
To resolve the issue, just delete this folder ../T/fletd-0.1.50/fletd
. The folder is the one with the FileNotFound Error encountered earlier.
It should work now.
TBD