flet icon indicating copy to clipboard operation
flet copied to clipboard

feature: Support package-level running

Open skeledrew opened this issue 2 months ago • 1 comments

Duplicate Check

  • [x] I have searched the opened issues and there are no duplicates

Describe the requested feature

I'd like to see support for running a complete package, rather than only single scripts. So given a project including a structure similar to:

...
./src/fletbox
./src/fletbox/__init__.py
./src/fletbox/counter.py

and from fletbox import counter in __init__.py, I should be able to do flet run --module fletbox or similar.

Suggest a solution

So far I have found I can use the form flet run -m src.fletbox, which is not intuitive, and it errors:

Traceback (most recent call last):
  File "<frozen runpy>", line 189, in _run_module_as_main
  File "<frozen runpy>", line 148, in _get_module_details
  File "<frozen runpy>", line 112, in _get_module_details
  File "/home/skeledrew/Projects/fletbox/src/fletbox/__init__.py", line 3, in <module>
    from fletbox import counter
ModuleNotFoundError: No module named 'fletbox'

This can be fixed by updating the path in init.py`:

import sys
from pathlib import Path

sys.path.append(str(Path(__file__).parent.parent))

from fletbox import counter

This path update is something better done in the flet-cli package, and I'd update it myself, however my primary target is Android, and the behavior would be undefined. So solving for non-desktop platforms is a key concern.

Screenshots

No response

Additional details

No response

skeledrew avatar Nov 08 '25 00:11 skeledrew