Skip to content

Latest commit

 

History

History
121 lines (75 loc) · 3.06 KB

CONTRIBUTING.md

File metadata and controls

121 lines (75 loc) · 3.06 KB

Contributing to Flet

Thank you for your interest in contributing to Flet!

Clone repo

git clone https://github.com/flet-dev/flet

Python SDK

Install Poetry

Windows

(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | py -

macOS

curl -sSL https://install.python-poetry.org | python3 -

Open worker directory

cd sdk/python

Install dependencies

To install all Flet dependencies and enable the project as editable package run:

poetry install

Check the installation

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:

poetry run python hello.py

During the first run Flet Client (flet) executable 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.

Running tests

Pytest should be run with poetry run:

poetry run pytest

Code formatting

The project uses Black formatting style. All .py files in a PR must be black-formatted.

IDE-specific Black integration guides:

Type checking

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.

Sort imports on Save

Install isort extension for imports formatting: https://marketplace.visualstudio.com/items?itemName=ms-python.isort

pre-commit

pre-commit is a dev dependency of Flet and is automatically installed by poetry install. To install the pre-commit hooks run: pre-commit install. Once installed, every time you commit, pre-commit will run the configured hooks against changed files.

Possible installation error when working with a source package

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.

Flutter client

Add the following to ~/.zprofile (or other profile scripts for your OS):

# Flet
export FLET_VIEW_PATH="$HOME/Projects/flet-dev/flet/client/build/macos/Build/Products/Release"
export FLET_WEB_PATH="$HOME/Projects/flet-dev/flet/client/build/web"

If you have Microsoft Edge installed and want to use it for debugging Flutter apps:

# Flutter
export CHROME_EXECUTABLE="/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge"