fastled 1.2.74__py3-none-any.whl → 1.2.76__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.
fastled/__init__.py CHANGED
@@ -13,7 +13,7 @@ from .types import BuildMode, CompileResult, CompileServerError
13
13
  # IMPORTANT! There's a bug in github which will REJECT any version update
14
14
  # that has any other change in the repo. Please bump the version as the
15
15
  # ONLY change in a commit, or else the pypi update and the release will fail.
16
- __version__ = "1.2.74"
16
+ __version__ = "1.2.76"
17
17
 
18
18
  DOCKER_FILE = (
19
19
  "https://raw.githubusercontent.com/zackees/fastled-wasm/refs/heads/main/Dockerfile"
fastled/docker_manager.py CHANGED
@@ -25,6 +25,7 @@ from docker.models.containers import Container
25
25
  from docker.models.images import Image
26
26
  from filelock import FileLock
27
27
 
28
+ from fastled.print_filter import PrintFilter, PrintFilterFastled
28
29
  from fastled.spinner import Spinner
29
30
 
30
31
  CONFIG_DIR = Path(user_data_dir("fastled", "fastled"))
@@ -99,25 +100,10 @@ class Volume:
99
100
  return volumes
100
101
 
101
102
 
102
- class PrintFilter:
103
- """Provides filtering for text output so that source files match up with local names."""
104
-
105
- def __init__(self) -> None:
106
- pass
107
-
108
- def _remove_ino_cpp(self, text: str) -> str:
109
- return text.replace(".ino.cpp", ".ino")
110
-
111
- def _filter_all(self, text: str) -> str:
112
- text = self._remove_ino_cpp(text)
113
- return text
114
-
115
- def print(self, text: str | bytes) -> None:
116
- """Prints the text to the console."""
117
- if isinstance(text, bytes):
118
- text = text.decode("utf-8")
119
- text = self._filter_all(text)
120
- print(text, end="")
103
+ # Override the default PrintFilter to use a custom one.
104
+ def make_default_print_filter() -> PrintFilter:
105
+ """Create a default PrintFilter instance."""
106
+ return PrintFilterFastled()
121
107
 
122
108
 
123
109
  class RunningContainer:
@@ -127,7 +113,7 @@ class RunningContainer:
127
113
  first_run: bool = False,
128
114
  filter: PrintFilter | None = None,
129
115
  ) -> None:
130
- self.filter = filter or PrintFilter()
116
+ self.filter = filter or make_default_print_filter()
131
117
  self.container = container
132
118
  self.first_run = first_run
133
119
  self.running = True
fastled/parse_args.py CHANGED
@@ -24,10 +24,37 @@ def _find_fastled_repo(start: Path) -> Path | None:
24
24
  return None
25
25
 
26
26
 
27
+ _DEFAULT_HELP_TEXT = """
28
+ FastLED WASM Compiler - Useful options:
29
+ <directory> Directory containing the FastLED sketch to compile
30
+ --init [example] Initialize one of the top tier WASM examples
31
+ --web [url] Use web compiler
32
+ --server Run the compiler server
33
+ --debug Build with debug symbols for dev-tools debugging
34
+ --quick Build in quick mode (default)
35
+ --release Build in optimized release mode
36
+ --profile Enable profiling the C++ build system
37
+ --update Update the docker image for the wasm compiler
38
+ --purge Remove all FastLED containers and images
39
+ --version Show version information
40
+ --help Show detailed help
41
+ Examples:
42
+ fastled (will auto detect the sketch directory and prompt you)
43
+ fastled my_sketch
44
+ fastled my_sketch --web (compiles using the web compiler only)
45
+ fastled --init Blink (initializes a new sketch directory with the Blink example)
46
+ fastled --server (runs the compiler server in the current directory)
47
+ """
48
+
49
+
27
50
  def parse_args() -> Args:
28
51
  """Parse command-line arguments."""
29
52
  from fastled import __version__
30
53
 
54
+ # Check if no arguments were provided
55
+ if len(sys.argv) == 1:
56
+ print(_DEFAULT_HELP_TEXT)
57
+
31
58
  parser = argparse.ArgumentParser(description=f"FastLED WASM Compiler {__version__}")
