flet-desktop-light 0.25.0__py3-none-musllinux_1_2_aarch64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,178 @@
1
+ import asyncio
2
+ import logging
3
+ import os
4
+ import signal
5
+ import subprocess
6
+ import tarfile
7
+ import tempfile
8
+ import urllib.request
9
+ import zipfile
10
+ from pathlib import Path
11
+
12
+ from flet.utils import (
13
+ get_arch,
14
+ is_linux,
15
+ is_macos,
16
+ is_windows,
17
+ random_string,
18
+ safe_tar_extractall,
19
+ )
20
+
21
+ import flet_desktop
22
+ import flet_desktop.version
23
+
24
+ logger = logging.getLogger(flet_desktop.__name__)
25
+
26
+
27
+ def get_package_bin_dir():
28
+ return str(Path(__file__).parent.joinpath("app"))
29
+
30
+
31
+ def open_flet_view(page_url, assets_dir, hidden):
32
+ args, flet_env, pid_file = __locate_and_unpack_flet_view(
33
+ page_url, assets_dir, hidden
34
+ )
35
+ return subprocess.Popen(args, env=flet_env), pid_file
36
+
37
+
38
+ async def open_flet_view_async(page_url, assets_dir, hidden):
39
+ args, flet_env, pid_file = __locate_and_unpack_flet_view(
40
+ page_url, assets_dir, hidden
41
+ )
42
+ return (
43
+ await asyncio.create_subprocess_exec(args[0], *args[1:], env=flet_env),
44
+ pid_file,
45
+ )
46
+
47
+
48
+ def close_flet_view(pid_file):
49
+ if pid_file is not None and os.path.exists(pid_file):
50
+ try:
51
+ with open(pid_file) as f:
52
+ fvp_pid = int(f.read())
53
+ logger.debug(f"Flet View process {fvp_pid}")
54
+ os.kill(fvp_pid, signal.SIGKILL)
55
+ except Exception:
56
+ pass
57
+ finally:
58
+ os.remove(pid_file)
59
+
60
+
61
+ def __locate_and_unpack_flet_view(page_url, assets_dir, hidden):
62
+ logger.info("Starting Flet View app...")
63
+
64
+ args = []
65
+
66
+ # pid file - Flet client writes its process ID to this file
67
+ pid_file = str(Path(tempfile.gettempdir()).joinpath(random_string(20)))
68
+
69
+ if is_windows():
70
+ flet_exe = "flet.exe"
71
+ temp_flet_dir = Path.home().joinpath(
72
+ ".flet", "bin", f"flet-{flet_desktop.version.version}"
73
+ )
74
+
75
+ # check if flet_view.exe exists in "bin" directory (user mode)
76
+ flet_path = os.path.join(get_package_bin_dir(), "flet", flet_exe)
77
+ if os.path.exists(flet_path):
78
+ logger.info(f"Flet View found in: {flet_path}")
79
+ else:
80
+ # check if flet.exe is in FLET_VIEW_PATH (flet developer mode)
81
+ flet_path = os.environ.get("FLET_VIEW_PATH")
82
+ if flet_path and os.path.exists(flet_path):
83
+ logger.info(f"Flet View found in PATH: {flet_path}")
84
+ flet_path = os.path.join(flet_path, flet_exe)
85
+ else:
86
+ if not temp_flet_dir.exists():
87
+ zip_file = __download_flet_client("flet-windows.zip")
88
+
89
+ logger.info(f"Extracting flet.exe from archive to {temp_flet_dir}")
90
+ temp_flet_dir.mkdir(parents=True, exist_ok=True)
91
+ with zipfile.ZipFile(zip_file, "r") as zip_arch:
92
+ zip_arch.extractall(str(temp_flet_dir))
93
+ flet_path = str(temp_flet_dir.joinpath("flet", flet_exe))
94
+ args = [flet_path, page_url, pid_file]
95
+ elif is_macos():
96
+ # build version-specific path to Flet.app
97
+ temp_flet_dir = Path.home().joinpath(
98
+ ".flet", "bin", f"flet-{flet_desktop.version.version}"
99
+ )
100
+
101
+ # check if flet.exe is in FLET_VIEW_PATH (flet developer mode)
102
+ flet_path = os.environ.get("FLET_VIEW_PATH")
103
+ if flet_path:
104
+ logger.info(f"Flet.app is set via FLET_VIEW_PATH: {flet_path}")
105
+ temp_flet_dir = Path(flet_path)
106
+ else:
107
+ # check if flet_view.app exists in a temp directory
108
+ if not temp_flet_dir.exists():
109
+ # check if flet.tar.gz exists
110
+ gz_filename = "flet-macos.tar.gz"
111
+ tar_file = os.path.join(get_package_bin_dir(), gz_filename)
112
+ if not os.path.exists(tar_file):
113
+ tar_file = __download_flet_client(gz_filename)
114
+
115
+ logger.info(f"Extracting Flet.app from archive to {temp_flet_dir}")
116
+ temp_flet_dir.mkdir(parents=True, exist_ok=True)
117
+ with tarfile.open(str(tar_file), "r:gz") as tar_arch:
118
+ safe_tar_extractall(tar_arch, str(temp_flet_dir))
119
+ else:
120
+ logger.info(f"Flet View found in: {temp_flet_dir}")
121
+
122
+ app_name = None
123
+ for f in os.listdir(temp_flet_dir):
124
+ if f.endswith(".app"):
125
+ app_name = f
126
+ assert app_name is not None, f"Application bundle not found in {temp_flet_dir}"
127
+ app_path = temp_flet_dir.joinpath(app_name)
128
+ args = ["open", str(app_path), "-n", "-W", "--args", page_url, pid_file]
129
+ elif is_linux():
130
+ # build version-specific path to flet folder
131
+ temp_flet_dir = Path.home().joinpath(
132
+ ".flet", "bin", f"flet-{flet_desktop.version.version}"
133
+ )
134
+
135
+ app_path = None
136
+ # check if flet.exe is in FLET_VIEW_PATH (flet developer mode)
137
+ flet_path = os.environ.get("FLET_VIEW_PATH")
138
+ if flet_path:
139
+ logger.info(f"Flet View is set via FLET_VIEW_PATH: {flet_path}")
140
+ temp_flet_dir = Path(flet_path)
141
+ app_path = temp_flet_dir.joinpath("flet")
142
+ else:
143
+ # check if flet_view.app exists in a temp directory
144
+ if not temp_flet_dir.exists():
145
+ # check if flet.tar.gz exists
146
+ gz_filename = f"flet-linux-{get_arch()}.tar.gz"
147
+ tar_file = os.path.join(get_package_bin_dir(), gz_filename)
148
+ if not os.path.exists(tar_file):
149
+ tar_file = __download_flet_client(gz_filename)
150
+
151
+ logger.info(f"Extracting Flet from archive to {temp_flet_dir}")
152
+ temp_flet_dir.mkdir(parents=True, exist_ok=True)
153
+ with tarfile.open(str(tar_file), "r:gz") as tar_arch:
154
+ safe_tar_extractall(tar_arch, str(temp_flet_dir))
155
+ else:
156
+ logger.info(f"Flet View found in: {temp_flet_dir}")
157
+
158
+ app_path = temp_flet_dir.joinpath("flet", "flet")
159
+ args = [str(app_path), page_url, pid_file]
160
+
161
+ flet_env = {**os.environ}
162
+
163
+ if assets_dir:
164
+ args.append(assets_dir)
165
+
166
+ if hidden:
167
+ flet_env["FLET_HIDE_WINDOW_ON_START"] = "true"
168
+
169
+ return args, flet_env, pid_file
170
+
171
+
172
+ def __download_flet_client(file_name):
173
+ ver = flet_desktop.version.version
174
+ temp_arch = Path(tempfile.gettempdir()).joinpath(file_name)
175
+ logger.info(f"Downloading Flet v{ver} to {temp_arch}")
176
+ flet_url = f"https://github.com/flet-dev/flet/releases/download/v{ver}/{file_name}"
177
+ urllib.request.urlretrieve(flet_url, temp_arch)
178
+ return str(temp_arch)
Binary file
@@ -0,0 +1 @@
1
+ version = "0.25.0"
@@ -0,0 +1,25 @@
1
+ Metadata-Version: 2.1
2
+ Name: flet-desktop-light
3
+ Version: 0.25.0
4
+ Summary: Flet Desktop client in Flutter
5
+ License: Apache-2.0
6
+ Author: Appveyor Systems Inc.
7
+ Author-email: hello@flet.dev
8
+ Requires-Python: >=3.8,<4.0
9
+ Classifier: License :: OSI Approved :: Apache Software License
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.8
12
+ Classifier: Programming Language :: Python :: 3.9
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Requires-Dist: flet (==0.25.0)
18
+ Project-URL: documentation, https://flet.dev/docs
19
+ Project-URL: homepage, https://flet.dev
20
+ Project-URL: repository, https://github.com/flet-dev/flet
21
+ Description-Content-Type: text/markdown
22
+
23
+ # Flet Desktop client in Flutter
24
+
25
+ This package contains a compiled Flutter Flet desktop client.
@@ -0,0 +1,6 @@
1
+ flet_desktop/__init__.py,sha256=CtqPLA0DvZuFidnu_UEE_-F197SviQtjekV7fS82LOw,6538
2
+ flet_desktop/version.py,sha256=7GJU11wOEbILrVlgIpYpRfaUj6J_QdwKmOB1cFXuNPs,19
3
+ flet_desktop/app/flet-linux-arm64.tar.gz,sha256=rRPq6qsNxKIZZUtyAAAEatgJt4gjFDg3zgy9qcui_L0,14750983
4
+ flet_desktop_light-0.25.0.dist-info/METADATA,sha256=N9k5gGtDBCGBmyAW_MNmEKyDmyTbaAEjE2YG3RgK7r8,941
5
+ flet_desktop_light-0.25.0.dist-info/WHEEL,sha256=FPa_FUoAuiP1FnyATIVWtqK3IOSYvvJIdZuCANv4Nuk,106
6
+ flet_desktop_light-0.25.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: poetry-core 1.9.1
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-musllinux_1_2_aarch64