Skip to content

Commit cc998cd

Browse files
Merge flet-core into flet, flet package extras (#4251)
* Merge flet_core into flet * Reformat __init__ * Fix logger * inroduce Flet extras * Fix tests and some imports * Fix tests * Update markers, create flet.cli redirect * Fix PubSubHub references * On-demand install flet packages * Fix verson in dependent packages * Complete merge of main * Fix deprecated enum metaclasses * Fix tests
1 parent 93cce26 commit cc998cd

File tree

284 files changed

+2866
-2198
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

284 files changed

+2866
-2198
lines changed

.appveyor.yml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,8 @@ for:
199199
- ps: |
200200
$ErrorActionPreference = "Stop"
201201
$env:PYPI_VER = $env:APPVEYOR_BUILD_VERSION.replace("+", ".dev")
202-
$vp = "$env:flet_sdk_root/packages/flet-core/src/flet_core/version.py"; (Get-Content $vp).replace("version = `"`"", "version = `"$env:PYPI_VER`"") | Set-Content $vp
202+
$vp = "$env:flet_sdk_root/packages/flet/src/flet/version.py"; (Get-Content $vp).replace("version = `"`"", "version = `"$env:PYPI_VER`"") | Set-Content $vp
203203
- python ci/patch_toml_versions.py %flet_sdk_root%/packages/flet-desktop/pyproject.toml %PYPI_VER%
204-
- python ci/patch_toml_versions.py %flet_sdk_root%/packages/flet-core/pyproject.toml %PYPI_VER%
205204

206205
- cd client
207206
- set RELEASE_DIR=build\windows\x64\runner\Release
@@ -491,11 +490,6 @@ for:
491490
- cd $flet_sdk_root
492491
- poetry install
493492

494-
# build "flet-core" package
495-
- pushd packages/flet-core
496-
- poetry build
497-
- popd
498-
499493
# build "flet-cli" package
500494
- pushd packages/flet-cli
501495
- poetry build
@@ -510,11 +504,9 @@ for:
510504
# publish package
511505
- |
512506
publish_to_pypi \
513-
packages/flet-core/dist/*.whl \
514507
packages/flet-cli/dist/*.whl \
515508
packages/flet/dist/*.whl
516509
517510
artifacts:
518-
- path: sdk/python/packages/flet-core/dist/*
519511
- path: sdk/python/packages/flet-cli/dist/*
520512
- path: sdk/python/packages/flet/dist/*

ci/clean-pypi.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#VER="0\.22\.0\.dev"
33
#VER="0\.21\.1"
44
pypi-cleanup -u flet -p flet -y -r $VER --do-it
5-
pypi-cleanup -u flet -p flet-core -y -r $VER --do-it
6-
pypi-cleanup -u flet -p flet-runtime -y -r $VER --do-it
7-
pypi-cleanup -u flet -p flet-embed -y -r $VER --do-it
8-
pypi-cleanup -u flet -p flet-pyodide -y -r $VER --do-it
5+
pypi-cleanup -u flet -p flet-cli -y -r $VER --do-it
6+
pypi-cleanup -u flet -p flet-desktop -y -r $VER --do-it
7+
pypi-cleanup -u flet -p flet-web -y -r $VER --do-it

ci/common.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ pip install --upgrade setuptools wheel twine poetry tomlkit virtualenv
77

88
function patch_python_package_versions() {
99
PYPI_VER="${APPVEYOR_BUILD_VERSION/+/.dev}"
10-
sed -i -e "s/version = \"\"/version = \"$PYPI_VER\"/g" $flet_sdk_root/packages/flet-core/src/flet_core/version.py
10+
sed -i -e "s/version = \"\"/version = \"$PYPI_VER\"/g" $flet_sdk_root/packages/flet/src/flet/version.py
1111
python3 $root/ci/patch_toml_versions.py $flet_sdk_root/packages/flet/pyproject.toml $PYPI_VER
1212
python3 $root/ci/patch_toml_versions.py $flet_sdk_root/packages/flet-cli/pyproject.toml $PYPI_VER
13-
python3 $root/ci/patch_toml_versions.py $flet_sdk_root/packages/flet-core/pyproject.toml $PYPI_VER
1413
python3 $root/ci/patch_toml_versions.py $flet_sdk_root/packages/flet-desktop/pyproject.toml $PYPI_VER
1514
python3 $root/ci/patch_toml_versions.py $flet_sdk_root/packages/flet-web/pyproject.toml $PYPI_VER
1615
}

ci/patch_toml_versions.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ def patch_dep(dep_name):
3232
deps[dep_name] = ver
3333

3434

35-
patch_dep("flet-core")
3635
patch_dep("flet-cli")
3736
patch_dep("flet-desktop")
3837
patch_dep("flet-web")

ci/update-flet-wheel-deps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def update_metadata(metadata_file, version):
3838
if lines[i].startswith("Requires-Dist: flet-desktop "):
3939
lines.insert(
4040
i + 1,
41-
f"Requires-Dist: flet-desktop-light (=={version}) ; platform_system == 'Linux' and 'embedded' not in platform_version\n",
41+
f'Requires-Dist: flet-desktop-light (=={version}) ; platform_system == "Linux" and (extra == "all" or extra == "desktop")\n',
4242
)
4343
lines[i] = re.sub(
4444
r'platform_system != "desktop-light"',

sdk/python/packages/flet-cli/pyproject.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,19 @@ documentation = "https://flet.dev/docs"
1515

1616
[tool.poetry.dependencies]
1717
python = "^3.8"
18+
flet = { version = "0.1.0" }
1819
watchdog = "^4.0.0"
1920
packaging = "*"
2021
qrcode = "^7.4.2"
2122
toml = "^0.10.2"
2223
cookiecutter = "^2.6.0"
2324

25+
[tool.poetry.scripts]
26+
flet = "flet_cli.cli:main"
27+
28+
[tool.poetry.plugins."pyinstaller40"]
29+
hook-dirs = "flet_cli.__pyinstaller:get_hook_dirs"
30+
2431
[build-system]
2532
requires = ["poetry-core"]
2633
build-backend = "poetry.core.masonry.api"

sdk/python/packages/flet-cli/src/flet_cli/__pyinstaller/macos_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import tarfile
66
from pathlib import Path
77

8-
from flet_core.utils import safe_tar_extractall
8+
from flet.utils import safe_tar_extractall
99
from PyInstaller.building.icon import normalize_icon_type
1010

1111

sdk/python/packages/flet-cli/src/flet_cli/__pyinstaller/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import uuid
44
from pathlib import Path
55

6-
from flet_core.utils import copy_tree
6+
from flet.utils import copy_tree
77
from flet_desktop import get_package_bin_dir
88

99

sdk/python/packages/flet-cli/src/flet_cli/commands/build.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import argparse
22
import glob
3-
import json
43
import os
54
import platform
65
import re
@@ -13,16 +12,15 @@
1312
import flet.version
1413
import toml
1514
import yaml
15+
from flet.utils import copy_tree, is_windows, slugify
16+
from flet.utils.platform_utils import get_bool_env_var
1617
from flet.version import update_version
17-
from flet_core.utils import copy_tree, is_windows, slugify
18-
from flet_core.utils.platform_utils import get_bool_env_var
18+
from flet_cli.commands.base import BaseCommand
19+
from flet_cli.utils.merge import merge_dict
1920
from packaging import version
2021
from rich.console import Console, Style
2122
from rich.table import Column, Table
2223

23-
from flet_cli.commands.base import BaseCommand
24-
from flet_cli.utils.merge import merge_dict
25-
2624
if is_windows():
2725
from ctypes import windll
2826

sdk/python/packages/flet-cli/src/flet_cli/commands/create.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
from pathlib import Path
44

55
import flet.version
6+
from flet.utils import slugify
67
from flet_cli.commands.base import BaseCommand
7-
from flet_core.utils import slugify
88
from packaging import version
99
from rich import print
1010

sdk/python/packages/flet-cli/src/flet_cli/commands/pack.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
import sys
55
from pathlib import Path
66

7-
from flet_core.utils import is_macos, is_windows
8-
97
import flet_cli.__pyinstaller.config as hook_config
8+
from flet.utils import is_macos, is_windows
109
from flet_cli.commands.base import BaseCommand
1110

1211

@@ -132,6 +131,14 @@ def add_arguments(self, parser: argparse.ArgumentParser) -> None:
132131
)
133132

134133
def handle(self, options: argparse.Namespace) -> None:
134+
135+
try:
136+
import flet_desktop
137+
except:
138+
from flet_cli.utils.pip import install_flet_package
139+
140+
install_flet_package("flet-desktop")
141+
135142
is_dir_not_empty = lambda dir: os.path.isdir(dir) and len(os.listdir(dir)) != 0
136143

137144
# delete "build" directory
@@ -173,7 +180,6 @@ def handle(self, options: argparse.Namespace) -> None:
173180

174181
try:
175182
import PyInstaller.__main__
176-
177183
from flet_cli.__pyinstaller.utils import copy_flet_bin
178184

179185
pyi_args = [options.script, "--noconfirm"]

sdk/python/packages/flet-cli/src/flet_cli/commands/publish.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@
77
import tempfile
88
from pathlib import Path
99

10+
from flet.core.types import WebRenderer
11+
from flet.utils import copy_tree, is_within_directory, random_string
1012
from flet_cli.commands.base import BaseCommand
11-
from flet_core.types import WebRenderer
12-
from flet_core.utils import copy_tree, is_within_directory, random_string
13-
from flet_web import get_package_web_dir, patch_index_html, patch_manifest_json
1413

1514

1615
class Command(BaseCommand):
@@ -91,6 +90,15 @@ def add_arguments(self, parser: argparse.ArgumentParser) -> None:
9190
)
9291

9392
def handle(self, options: argparse.Namespace) -> None:
93+
try:
94+
import flet_web
95+
except:
96+
from flet_cli.utils.pip import install_flet_package
97+
98+
install_flet_package("flet-web")
99+
100+
from flet_web import get_package_web_dir, patch_index_html, patch_manifest_json
101+
94102
# constants
95103
dist_name = "dist"
96104
app_tar_gz_filename = "app.tar.gz"

sdk/python/packages/flet-cli/src/flet_cli/commands/run.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,14 @@
1111
from urllib.parse import quote, urlparse, urlunparse
1212

1313
import qrcode
14-
from flet.utils import get_free_tcp_port, get_local_ip, open_in_browser
14+
from flet.utils import (
15+
get_free_tcp_port,
16+
get_local_ip,
17+
is_windows,
18+
open_in_browser,
19+
random_string,
20+
)
1521
from flet_cli.commands.base import BaseCommand
16-
from flet_core.utils import is_windows, random_string
17-
from flet_desktop import close_flet_view, open_flet_view
1822
from watchdog.events import FileSystemEventHandler
1923
from watchdog.observers import Observer
2024

@@ -125,6 +129,20 @@ def add_arguments(self, parser: argparse.ArgumentParser) -> None:
125129
)
126130

127131
def handle(self, options: argparse.Namespace) -> None:
132+
from flet_cli.utils.pip import install_flet_package
133+
134+
if options.web:
135+
try:
136+
import flet_web
137+
except:
138+
install_flet_package("flet-web")
139+
else:
140+
try:
141+
import flet_desktop
142+
except:
143+
install_flet_package("flet-desktop")
144+
from flet_desktop import close_flet_view
145+
128146
if options.module:
129147
script_path = str(options.script).replace(".", "/")
130148
if os.path.isdir(script_path):
@@ -321,6 +339,8 @@ def print_output(self, p):
321339
print(line)
322340

323341
def open_flet_view_and_wait(self):
342+
from flet_desktop import open_flet_view
343+
324344
self.fvp, self.pid_file = open_flet_view(
325345
self.page_url, self.assets_dir, self.hidden
326346
)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import subprocess
2+
import sys
3+
4+
import flet_cli.version
5+
6+
7+
def install_flet_package(name: str):
8+
subprocess.call(
9+
[
10+
sys.executable,
11+
"-m",
12+
"pip",
13+
"install",
14+
"-q",
15+
"--disable-pip-version-check",
16+
f"{name}=={flet_cli.version.version}",
17+
]
18+
)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""Provide the current Flet version."""
22

3-
import flet_core.version
3+
import flet.version
44

5-
version = flet_core.version.version
5+
version = flet.version.version

sdk/python/packages/flet-core/README.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

sdk/python/packages/flet-core/pyproject.toml

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)