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