flet-desktop-light 0.1.0__py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.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.

Potentially problematic release.


This version of flet-desktop-light might be problematic. Click here for more details.

@@ -0,0 +1,219 @@
1
+ import asyncio
2
+ import logging
3
+ import os
4
+ import signal
5
+ import stat
6
+ import subprocess
7
+ import tarfile
8
+ import tempfile
9
+ import urllib.request
10
+ import zipfile
11
+ from pathlib import Path
12
+
13
+ import flet_desktop
14
+ import flet_desktop.version
15
+ from flet.utils import (
16
+ get_arch,
17
+ is_linux,
18
+ is_macos,
19
+ is_windows,
20
+ random_string,
21
+ safe_tar_extractall,
22
+ )
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, encoding="utf-8") 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_path = None
71
+ # try loading Flet client built with the latest run of `flet build`
72
+ build_windows = os.path.join(os.getcwd(), "build", "windows")
73
+ if os.path.exists(build_windows):
74
+ for f in os.listdir(build_windows):
75
+ if f.endswith(".exe"):
76
+ flet_path = os.path.join(build_windows, f)
77
+
78
+ if not flet_path:
79
+ flet_exe = "flet.exe"
80
+ temp_flet_dir = Path.home().joinpath(
81
+ ".flet", "bin", f"flet-{flet_desktop.version.version}"
82
+ )
83
+
84
+ # check if flet_view.exe exists in "bin" directory (user mode)
85
+ flet_path = os.path.join(get_package_bin_dir(), "flet", flet_exe)
86
+ logger.info(f"Looking for Flet executable at: {flet_path}")
87
+ if os.path.exists(flet_path):
88
+ logger.info(f"Flet View found in: {flet_path}")
89
+ else:
90
+ # check if flet.exe is in FLET_VIEW_PATH (flet developer mode)
91
+ flet_path = os.environ.get("FLET_VIEW_PATH")
92
+ if flet_path and os.path.exists(flet_path):
93
+ logger.info(f"Flet View found in PATH: {flet_path}")
94
+ flet_path = os.path.join(flet_path, flet_exe)
95
+ else:
96
+ if not temp_flet_dir.exists():
97
+ zip_file = __download_flet_client("flet-windows.zip")
98
+
99
+ logger.info(
100
+ f"Extracting flet.exe from archive to {temp_flet_dir}"
101
+ )
102
+ temp_flet_dir.mkdir(parents=True, exist_ok=True)
103
+ with zipfile.ZipFile(zip_file, "r") as zip_arch:
104
+ zip_arch.extractall(str(temp_flet_dir))
105
+ flet_path = str(temp_flet_dir.joinpath("flet", flet_exe))
106
+ args = [flet_path, page_url, pid_file]
107
+ elif is_macos():
108
+ app_path = None
109
+ # try loading Flet client built with the latest run of `flet build`
110
+ build_macos = os.path.join(os.getcwd(), "build", "macos")
111
+ if os.path.exists(build_macos):
112
+ for f in os.listdir(build_macos):
113
+ if f.endswith(".app"):
114
+ app_path = os.path.join(build_macos, f)
115
+
116
+ if not app_path:
117
+ # build version-specific path to Flet.app
118
+ temp_flet_dir = Path.home().joinpath(
119
+ ".flet", "bin", f"flet-{flet_desktop.version.version}"
120
+ )
121
+
122
+ # check if flet.exe is in FLET_VIEW_PATH (flet developer mode)
123
+ flet_path = os.environ.get("FLET_VIEW_PATH")
124
+ if flet_path:
125
+ logger.info(f"Flet.app is set via FLET_VIEW_PATH: {flet_path}")
126
+ temp_flet_dir = Path(flet_path)
127
+ else:
128
+ # check if flet_view.app exists in a temp directory
129
+ if not temp_flet_dir.exists():
130
+ # check if flet.tar.gz exists
131
+ gz_filename = "flet-macos.tar.gz"
132
+ tar_file = os.path.join(get_package_bin_dir(), gz_filename)
133
+ logger.info(f"Looking for Flet.app archive at: {tar_file}")
134
+ if not os.path.exists(tar_file):
135
+ tar_file = __download_flet_client(gz_filename)
136
+
137
+ logger.info(f"Extracting Flet.app from archive to {temp_flet_dir}")
138
+ temp_flet_dir.mkdir(parents=True, exist_ok=True)
139
+ with tarfile.open(str(tar_file), "r:gz") as tar_arch:
140
+ safe_tar_extractall(tar_arch, str(temp_flet_dir))
141
+ else:
142
+ logger.info(f"Flet View found in: {temp_flet_dir}")
143
+
144
+ app_name = None
145
+ for f in os.listdir(temp_flet_dir):
146
+ if f.endswith(".app"):
147
+ app_name = f
148
+ if app_name is None:
149
+ raise FileNotFoundError(
150
+ f"Application bundle not found in {temp_flet_dir}"
151
+ )
152
+ app_path = temp_flet_dir.joinpath(app_name)
153
+ logger.info(f"page_url: {page_url}")
154
+ logger.info(f"pid_file: {pid_file}")
155
+ args = ["open", str(app_path), "-n", "-W", "--args", page_url, pid_file]
156
+ elif is_linux():
157
+ app_path = None
158
+ # try loading Flet client built with the latest run of `flet build`
159
+ build_linux = os.path.join(os.getcwd(), "build", "linux")
160
+ if os.path.exists(build_linux):
161
+ for f in os.listdir(build_linux):
162
+ ef = os.path.join(build_linux, f)
163
+ if os.path.isfile(ef) and stat.S_IXUSR & os.stat(ef)[stat.ST_MODE]:
164
+ app_path = ef
165
+
166
+ if not app_path:
167
+ # build version-specific path to flet folder
168
+ temp_flet_dir = Path.home().joinpath(
169
+ ".flet", "bin", f"flet-{flet_desktop.version.version}"
170
+ )
171
+
172
+ # check if flet.exe is in FLET_VIEW_PATH (flet developer mode)
173
+ flet_path = os.environ.get("FLET_VIEW_PATH")
174
+ if flet_path:
175
+ logger.info(f"Flet View is set via FLET_VIEW_PATH: {flet_path}")
176
+ temp_flet_dir = Path(flet_path)
177
+ app_path = temp_flet_dir.joinpath("flet")
178
+ else:
179
+ # check if flet_view.app exists in a temp directory
180
+ if not temp_flet_dir.exists():
181
+ # check if flet.tar.gz exists
182
+ gz_filename = f"flet-linux-{get_arch()}.tar.gz"
183
+ tar_file = os.path.join(get_package_bin_dir(), gz_filename)
184
+ logger.info(f"Looking for Flet bundle archive at: {tar_file}")
185
+ if not os.path.exists(tar_file):
186
+ tar_file = __download_flet_client(gz_filename)
187
+
188
+ logger.info(f"Extracting Flet from archive to {temp_flet_dir}")
189
+ temp_flet_dir.mkdir(parents=True, exist_ok=True)
190
+ with tarfile.open(str(tar_file), "r:gz") as tar_arch:
191
+ safe_tar_extractall(tar_arch, str(temp_flet_dir))
192
+ else:
193
+ logger.info(f"Flet View found in: {temp_flet_dir}")
194
+
195
+ app_path = temp_flet_dir.joinpath("flet", "flet")
196
+ args = [str(app_path), page_url, pid_file]
197
+
198
+ flet_env = {**os.environ}
199
+
200
+ if assets_dir:
201
+ args.append(assets_dir)
202
+
203
+ if hidden:
204
+ flet_env["FLET_HIDE_WINDOW_ON_START"] = "true"
205
+
206
+ return args, flet_env, pid_file
207
+
208
+
209
+ def __download_flet_client(file_name):
210
+ ver = flet_desktop.version.version
211
+ if not ver:
212
+ import flet.version
213
+
214
+ ver = flet.version.flet_version
215
+ temp_arch = Path(tempfile.gettempdir()).joinpath(file_name)
216
+ flet_url = f"https://github.com/flet-dev/flet/releases/download/v{ver}/{file_name}"
217
+ logger.info(f"Downloading Flet v{ver} from {flet_url} to {temp_arch}")
218
+ urllib.request.urlretrieve(flet_url, temp_arch)
219
+ return str(temp_arch)
Binary file
@@ -0,0 +1 @@
1
+ version = ""
@@ -0,0 +1,17 @@
1
+ Metadata-Version: 2.4
2
+ Name: flet-desktop-light
3
+ Version: 0.1.0
4
+ Summary: Flet Desktop client in Flutter (light)
5
+ Author-email: "Appveyor Systems Inc." <hello@flet.dev>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://flet.dev
8
+ Project-URL: Repository, https://github.com/flet-dev/flet
9
+ Project-URL: Documentation, https://flet.dev/docs
10
+ Requires-Python: >=3.10
11
+ Description-Content-Type: text/markdown
12
+ Requires-Dist: flet
13
+
14
+ # Flet Desktop client in Flutter (light)
15
+
16
+ This package contains a compiled Flutter Flet desktop client with audio and video
17
+ components removed.
@@ -0,0 +1,7 @@
1
+ flet_desktop/__init__.py,sha256=7S9FvCf4H5jbbbfcIgu8dkUxbysSnTHgDeo4SZUMo0I,8611
2
+ flet_desktop/version.py,sha256=0ePmO_Cak8o-_6HvGni7ZWTWmm9C8Mbz8SamFrt-rLw,13
3
+ flet_desktop/app/flet-linux-amd64.tar.gz,sha256=CkFDEDU00UQUSNZOplpo4zDzMhQUCOG2VyuAx1T15ps,22067317
4
+ flet_desktop_light-0.1.0.dist-info/METADATA,sha256=HONzpKcUuBhhF3lud7gAf6ui_knasO7sHr_BEkP5bRw,573
5
+ flet_desktop_light-0.1.0.dist-info/WHEEL,sha256=gwD9f5M5Vdr7HHdR6LliiNmtaZilYS8xg_t2LSyoFMM,144
6
+ flet_desktop_light-0.1.0.dist-info/top_level.txt,sha256=ugIkH3TGoxP2-XUffs2tqRF1Qi9icFhrR1d1SSzgktc,13
7
+ flet_desktop_light-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,6 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-manylinux_2_17_x86_64
5
+ Tag: py3-none-manylinux2014_x86_64
6
+
@@ -0,0 +1 @@
1
+ flet_desktop