32
59
  parser.add_argument("--version", action="version", version=f"{__version__}")
33
60
  parser.add_argument(
@@ -66,7 +93,7 @@ def parse_args() -> Args:
66
93
  parser.add_argument(
67
94
  "--profile",
68
95
  action="store_true",
69
- help="Enable profiling for web compilation",
96
+ help="Enable profiling of the C++ build system used for wasm compilation.",
70
97
  )
71
98
  parser.add_argument(
72
99
  "--force-compile",
@@ -79,6 +106,7 @@ def parse_args() -> Args:
79
106
  help="Disable automatic updates of the wasm compiler image when using docker.",
80
107
  )
81
108
  parser.add_argument(
109
+ "-u",
82
110
  "--update",
83
111
  "--upgrade",
84
112
  action="store_true",
@@ -89,7 +117,7 @@ def parse_args() -> Args:
89
117
  "--local",
90
118
  "-l",
91
119
  action="store_true",
92
- help="Use localhost for web compilation from an instance of fastled --server, creating it if necessary",
120
+ help="(Default): Use localhost for web compilation from an instance of fastled --server, creating it if necessary",
93
121
  )
94
122
  parser.add_argument(
95
123
  "--build",
@@ -0,0 +1,68 @@
1
+ import re
2
+ from abc import ABC, abstractmethod
3
+
4
+
5
+ class PrintFilter(ABC):
6
+ """Abstract base class for filtering text output."""
7
+
8
+ def __init__(self, echo: bool = True) -> None:
9
+ self.echo = echo
10
+
11
+ @abstractmethod
12
+ def filter(self, text: str) -> str:
13
+ """Filter the text according to implementation-specific rules."""
14
+ pass
15
+
16
+ def print(self, text: str | bytes) -> str:
17
+ """Prints the text to the console after filtering."""
18
+ if isinstance(text, bytes):
19
+ text = text.decode("utf-8")
20
+ text = self.filter(text)
21
+ if self.echo:
22
+ print(text, end="")
23
+ return text
24
+
25
+
26
+ def _handle_ino_cpp(line: str) -> str:
27
+ if ".ino.cpp" in line[0:30]:
28
+ # Extract the filename without path and extension
29
+ match = re.search(r"src/([^/]+)\.ino\.cpp", line)
30
+ if match:
31
+ filename = match.group(1)
32
+ # Replace with examples/Filename/Filename.ino format
33
+ line = line.replace(
34
+ f"src/{filename}.ino.cpp", f"examples/{filename}/{filename}.ino"
35
+ )
36
+ else:
37
+ # Fall back to simple extension replacement if regex doesn't match
38
+ line = line.replace(".ino.cpp", ".ino")
39
+ return line
40
+
41
+
42
+ class PrintFilterDefault(PrintFilter):
43
+ """Provides default filtering for FastLED output."""
44
+
45
+ def filter(self, text: str) -> str:
46
+ return text
47
+
48
+
49
+ class PrintFilterFastled(PrintFilter):
50
+ """Provides filtering for FastLED output so that source files match up with local names."""
51
+
52
+ def __init__(self, echo: bool = True) -> None:
53
+ super().__init__(echo)
54
+ self.build_started = False
55
+
56
+ def filter(self, text: str) -> str:
57
+ lines = text.splitlines()
58
+ out: list[str] = []
59
+ for line in lines:
60
+ ## DEBUG DO NOT SUBMIT
61
+ # print(line)
62
+ if "# WASM is building" in line:
63
+ self.build_started = True
64
+ if self.build_started or " error: " in line:
65
+ line = _handle_ino_cpp(line)
66
+ out.append(line)
67
+ text = "\n".join(out)
68
+ return text
@@ -20,7 +20,9 @@ def select_sketch_directory(
20
20
  print("\nMultiple Directories found, choose one:")
21
21
  for i, sketch_dir in enumerate(sketch_directories):
22
22
  print(f" [{i+1}]: {sketch_dir}")
23
- which = input("\nPlease specify a sketch directory: ").strip()
23
+ which = input(
24
+ "\nPlease specify a sketch directory\nYou can enter a number or type a fuzzy search: "
25
+ ).strip()
24
26
  try:
25
27
  index = int(which) - 1
26
28
  return str(sketch_directories[index])
fastled/types.py CHANGED
@@ -4,6 +4,8 @@ from enum import Enum
4
4
  from pathlib import Path
5
5
  from typing import Any
6
6
 
7
+ from fastled.print_filter import PrintFilterFastled
8
+
7
9
 
8
10
  @dataclass
9
11
  class Args:
@@ -102,6 +104,11 @@ class CompileResult:
102
104
  def to_dict(self) -> dict[str, Any]:
103
105
  return self.__dict__.copy()
104
106
 
107
+ def __post_init__(self):
108
+ # Filter the stdout.
109
+ pf = PrintFilterFastled(echo=False)
110
+ self.stdout = pf.print(self.stdout)
111
+
105
112
 
106
113
  class CompileServerError(Exception):
107
114
  """Error class for failing to instantiate CompileServer."""
fastled/web_compile.py CHANGED
@@ -4,6 +4,7 @@ import json
4
4
  import os
5
5
  import shutil
6
6
  import tempfile
7
+ import time
7
8
  import zipfile
8
9
  from concurrent.futures import Future, ThreadPoolExecutor, as_completed
9
10
  from dataclasses import dataclass
@@ -154,6 +155,37 @@ def find_good_connection(
154
155
  return None
155
156
 
156
157
 
158
+ def _banner(msg: str) -> str:
159
+ """
160
+ Create a banner for the given message.
161
+ Example:
162
+ msg = "Hello, World!"
163
+ print -> "#################"
164
+ "# Hello, World! #"
165
+ "#################"
166
+ """
167
+ lines = msg.split("\n")
168
+ # Find the width of the widest line
169
+ max_width = max(len(line) for line in lines)
170
+ width = max_width + 4 # Add 4 for "# " and " #"
171
+
172
+ # Create the top border
173
+ banner = "\n" + "#" * width + "\n"
174
+
175
+ # Add each line with proper padding
176
+ for line in lines:
177
+ padding = max_width - len(line)
178
+ banner += f"# {line}{' ' * padding} #\n"
179
+
180
+ # Add the bottom border
181
+ banner += "#" * width + "\n"
182
+ return banner
183
+
184
+
185
+ def _print_banner(msg: str) -> None:
186
+ print(_banner(msg))
187
+
188
+
157
189
  def web_compile(
158
190
  directory: Path | str,
159
191
  host: str | None = None,
@@ -161,11 +193,12 @@ def web_compile(
161
193
  build_mode: BuildMode | None = None,
162
194
  profile: bool = False,
163
195
  ) -> CompileResult:
196
+ start_time = time.time()
164
197
  if isinstance(directory, str):
165
198
  directory = Path(directory)
166
199
  host = _sanitize_host(host or DEFAULT_HOST)
167
200
  build_mode = build_mode or BuildMode.QUICK
168
- print("Compiling on", host)
201
+ _print_banner(f"Compiling on {host}")
169
202
  auth_token = auth_token or _AUTH_TOKEN
170
203
  if not directory.exists():
171
204
  raise FileNotFoundError(f"Directory not found: {directory}")
@@ -186,7 +219,7 @@ def web_compile(
186
219
 
187
220
  connection_result = find_good_connection(urls)
188
221
  if connection_result is None:
189
- print("Connection failed to all endpoints")
222
+ _print_banner("Connection failed to all endpoints")
190
223
  return CompileResult(
191
224
  success=False,
192
225
  stdout="Connection failed",
@@ -270,6 +303,9 @@ def web_compile(
270
303
  relative_path = file_path.relative_to(extract_path)
271
304
  out_zip.write(file_path, relative_path)
272
305
 
306
+ diff_time = time.time() - start_time
307
+ msg = f"Compilation success, took {diff_time:.2f} seconds"
308
+ _print_banner(msg)
273
309
  return CompileResult(
274
310
  success=True,
275
311
  stdout=stdout,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastled
3
- Version: 1.2.74
3
+ Version: 1.2.76
4
4
  Summary: FastLED Wasm Compiler
5
5
  Home-page: https://github.com/zackees/fastled-wasm
6
6
  Maintainer: Zachary Vorhies
@@ -1,21 +1,22 @@
1
- fastled/__init__.py,sha256=iGQXCTJFerVAry3RqgCchfgZJ6cuL2Zu5BOsAiydjLY,6770
1
+ fastled/__init__.py,sha256=qOnSt1eqFW7UnWuHYVomp-m5U5G7PE5bcC0NTFZ4Mr4,6770
2
2
  fastled/app.py,sha256=vteMH0WvWGkQq-FR6SdAzqJcHqx0Gcj-aclXYZL7n5Q,4073
3
3
  fastled/cli.py,sha256=FjVr31ht0UPlAcmX-84NwfAGMQHTkrCe4o744jCAxiw,375
4
4
  fastled/cli_test.py,sha256=qJB9yLRFR3OwOwdIWSQ0fQsWLnA37v5pDccufiP_hTs,512
5
5
  fastled/client_server.py,sha256=eG82h-27Y40szCew976lv9I6bP-YxtRV6sFNDVNTapo,14525
6
6
  fastled/compile_server.py,sha256=rkXvrvdav5vDG8lv_OlBX3YSCHtnHMt25nXbfeg_r78,2960
7
7
  fastled/compile_server_impl.py,sha256=LnvxeSgBQ3lvey3_dz71UnJjCb5WTUQaPYtuSc1BMvo,10706
8
- fastled/docker_manager.py,sha256=TtIeu7osBuIBW9CcuDvv3KjFaLIu5lWWtd94fXkLJXc,35493
8
+ fastled/docker_manager.py,sha256=SC_qV6grNTGh0QD1ubKrULQblrN-2PORocISlaZg9NQ,35156
9
9
  fastled/filewatcher.py,sha256=3qS3L7zMQhFuVrkeGn1djsB_cB6x_E2YGJmmQWVAU_w,10033
10
10
  fastled/interactive_srcs.py,sha256=F5nHdJc60xsnmOtnKhngE9JytqGn56PmYw_MVSIX1ac,138
11
11
  fastled/keyboard.py,sha256=UTAsqCn1UMYnB8YDzENiLTj4GeL45tYfEcO7_5fLFEg,3556
12
12
  fastled/keyz.py,sha256=LO-8m_7CpNDiZLM-FXhQ30f9gN1bUYz5lOsUPTIbI-c,4020
13
13
  fastled/live_client.py,sha256=MDauol0mxtXggV1Pv9ahC0Jjg_4wnnV6FjGEtdd9cxU,2763
14
14
  fastled/open_browser.py,sha256=Fv1w645rrVROaW4jjyU70Cfz6QPbyIqjK5yu16lhBlo,3836
15
- fastled/parse_args.py,sha256=4BWlPaRAGnRYGyywnhhPciPOlNEXflOlycSyrdDX8lU,8056
15
+ fastled/parse_args.py,sha256=lF63joIP2rN706n1rbxmBhWyogN91zjocyFtTVHOnds,9306
16
16
  fastled/paths.py,sha256=VsPmgu0lNSCFOoEC0BsTYzDygXqy15AHUfN-tTuzDZA,99
17
+ fastled/print_filter.py,sha256=nepkG6UpBg3PX_fnN5It7uKbhppqAC_hYuh06RqJsUM,2120
17
18
  fastled/project_init.py,sha256=bBt4DwmW5hZkm9ICt9Qk-0Nr_0JQM7icCgH5Iv-bCQs,3984
18
- fastled/select_sketch_directory.py,sha256=TZdCjl1D7YMKjodMTvDRurPcpAmN3x0TcJxffER2NfM,1314
19
+ fastled/select_sketch_directory.py,sha256=-eudwCns3AKj4HuHtSkZAFwbnf005SNL07pOzs9VxnE,1383
19
20
  fastled/server_fastapi.py,sha256=ytsL4poO-yugDIhvYJq6nCNdLZ4fQJ1AFqXkF-uEkqo,1488
20
21
  fastled/server_fastapi_cli.py,sha256=fJGLvbJx5ertsZER_lgg0GfkYTX-V2rxzbNO1lEapU0,1392
21
22
  fastled/server_flask.py,sha256=i0OtDdrjiF9hjKNnI2ebf6Ag-mxMmtUCxnuHMBOzx7I,4665
@@ -24,9 +25,9 @@ fastled/settings.py,sha256=URgM6ZPlQYF-0ZTEhQCX8isLR6CbmYGwhDX4uXbh-ZI,468
24
25
  fastled/sketch.py,sha256=tHckjDj8P6BI_LWzUFM071a9qcqPs-r-qFWIe50P5Xw,3391
25
26
  fastled/spinner.py,sha256=VHxmvB92P0Z_zYxRajb5HiNmkHHvZ5dG7hKtZltzpcs,867
26
27
  fastled/string_diff.py,sha256=NbtYxvBFxTUdmTpMLizlgZj2ULJ-7etj72GBdWDTGws,2496
27
- fastled/types.py,sha256=ZFqHxYIGSeQb9FiImA5KDXZLhmmVSjOrIQDduwxmCZw,4494
28
+ fastled/types.py,sha256=mNchhIW5m6hBBv63OYE0V_u5yGnS505eWjw7HCazb_s,4694
28
29
  fastled/util.py,sha256=17f2A52TfBErJOEGC_Vs72t1mTDocLVTfnR9hWbXW8A,501
29
- fastled/web_compile.py,sha256=H2Tm5kMBaRjqdHqxv7L3-xSeYNHi0k0P-XM0Cn9esOo,10360
30
+ fastled/web_compile.py,sha256=QTYHtcm55zsFxPhdA-qSPfL5Q4lhL3h3oNmir3m-Y3s,11345
30
31
  fastled/assets/example.txt,sha256=lTBovRjiz0_TgtAtbA1C5hNi2ffbqnNPqkKg6UiKCT8,54
31
32
  fastled/assets/localhost-key.pem,sha256=Q-CNO_UoOd8fFNN4ljcnqwUeCMhzTplRjLO2x0pYRlU,1704
32
33
  fastled/assets/localhost.pem,sha256=QTwUtTwjYWbm9m3pHW2IlK2nFZJ8b0pppxPjhgVZqQo,1619
@@ -34,9 +35,9 @@ fastled/site/build.py,sha256=2YKU_UWKlJdGnjdbAbaL0co6kceFMSTVYwH1KCmgPZA,13987
34
35
  fastled/site/examples.py,sha256=s6vj2zJc6BfKlnbwXr1QWY1mzuDBMt6j5MEBOWjO_U8,155
35
36
  fastled/test/can_run_local_docker_tests.py,sha256=LEuUbHctRhNNFWcvnz2kEGmjDJeXO4c3kNpizm3yVJs,400
36
37
  fastled/test/examples.py,sha256=GfaHeY1E8izBl6ZqDVjz--RHLyVR4NRnQ5pBesCFJFY,1673
37
- fastled-1.2.74.dist-info/licenses/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
38
- fastled-1.2.74.dist-info/METADATA,sha256=h4zIphh1RYBmcjFT2jcHR1UuP9jWYZ3knSEJk0XcBe0,22065
39
- fastled-1.2.74.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
40
- fastled-1.2.74.dist-info/entry_points.txt,sha256=RCwmzCSOS4-C2i9EziANq7Z2Zb4KFnEMR1FQC0bBwAw,101
41
- fastled-1.2.74.dist-info/top_level.txt,sha256=Bbv5kpJpZhWNCvDF4K0VcvtBSDMa8B7PTOrZa9CezHY,8
42
- fastled-1.2.74.dist-info/RECORD,,
38
+ fastled-1.2.76.dist-info/licenses/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
39
+ fastled-1.2.76.dist-info/METADATA,sha256=8C3qs-NQs8qb76ss0g-GC2bXqsNWPagZ-6w_un4v_r8,22065
40
+ fastled-1.2.76.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
41
+ fastled-1.2.76.dist-info/entry_points.txt,sha256=RCwmzCSOS4-C2i9EziANq7Z2Zb4KFnEMR1FQC0bBwAw,101
42
+ fastled-1.2.76.dist-info/top_level.txt,sha256=Bbv5kpJpZhWNCvDF4K0VcvtBSDMa8B7PTOrZa9CezHY,8
43
+ fastled-1.2.76.dist-info/RECORD,,