flet-cli 1.1.0.dev2__py3-none-any.whl → 1.1.0.dev4__py3-none-any.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.
@@ -187,6 +187,7 @@ class BaseFlutterCommand(BaseCommand):
187
187
  assert self.options
188
188
  self.required_flutter_version = version.Version(flet.version.flutter_version)
189
189
  if self.required_flutter_version == version.Version("0"):
190
+ self.skip_flutter_doctor = True
190
191
  self.cleanup(
191
192
  1,
192
193
  "Unable to determine the required Flutter SDK version. "
flet_cli/commands/pack.py CHANGED
@@ -247,11 +247,11 @@ class Command(BaseCommand):
247
247
  options: Parsed command-line options.
248
248
  snapshot_path: Path to the client's AOT snapshot.
249
249
  """
250
- from flet_cli.__pyinstaller.extensions import (
250
+ from flet_desktop import get_artifact_filename
251
+ from flet_desktop.extensions import (
251
252
  find_missing_extensions,
252
253
  get_client_extensions,
253
254
  )
254
- from flet_desktop import get_artifact_filename
255
255
 
256
256
  client_extensions = get_client_extensions(snapshot_path)
257
257
  if client_extensions is None:
flet_cli/commands/run.py CHANGED
@@ -1,4 +1,5 @@
1
1
  import argparse
2
+ import contextlib
2
3
  import errno
3
4
  import logging
4
5
  import os
@@ -235,6 +236,13 @@ class Command(BaseCommand):
235
236
  warning names the missing directory. The `"assets"` default is not
236
237
  exported, so the app's own `assets_dir` applies.
237
238
 
239
+ The desktop client is opened from this process, whose working directory
240
+ is where `flet run` was started, so `[tool.flet].desktop_flavor` of the
241
+ nearest `pyproject.toml` at or above the app's script is exported as
242
+ `FLET_DESKTOP_FLAVOR` when that variable is not set. That file may belong
243
+ to an enclosing project rather than the app, so if it can't be read or
244
+ parsed it is ignored instead of stopping the app.
245
+
238
246
  Args:
239
247
  options: Parsed command options produced by :meth:`add_arguments`.
240
248
  """
@@ -284,6 +292,23 @@ class Command(BaseCommand):
284
292
  if options.no_impeller and (options.web or options.ios or options.android):
285
293
  print("Warning: --no-impeller applies only to the desktop app.")
286
294
 
295
+ flavor_dir = next(
296
+ (
297
+ d
298
+ for d in [script_dir.resolve(), *script_dir.resolve().parents]
299
+ if d.joinpath("pyproject.toml").is_file()
300
+ ),
301
+ None,
302
+ )
303
+ desktop_flavor = None
304
+ if flavor_dir:
305
+ with contextlib.suppress(OSError, ValueError, AttributeError, TypeError):
306
+ desktop_flavor = load_pyproject_toml(flavor_dir)(
307
+ "tool.flet.desktop_flavor"
308
+ )
309
+ if desktop_flavor and not os.environ.get("FLET_DESKTOP_FLAVOR"):
310
+ os.environ["FLET_DESKTOP_FLAVOR"] = str(desktop_flavor)
311
+
287
312
  if get_pyproject("tool.flet.app.path"):
288
313
  script_dir = script_dir.joinpath(get_pyproject("tool.flet.app.path"))
289
314
  script_path = script_dir.joinpath(
@@ -668,15 +693,16 @@ class Handler(FileSystemEventHandler):
668
693
  """
669
694
 
670
695
  try:
671
- from flet_desktop import open_flet_view
696
+ from flet_desktop import explain_client_exit, open_flet_view
672
697
 
673
698
  self.fvp, self.pid_file = open_flet_view(
674
699
  self.page_url,
675
700
  self.assets_dir,
676
701
  self.hidden,
677
702
  no_impeller=self.no_impeller,
703
+ app_dir=os.path.dirname(self.script_path),
678
704
  )
679
- self.fvp.wait()
705
+ explain_client_exit(self.fvp.wait())
680
706
  self.p.send_signal(signal.SIGTERM)
681
707
  try:
682
708
  self.p.wait(2)
flet_cli/utils/android.py CHANGED
@@ -57,6 +57,121 @@ def excluded_android_abis(archs: list[str]) -> list[str]:
57
57
  return [abi for abi in ANDROID_ARCH_TO_FLUTTER_TARGET_PLATFORM if abi not in archs]
58
58
 
59
59
 
60
+ def _android_attributes(values: dict, path: str, reserved=()) -> dict:
61
+ """Validate Android attribute names and normalize scalar values for XML.
62
+
63
+ Raises:
64
+ ValueError: If a name is not an attribute name or a value isn't a string,
65
+ boolean, or number.
66
+ """
67
+ resolved = {}
68
+ for key, value in values.items():
69
+ if key in reserved:
70
+ continue
71
+ if not isinstance(key, str) or not re.fullmatch(r"[A-Za-z_][A-Za-z0-9_]*", key):
72
+ raise ValueError(f"Invalid {path}: invalid Android attribute name {key!r}.")
73
+ if not isinstance(value, (str, bool, int, float)):
74
+ raise ValueError(
75
+ f"Invalid {path}.{key}: expected a string, boolean, or number."
76
+ )
77
+ resolved[key] = str(value).lower() if isinstance(value, bool) else str(value)
78
+ return resolved
79
+
80
+
81
+ def normalize_android_intent_filters(filters, path: str) -> list:
82
+ """Validate a list of `<intent-filter>` tables.
83
+
84
+ Each table needs at least one action in `actions` and may have
85
+ `categories` and `data`: a table, or list of tables, of `<data>`
86
+ attributes. Its other entries become the filter's own attributes, such as
87
+ `autoVerify` or `priority`.
88
+
89
+ Args:
90
+ filters: The configured list of filter tables.
91
+ path: The setting's path, used in error messages.
92
+
93
+ Returns:
94
+ Each filter's `attributes`, `actions`, `categories` and `data` list.
95
+
96
+ Raises:
97
+ ValueError: If a filter is malformed.
98
+ """
99
+
100
+ def fail(at, message):
101
+ """Report a malformed filter using its full configuration path."""
102
+ raise ValueError(f"Invalid {at}: {message}.")
103
+
104
+ if not isinstance(filters, list):
105
+ fail(path, "expected a list of filter tables")
106
+ normalized_filters = []
107
+ for index, intent_filter in enumerate(filters):
108
+ filter_path = f"{path}[{index}]"
109
+ if not isinstance(intent_filter, dict):
110
+ fail(filter_path, "expected a filter table")
111
+ for key in ("action", "category"):
112
+ if key in intent_filter:
113
+ fail(f"{filter_path}.{key}", f"use {key}s, a list of names")
114
+ normalized = {
115
+ "attributes": _android_attributes(
116
+ intent_filter, filter_path, ("actions", "categories", "data")
117
+ )
118
+ }
119
+ for key in ("actions", "categories"):
120
+ values = intent_filter.get(key, [])
121
+ if not isinstance(values, list) or not all(
122
+ isinstance(value, str) and value.strip() for value in values
123
+ ):
124
+ fail(f"{filter_path}.{key}", "expected a list of nonempty strings")
125
+ normalized[key] = [value.strip() for value in values]
126
+ if not normalized["actions"]:
127
+ fail(f"{filter_path}.actions", "at least one action is required")
128
+ data = intent_filter.get("data", [])
129
+ single = isinstance(data, dict)
130
+ if not isinstance(data, (dict, list)):
131
+ fail(
132
+ f"{filter_path}.data", "expected a data table or a list of data tables"
133
+ )
134
+ normalized["data"] = []
135
+ for data_index, element in enumerate([data] if single else data):
136
+ data_path = (
137
+ f"{filter_path}.data" if single else f"{filter_path}.data[{data_index}]"
138
+ )
139
+ if not isinstance(element, dict) or not element:
140
+ fail(data_path, "expected a nonempty table of data attributes")
141
+ normalized["data"].append(_android_attributes(element, data_path))
142
+ normalized_filters.append(normalized)
143
+ return normalized_filters
144
+
145
+
146
+ def normalize_android_activity(configured) -> dict:
147
+ """Validate what the app adds to its main activity.
148
+
149
+ Only intent filters are supported; they are added after the activity's own
150
+ launcher and deep-linking filters.
151
+
152
+ Returns:
153
+ A table with the activity's `intent_filters`, empty by default.
154
+
155
+ Raises:
156
+ ValueError: If the table or one of its filters is malformed.
157
+ """
158
+ setting = "tool.flet.android.activity"
159
+ if configured is None:
160
+ return {"intent_filters": []}
161
+ if not isinstance(configured, dict):
162
+ raise ValueError(f"Invalid {setting}: expected a table.")
163
+ for key in configured:
164
+ if key != "intent_filter":
165
+ raise ValueError(
166
+ f"Invalid {setting}.{key}: only intent_filter is supported."
167
+ )
168
+ return {
169
+ "intent_filters": normalize_android_intent_filters(
170
+ configured.get("intent_filter", []), f"{setting}.intent_filter"
171
+ )
172
+ }
173
+
174
+
60
175
  def normalize_android_receivers(configured) -> dict:
61
176
  """Validate receiver tables and normalize their manifest attributes.
62
177
 
@@ -99,35 +214,9 @@ def normalize_android_receivers(configured) -> dict:
99
214
  str(value).lower() if isinstance(value, bool) else str(value)
100
215
  )
101
216
 
102
- filters = receiver.get("intent_filter", [])
103
- if not isinstance(filters, list):
104
- fail(f"{path}.intent_filter", "expected a list of filter tables")
105
- normalized_filters = []
106
- for index, intent_filter in enumerate(filters):
107
- filter_path = f"{path}.intent_filter[{index}]"
108
- if not isinstance(intent_filter, dict):
109
- fail(filter_path, "expected a filter table")
110
- for key in intent_filter:
111
- if key not in ("actions", "categories"):
112
- fail(
113
- f"{filter_path}.{key}",
114
- "only actions and categories are supported",
115
- )
116
- normalized = {}
117
- for key in ("actions", "categories"):
118
- values = intent_filter.get(key, [])
119
- if not isinstance(values, list):
120
- fail(f"{filter_path}.{key}", "expected a list of nonempty strings")
121
- for value in values:
122
- if not isinstance(value, str) or not value.strip():
123
- fail(
124
- f"{filter_path}.{key}",
125
- "expected a list of nonempty strings",
126
- )
127
- normalized[key] = values.copy()
128
- if not normalized["actions"]:
129
- fail(f"{filter_path}.actions", "at least one action is required")
130
- normalized_filters.append(normalized)
217
+ normalized_filters = normalize_android_intent_filters(
218
+ receiver.get("intent_filter", []), f"{path}.intent_filter"
219
+ )
131
220
 
132
221
  if normalized_filters and "exported" not in attributes:
133
222
  fail(
@@ -220,6 +309,157 @@ def normalize_android_services(configured) -> dict:
220
309
  return resolved
221
310
 
222
311
 
312
+ def normalize_android_application_attributes(configured, product_name: str) -> dict:
313
+ """Merge the app's `<application>` attributes over the ones Flet sets.
314
+
315
+ Flet sets `label` to the product name, `name` to Flutter's application
316
+ class, `enableOnBackInvokedCallback` to `true` and `icon` to the launcher
317
+ icon. An entry with the same key replaces Flet's value instead of adding
318
+ the attribute a second time.
319
+
320
+ Args:
321
+ configured: The app's `<application>` attributes, if any.
322
+ product_name: The app's product name, used as the default label.
323
+
324
+ Returns:
325
+ Attribute names mapped to their manifest values; booleans are written
326
+ as lowercase `true` or `false`.
327
+
328
+ Raises:
329
+ ValueError: If the table, an attribute name or a value is malformed.
330
+ """
331
+ setting = "tool.flet.android.manifest_application"
332
+ resolved = {
333
+ "label": product_name,
334
+ "name": "${applicationName}",
335
+ "enableOnBackInvokedCallback": "true",
336
+ "icon": "@mipmap/ic_launcher",
337
+ }
338
+ if configured is None:
339
+ return resolved
340
+ if not isinstance(configured, dict):
341
+ raise ValueError(f"Invalid {setting}: expected a table of attributes.")
342
+ for key, value in configured.items():
343
+ if not isinstance(key, str) or not re.fullmatch(r"[A-Za-z_][A-Za-z0-9_]*", key):
344
+ raise ValueError(
345
+ f"Invalid {setting}: invalid Android attribute name {key!r}."
346
+ )
347
+ if not isinstance(value, (str, bool, int, float)):
348
+ raise ValueError(
349
+ f"Invalid {setting}.{key}: expected a string, boolean, or number."
350
+ )
351
+ resolved[key] = str(value).lower() if isinstance(value, bool) else str(value)
352
+ return resolved
353
+
354
+
355
+ ANDROID_QUERIES_DATA_ATTRIBUTES = ("scheme", "host", "mimeType")
356
+ """`<data>` attributes Android supports in a `<queries>` intent; each may be set
357
+ once per intent."""
358
+
359
+
360
+ def normalize_android_queries(configured) -> dict:
361
+ """Validate the apps, intents, and providers an app declares it queries.
362
+
363
+ Android 11 and later hide other apps from an app unless its manifest names
364
+ them in `<queries>`. Intents follow Android's limits for `<queries>`: one
365
+ action, optional categories, and `<data>` elements that set each of
366
+ `scheme`, `host`, and `mimeType` at most once in total. Duplicate packages
367
+ and providers are dropped.
368
+
369
+ Returns:
370
+ A table with `packages`, `intents`, and `providers` lists, empty by default.
371
+
372
+ Raises:
373
+ ValueError: If a query declaration is malformed.
374
+ """
375
+ setting = "tool.flet.android.queries"
376
+
377
+ def fail(path, message):
378
+ """Report a malformed declaration using its full configuration path."""
379
+ raise ValueError(f"Invalid {path}: {message}.")
380
+
381
+ def names(key, pattern, description):
382
+ """Validate a list of names and drop duplicates, keeping their order."""
383
+ values = configured.get(key, [])
384
+ if not isinstance(values, list) or not all(
385
+ isinstance(value, str) and re.fullmatch(pattern, value.strip())
386
+ for value in values
387
+ ):
388
+ fail(f"{setting}.{key}", f"expected a list of {description}")
389
+ return list(dict.fromkeys(value.strip() for value in values))
390
+
391
+ resolved = {"packages": [], "intents": [], "providers": []}
392
+ if configured is None:
393
+ return resolved
394
+ if not isinstance(configured, dict):
395
+ fail(setting, "expected a table with packages, intent, or providers")
396
+ for key in configured:
397
+ if key not in ("packages", "intent", "providers"):
398
+ fail(
399
+ f"{setting}.{key}", "only packages, intent, and providers are supported"
400
+ )
401
+
402
+ resolved["packages"] = names(
403
+ "packages",
404
+ r"[A-Za-z][A-Za-z0-9_]*(\.[A-Za-z][A-Za-z0-9_]*)+",
405
+ "package names, such as com.example.app",
406
+ )
407
+ resolved["providers"] = names(
408
+ "providers", r"[^\s;]+(;[^\s;]+)*", "provider authorities"
409
+ )
410
+
411
+ intents = configured.get("intent", [])
412
+ if not isinstance(intents, list):
413
+ fail(f"{setting}.intent", "expected a list of intent tables")
414
+ for index, intent in enumerate(intents):
415
+ path = f"{setting}.intent[{index}]"
416
+ if not isinstance(intent, dict):
417
+ fail(path, "expected an intent table")
418
+ for key in intent:
419
+ if key not in ("action", "categories", "data"):
420
+ fail(f"{path}.{key}", "only action, categories, and data are supported")
421
+ action = intent.get("action")
422
+ if not isinstance(action, str) or not action.strip():
423
+ fail(f"{path}.action", "expected one nonempty action name")
424
+ categories = intent.get("categories", [])
425
+ if not isinstance(categories, list) or not all(
426
+ isinstance(c, str) and c.strip() for c in categories
427
+ ):
428
+ fail(f"{path}.categories", "expected a list of nonempty strings")
429
+ data = intent.get("data", [])
430
+ single = isinstance(data, dict)
431
+ if single:
432
+ data = [data]
433
+ if not isinstance(data, list):
434
+ fail(f"{path}.data", "expected a data table or a list of data tables")
435
+ normalized_data = []
436
+ used = set()
437
+ for data_index, element in enumerate(data):
438
+ data_path = f"{path}.data" if single else f"{path}.data[{data_index}]"
439
+ if not isinstance(element, dict) or not element:
440
+ fail(data_path, "expected a nonempty table of data attributes")
441
+ for key, value in element.items():
442
+ if key not in ANDROID_QUERIES_DATA_ATTRIBUTES:
443
+ fail(
444
+ f"{data_path}.{key}",
445
+ "only scheme, host, and mimeType are supported in queries",
446
+ )
447
+ if key in used:
448
+ fail(f"{data_path}.{key}", f"{key} can be set only once per intent")
449
+ if not isinstance(value, str) or not value.strip():
450
+ fail(f"{data_path}.{key}", "expected a nonempty string")
451
+ used.add(key)
452
+ normalized_data.append({k: v.strip() for k, v in element.items()})
453
+ resolved["intents"].append(
454
+ {
455
+ "action": action.strip(),
456
+ "categories": [c.strip() for c in categories],
457
+ "data": normalized_data,
458
+ }
459
+ )
460
+ return resolved
461
+
462
+
223
463
  ANDROID_RESOURCE_TYPES = {
224
464
  "anim",
225
465
  "animator",
flet_cli/version.py CHANGED
@@ -1 +1 @@
1
- version = "1.1.0.dev2"
1
+ version = "1.1.0.dev4"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flet-cli
3
- Version: 1.1.0.dev2
3
+ Version: 1.1.0.dev4
4
4
  Summary: Flet CLI
5
5
  Author-email: "Appveyor Systems Inc." <hello@flet.dev>
6
6
  License-Expression: Apache-2.0
@@ -9,8 +9,8 @@ Project-URL: Repository, https://github.com/flet-dev/flet
9
9
  Project-URL: Documentation, https://flet.dev/docs
10
10
  Requires-Python: >=3.10
11
11
  Description-Content-Type: text/markdown
12
- Requires-Dist: flet==1.1.0.dev2
13
- Requires-Dist: flet-platform-assets==1.1.0.dev2
12
+ Requires-Dist: flet==1.1.0.dev4
13
+ Requires-Dist: flet-platform-assets==1.1.0.dev4
14
14
  Requires-Dist: watchdog>=4.0.0
15
15
  Requires-Dist: packaging>=25.0
16
16
  Requires-Dist: qrcode>=7.4.2
@@ -1,8 +1,7 @@
1
1
  flet_cli/cli.py,sha256=TlUPz73bL6rcSQBBH05uAljU9f-ZsuefEKYR-SbdPbE,10115
2
- flet_cli/version.py,sha256=dDBF7DByCLLxsQMLSsO_YNMhEP_dCSWn9QCX_1B_36g,23
2
+ flet_cli/version.py,sha256=2riRADLE95mZv4R1KF4qPUxM4gH-U0yJYnOaDzNsHs4,23
3
3
  flet_cli/__pyinstaller/__init__.py,sha256=1MZKXQG20CRYCGCPzbbO3o-rUJMKm0q_ck9_jDSuTgU,177
4
4
  flet_cli/__pyinstaller/config.py,sha256=LRzpGt1QzSBWtE3zPWo2nA2Hf3ppMHv0LQnpi-dwGDk,245
5
- flet_cli/__pyinstaller/extensions.py,sha256=-HfOQmkVbOezpGFvi6bwGx0owl6DA9ji5flzIT_mUEw,5611
6
5
  flet_cli/__pyinstaller/hook-flet.py,sha256=RbiFE8-7VBsY4Dwt7a9-9gW0gUFQGjOLY1-OBsZm_mI,506
7
6
  flet_cli/__pyinstaller/hook-flet_desktop.py,sha256=_K14yzuvAzxIWUk-jBpUYiFFmPgxYuHt1EWrT7Z7s7U,106
8
7
  flet_cli/__pyinstaller/macos_utils.py,sha256=aGHqLicY6VteFb7YP9zK1CtT98CsCU8I3cXQKWwpeaA,5164
@@ -12,23 +11,23 @@ flet_cli/__pyinstaller/win_utils.py,sha256=yZixKh6Pq1ou8oNmhE_j7kuSSjN-BaQSvAhFh
12
11
  flet_cli/__pyinstaller/rthooks/pyi_rth_localhost_fletd.py,sha256=O8lAxkHmNaXaZNzP-3VTuUhuglYwgJtzaeIKQa2neGU,2379
13
12
  flet_cli/commands/base.py,sha256=6MTAuA7kKdaKIZI4AyWPM1TJfFCxmRj7kc7z2h6E_4k,3496
14
13
  flet_cli/commands/build.py,sha256=FCt95Smfyvch8xuvUmgNT7frI_3KKIbnN_YZ_iJs-sk,36725
15
- flet_cli/commands/build_base.py,sha256=FS3z2ebfAxP_CiZFoVrwX18HnunBRo-MrrWaev1Y0bk,164651
14
+ flet_cli/commands/build_base.py,sha256=grdxa1za8LzobTO7kd6AJSwsZ79KDgp216lihC-FfYM,177179
16
15
  flet_cli/commands/clean.py,sha256=fIRr1ktoE9wzO0R-lAq985zbCH1dX6Sao5VyXiJxiOY,2250
17
16
  flet_cli/commands/create.py,sha256=i0-DEGlE4mOpP1lGxfuv7Iea131ukdNP5SQupcS8Eug,11317
18
17
  flet_cli/commands/debug.py,sha256=pZH4Lsn9nLET4Zet9XwJweCA8rQyt2fIF-srH5XO7JM,6699
19
18
  flet_cli/commands/devices.py,sha256=mYUOk93EnpS9FvZnTUjCL58P0jHA6FD8HoudFGqF1go,7777
20
19
  flet_cli/commands/doctor.py,sha256=uG2xUAT_FASB9cnLD9G83NTYdP9iuKhaHyQLjMB_E4c,1051
21
20
  flet_cli/commands/emulators.py,sha256=IVMCRCI-nXfD51H_ApV8GZhpmpDrhC8s61uaXPGVarI,13039
22
- flet_cli/commands/flutter_base.py,sha256=hKIx8grGOls_685ik-Vg_XPKkOQGltbYQw0IMQ6TgNA,26456
21
+ flet_cli/commands/flutter_base.py,sha256=18H3ofgsnSeCfaZZwPemYLNEtPLr_v46QlP_bVPUQG8,26500
23
22
  flet_cli/commands/mcp.py,sha256=AVEnf6YjICqoBQPKqBaHp27KHXxFVjH-IRpAi6dSjcM,2065
24
23
  flet_cli/commands/options.py,sha256=CD7Fw2CtUeuVrtM_oR1_OrAcMKF2EhRUoPuX9_3IsW8,2543
25
- flet_cli/commands/pack.py,sha256=Zlha-j10JJ1tMKY5VrZHZBAEJsIPQS8-huMoqMkPkkY,30387
24
+ flet_cli/commands/pack.py,sha256=nM06iFNwG4nAGXzOM8w0NCfvpNIg7TQdVxQv537Gbko,30377
26
25
  flet_cli/commands/publish.py,sha256=Ra92AZ3NbBMFAnbJxBafaXvmF-3T2tXGO5V6MiHDYp8,14581
27
- flet_cli/commands/run.py,sha256=oQasecCot958_3hLdeHjXRlnRIMudKa1VFQCZLvk2rk,28436
26
+ flet_cli/commands/run.py,sha256=W96y_bUCOh2TK2w9tfWzbYU5ahS_CBE-vzLVkoNTU4M,29663
28
27
  flet_cli/commands/serve.py,sha256=YrollC80u9JvuXHbI_qQ3wxpjcqpIQwFxdD5nIOeOT4,3143
29
28
  flet_cli/commands/test.py,sha256=lY4EqTyxG7jaE0lt0nCepimHBiPB0OnSY8zIUQxluQA,12875
30
29
  flet_cli/commands/test_host.py,sha256=GrRLpGJf4feJsQydKZaqGX8aY1aPXPEPWCsMqEEgA2k,394
31
- flet_cli/utils/android.py,sha256=tRE7J90fqpn17_lSGHCK-r4kUyYuu3MBA15-bUWh2LU,13740
30
+ flet_cli/utils/android.py,sha256=MTs2FkJ_c-Yog5piQDBI-saxsuC9Zzi07969gVe2pUk,23389
32
31
  flet_cli/utils/android_sdk.py,sha256=8jRccd0PArpovoNVqiAyp4me_AvQLUb8lmrSQjE0Xfc,14047
33
32
  flet_cli/utils/app_excludes.py,sha256=A_QgScerUDKrBSXA4PL1_P9IPNjqRkBik2Y0uJ_W0UQ,3890
34
33
  flet_cli/utils/cli.py,sha256=wPtVyfrwOdJ35acr4nVpNiS2p4SQmFD_hDsgYBBzZng,1524
@@ -50,8 +49,8 @@ flet_cli/utils/pyodide.py,sha256=RhumXYuovPxgLbu99pNNhVb9SRvBvhLGiUMtb9WxC5U,505
50
49
  flet_cli/utils/pyproject_toml.py,sha256=o4fAWKXMyK8vdnAO41BLI7Lt3ohMlVdlwrpaifq30Cs,1408
51
50
  flet_cli/utils/python_versions.py,sha256=eYfblWYTD2_PiiAK43euVVg1NaaxsIh_6H8J7CcnbcM,8129
52
51
  flet_cli/utils/template_cache.py,sha256=Lf_iuk30zTfaNFbRmrc8s07w1yE-PYjdovZztoiuPzc,1596
53
- flet_cli-1.1.0.dev2.dist-info/METADATA,sha256=4uRUm4j_gjDHkbS-Z8b8T16t5pxcJTS8cmMPkSDo9uU,1588
54
- flet_cli-1.1.0.dev2.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
55
- flet_cli-1.1.0.dev2.dist-info/entry_points.txt,sha256=UZFR426y3mfr0wgikEFPbZ6wtGwfgykif9Obw6R7Wnc,65
56
- flet_cli-1.1.0.dev2.dist-info/top_level.txt,sha256=4_BPVAJpcNofDe3XMxajlZLBNWzWqKhRynNSBCYTKVQ,9
57
- flet_cli-1.1.0.dev2.dist-info/RECORD,,
52
+ flet_cli-1.1.0.dev4.dist-info/METADATA,sha256=5y8Qcgd3MeBDaYaulrn606g9a80EjIyLeLjspK3ePoQ,1588
53
+ flet_cli-1.1.0.dev4.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
54
+ flet_cli-1.1.0.dev4.dist-info/entry_points.txt,sha256=UZFR426y3mfr0wgikEFPbZ6wtGwfgykif9Obw6R7Wnc,65
55
+ flet_cli-1.1.0.dev4.dist-info/top_level.txt,sha256=4_BPVAJpcNofDe3XMxajlZLBNWzWqKhRynNSBCYTKVQ,9
56
+ flet_cli-1.1.0.dev4.dist-info/RECORD,,
@@ -1,177 +0,0 @@
1
- import ast
2
- import importlib.metadata
3
- import re
4
- import sys
5
- from dataclasses import dataclass
6
- from pathlib import Path
7
- from typing import Optional
8
-
9
- _PACKAGE_URI = re.compile(rb"package:([a-z][a-z0-9_]*)/")
10
-
11
- # Directories that hold no app code, skipped when looking for the app's imports.
12
- _SKIPPED_DIRS = {"__pycache__", "build", "dist", "node_modules", "site-packages"}
13
-
14
-
15
- @dataclass
16
- class InstalledExtension:
17
- """
18
- A Flet extension installed in the current environment.
19
- """
20
-
21
- package: str
22
- """
23
- Name of the extension's Flutter package.
24
- """
25
-
26
- distribution: Optional[str]
27
- """
28
- Name of the distribution that installed it, if known.
29
- """
30
-
31
- modules: set[str]
32
- """
33
- Top-level Python modules the extension provides.
34
- """
35
-
36
-
37
- def get_client_extensions(snapshot_path: str) -> Optional[set[str]]:
38
- """
39
- Return the Flutter packages compiled into a prebuilt Flet client.
40
-
41
- Release builds keep the `package:<name>/` URI of every Dart library in the
42
- app's AOT snapshot: `data/app.so` on Windows, `lib/libapp.so` on Linux and
43
- `Contents/Frameworks/App.framework/App` in a macOS app bundle.
44
-
45
- Args:
46
- snapshot_path: Path to the client's AOT snapshot.
47
-
48
- Returns:
49
- Names of the packages, or `None` when the snapshot is missing or names no
50
- `flet` library, so the client's extensions can't be told.
51
- """
52
-
53
- path = Path(snapshot_path)
54
- if not path.is_file():
55
- return None
56
- packages = {m.decode() for m in _PACKAGE_URI.findall(path.read_bytes())}
57
- return packages if "flet" in packages else None
58
-
59
-
60
- def find_installed_extensions() -> list[InstalledExtension]:
61
- """
62
- Return the Flet extensions installed in the current environment.
63
-
64
- An extension is a distribution that installs a `flutter/<package>/pubspec.yaml`
65
- file. Editable installs list no such file in their `RECORD`, so a
66
- `flutter/<package>` folder on `sys.path` that no distribution owns is reported
67
- too when the same `sys.path` entry has a Python module named `<package>`.
68
- """
69
-
70
- extensions: dict[str, InstalledExtension] = {}
71
- for dist in importlib.metadata.distributions():
72
- files = dist.files or []
73
- packages = {
74
- f.parts[1]
75
- for f in files
76
- if len(f.parts) == 3
77
- and f.parts[0] == "flutter"
78
- and f.parts[2] == "pubspec.yaml"
79
- }
80
- if not packages:
81
- continue
82
- modules = {
83
- Path(f.parts[0]).stem
84
- for f in files
85
- if f.parts[0] not in ("flutter", "..", "__pycache__")
86
- and not f.parts[0].endswith((".dist-info", ".data", ".pth"))
87
- and (len(f.parts) > 1 or f.suffix == ".py")
88
- }
89
- for package in packages:
90
- extensions.setdefault(
91
- package,
92
- InstalledExtension(package, dist.metadata["Name"], modules),
93
- )
94
-
95
- for entry in sys.path:
96
- entry_dir = Path(entry or ".")
97
- if not (entry_dir / "flutter").is_dir():
98
- continue
99
- for pubspec in sorted((entry_dir / "flutter").glob("*/pubspec.yaml")):
100
- package = pubspec.parent.name
101
- if (entry_dir / package).is_dir() or (
102
- entry_dir / f"{package}.py"
103
- ).is_file():
104
- extensions.setdefault(
105
- package, InstalledExtension(package, None, {package})
106
- )
107
-
108
- return sorted(extensions.values(), key=lambda e: e.package)
109
-
110
-
111
- def find_imported_modules(app_dir: Path) -> set[str]:
112
- """
113
- Return the top-level modules the app's Python files import.
114
-
115
- Virtual environments, hidden folders, build output and symlinked folders in
116
- `app_dir` are skipped, as are files that can't be read or don't parse.
117
-
118
- Args:
119
- app_dir: Directory of the app's main script.
120
- """
121
-
122
- modules: set[str] = set()
123
- for path in _iter_app_files(app_dir):
124
- try:
125
- tree = ast.parse(path.read_bytes(), filename=str(path))
126
- except (OSError, SyntaxError, ValueError):
127
- continue
128
- for node in ast.walk(tree):
129
- if isinstance(node, ast.Import):
130
- modules.update(alias.name.split(".")[0] for alias in node.names)
131
- elif isinstance(node, ast.ImportFrom) and node.module and not node.level:
132
- modules.add(node.module.split(".")[0])
133
- return modules
134
-
135
-
136
- def find_missing_extensions(
137
- app_dir: Path, client_extensions: set[str]
138
- ) -> list[InstalledExtension]:
139
- """
140
- Return the installed extensions the app imports but the client lacks.
141
-
142
- Args:
143
- app_dir: Directory of the app's main script.
144
- client_extensions: Flutter packages compiled into the client, as
145
- returned by `get_client_extensions()`.
146
- """
147
-
148
- candidates = [
149
- e for e in find_installed_extensions() if e.package not in client_extensions
150
- ]
151
- if not candidates:
152
- return []
153
- imported = find_imported_modules(app_dir)
154
- return [e for e in candidates if e.modules & imported]
155
-
156
-
157
- def _iter_app_files(directory: Path):
158
- """
159
- Yield the Python files of an app folder, recursively.
160
- """
161
-
162
- try:
163
- paths = sorted(directory.iterdir())
164
- except OSError:
165
- return
166
- for path in paths:
167
- if path.is_dir():
168
- if (
169
- path.is_symlink()
170
- or path.name.startswith(".")
171
- or path.name in _SKIPPED_DIRS
172
- or (path / "pyvenv.cfg").exists()
173
- ):
174
- continue
175
- yield from _iter_app_files(path)
176
- elif path.suffix == ".py":
177
- yield path