flet-desktop-light 0.70.0.dev6232__tar.gz

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,16 @@
1
+ Metadata-Version: 2.4
2
+ Name: flet-desktop-light
3
+ Version: 0.70.0.dev6232
4
+ Summary: Flet Desktop client in Flutter
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
15
+
16
+ This package contains a compiled Flutter Flet desktop client.
@@ -0,0 +1,3 @@
1
+ # Flet Desktop client in Flutter
2
+
3
+ This package contains a compiled Flutter Flet desktop client.
@@ -0,0 +1,23 @@
1
+ [project]
2
+ name = "flet-desktop-light"
3
+ version = "0.70.0.dev6232"
4
+ description = "Flet Desktop client in Flutter"
5
+ authors = [{ name = "Appveyor Systems Inc.", email = "hello@flet.dev" }]
6
+ license = "Apache-2.0"
7
+ readme = "README.md"
8
+ requires-python = ">=3.10"
9
+ dependencies = [
10
+ "flet"
11
+ ]
12
+
13
+ [project.urls]
14
+ Homepage = "https://flet.dev"
15
+ Repository = "https://github.com/flet-dev/flet"
16
+ Documentation = "https://flet.dev/docs"
17
+
18
+ [tool.setuptools.package-data]
19
+ "flet_desktop.app" = ["**/*"]
20
+
21
+ [build-system]
22
+ requires = ["setuptools"]
23
+ build-backend = "setuptools.build_meta"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,220 @@
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
+ from flet.utils import (
14
+ get_arch,
15
+ is_linux,
16
+ is_macos,
17
+ is_windows,
18
+ random_string,
19
+ safe_tar_extractall,
20
+ )
21
+
22
+ import flet_desktop
23
+ import flet_desktop.version
24
+
25
+ logger = logging.getLogger(flet_desktop.__name__)
26
+
27
+
28
+ def get_package_bin_dir():
29
+ return str(Path(__file__).parent.joinpath("app"))
30
+
31
+
32
+ def open_flet_view(page_url, assets_dir, hidden):
33
+ args, flet_env, pid_file = __locate_and_unpack_flet_view(
34
+ page_url, assets_dir, hidden
35
+ )
36
+ return subprocess.Popen(args, env=flet_env), pid_file
37
+
38
+
39
+ async def open_flet_view_async(page_url, assets_dir, hidden):
40
+ args, flet_env, pid_file = __locate_and_unpack_flet_view(
41
+ page_url, assets_dir, hidden
42
+ )
43
+ return (
44
+ await asyncio.create_subprocess_exec(args[0], *args[1:], env=flet_env),
45
+ pid_file,
46
+ )
47
+
48
+
49
+ def close_flet_view(pid_file):
50
+ if pid_file is not None and os.path.exists(pid_file):
51
+ try:
52
+ with open(pid_file, encoding="utf-8") as f:
53
+ fvp_pid = int(f.read())
54
+ logger.debug(f"Flet View process {fvp_pid}")
55
+ os.kill(fvp_pid, signal.SIGKILL)
56
+ except Exception:
57
+ pass
58
+ finally:
59
+ os.remove(pid_file)
60
+
61
+
62
+ def __locate_and_unpack_flet_view(page_url, assets_dir, hidden):
63
+ logger.info("Starting Flet View app...")
64
+
65
+ args = []
66
+
67
+ # pid file - Flet client writes its process ID to this file
68
+ pid_file = str(Path(tempfile.gettempdir()).joinpath(random_string(20)))
69
+
70
+ if is_windows():
71
+ flet_path = None
72
+ # try loading Flet client built with the latest run of `flet build`
73
+ build_windows = os.path.join(os.getcwd(), "build", "windows")
74
+ if os.path.exists(build_windows):
75
+ for f in os.listdir(build_windows):
76
+ if f.endswith(".exe"):
77
+ flet_path = os.path.join(build_windows, f)
78
+
79
+ if not flet_path:
80
+ flet_exe = "flet.exe"
81
+ temp_flet_dir = Path.home().joinpath(
82
+ ".flet", "bin", f"flet-{flet_desktop.version.version}"
83
+ )
84
+
85
+ # check if flet_view.exe exists in "bin" directory (user mode)
86
+ flet_path = os.path.join(get_package_bin_dir(), "flet", flet_exe)
87
+ logger.info(f"Looking for Flet executable at: {flet_path}")
88
+ if os.path.exists(flet_path):
89
+ logger.info(f"Flet View found in: {flet_path}")
90
+ else:
91
+ # check if flet.exe is in FLET_VIEW_PATH (flet developer mode)
92
+ flet_path = os.environ.get("FLET_VIEW_PATH")
93
+ if flet_path and os.path.exists(flet_path):
94
+ logger.info(f"Flet View found in PATH: {flet_path}")
95
+ flet_path = os.path.join(flet_path, flet_exe)
96
+ else:
97
+ if not temp_flet_dir.exists():
98
+ zip_file = __download_flet_client("flet-windows.zip")
99
+
100
+ logger.info(
101
+ f"Extracting flet.exe from archive to {temp_flet_dir}"
102
+ )
103
+ temp_flet_dir.mkdir(parents=True, exist_ok=True)
104
+ with zipfile.ZipFile(zip_file, "r") as zip_arch:
105
+ zip_arch.extractall(str(temp_flet_dir))
106
+ flet_path = str(temp_flet_dir.joinpath("flet", flet_exe))
107
+ args = [flet_path, page_url, pid_file]
108
+ elif is_macos():
109
+ app_path = None
110
+ # try loading Flet client built with the latest run of `flet build`
111
+ build_macos = os.path.join(os.getcwd(), "build", "macos")
112
+ if os.path.exists(build_macos):
113
+ for f in os.listdir(build_macos):
114
+ if f.endswith(".app"):
115
+ app_path = os.path.join(build_macos, f)
116
+
117
+ if not app_path:
118
+ # build version-specific path to Flet.app
119
+ temp_flet_dir = Path.home().joinpath(
120
+ ".flet", "bin", f"flet-{flet_desktop.version.version}"
121
+ )
122
+
123
+ # check if flet.exe is in FLET_VIEW_PATH (flet developer mode)
124
+ flet_path = os.environ.get("FLET_VIEW_PATH")
125
+ if flet_path:
126
+ logger.info(f"Flet.app is set via FLET_VIEW_PATH: {flet_path}")
127
+ temp_flet_dir = Path(flet_path)
128
+ else:
129
+ # check if flet_view.app exists in a temp directory
130
+ if not temp_flet_dir.exists():
131
+ # check if flet.tar.gz exists
132
+ gz_filename = "flet-macos.tar.gz"
133
+ tar_file = os.path.join(get_package_bin_dir(), gz_filename)
134
+ logger.info(f"Looking for Flet.app archive at: {tar_file}")
135
+ if not os.path.exists(tar_file):
136
+ tar_file = __download_flet_client(gz_filename)
137
+
138
+ logger.info(f"Extracting Flet.app from archive to {temp_flet_dir}")
139
+ temp_flet_dir.mkdir(parents=True, exist_ok=True)
140
+ with tarfile.open(str(tar_file), "r:gz") as tar_arch:
141
+ safe_tar_extractall(tar_arch, str(temp_flet_dir))
142
+ else:
143
+ logger.info(f"Flet View found in: {temp_flet_dir}")
144
+
145
+ app_name = None
146
+ for f in os.listdir(temp_flet_dir):
147
+ if f.endswith(".app"):
148
+ app_name = f
149
+ assert app_name is not None, (
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
+ from flet.version import update_version
214
+
215
+ ver = flet.version.version or update_version()
216
+ temp_arch = Path(tempfile.gettempdir()).joinpath(file_name)
217
+ flet_url = f"https://github.com/flet-dev/flet/releases/download/v{ver}/{file_name}"
218
+ logger.info(f"Downloading Flet v{ver} from {flet_url} to {temp_arch}")
219
+ urllib.request.urlretrieve(flet_url, temp_arch)
220
+ return str(temp_arch)
@@ -0,0 +1 @@
1
+ version = "0.70.0.dev6232"
@@ -0,0 +1,16 @@
1
+ Metadata-Version: 2.4
2
+ Name: flet-desktop-light
3
+ Version: 0.70.0.dev6232
4
+ Summary: Flet Desktop client in Flutter
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
15
+
16
+ This package contains a compiled Flutter Flet desktop client.
@@ -0,0 +1,9 @@
1
+ README.md
2
+ pyproject.toml
3
+ src/flet_desktop/__init__.py
4
+ src/flet_desktop/version.py
5
+ src/flet_desktop_light.egg-info/PKG-INFO
6
+ src/flet_desktop_light.egg-info/SOURCES.txt
7
+ src/flet_desktop_light.egg-info/dependency_links.txt
8
+ src/flet_desktop_light.egg-info/requires.txt
9
+ src/flet_desktop_light.egg-info/top_level.txt