fastled 1.2.76__py3-none-any.whl → 1.2.78__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
@@ -7,17 +7,14 @@ from typing import Generator
7
7
 
8
8
  from .compile_server import CompileServer
9
9
  from .live_client import LiveClient
10
+ from .settings import DOCKER_FILE, IMAGE_NAME
10
11
  from .site.build import build
11
12
  from .types import BuildMode, CompileResult, CompileServerError
12
13
 
13
14
  # IMPORTANT! There's a bug in github which will REJECT any version update
14
15
  # that has any other change in the repo. Please bump the version as the
15
16
  # ONLY change in a commit, or else the pypi update and the release will fail.
16
- __version__ = "1.2.76"
17
-
18
- DOCKER_FILE = (
19
- "https://raw.githubusercontent.com/zackees/fastled-wasm/refs/heads/main/Dockerfile"
20
- )
17
+ __version__ = "1.2.78"
21
18
 
22
19
 
23
20
  class Api:
@@ -154,7 +151,6 @@ class Docker:
154
151
  @staticmethod
155
152
  def purge() -> None:
156
153
  from fastled.docker_manager import DockerManager
157
- from fastled.settings import IMAGE_NAME
158
154
 
159
155
  docker_mgr = DockerManager()
160
156
  docker_mgr.purge(image_name=IMAGE_NAME)
@@ -217,4 +213,5 @@ __all__ = [
217
213
  "CompileResult",
218
214
  "CompileServerError",
219
215
  "BuildMode",
216
+ "DOCKER_FILE",
220
217
  ]
fastled/app.py CHANGED
@@ -68,19 +68,37 @@ def main() -> int:
68
68
  print("Building is disabled")
69
69
  build = False
70
70
 
71
- if build:
72
- raise NotImplementedError("Building is not yet supported.")
71
+ if interactive:
72
+ # raise NotImplementedError("Building is not yet supported.")
73
73
  file_watcher_set(False)
74
- project_root = Path(".").absolute()
75
- print(f"Building Docker image at {project_root}")
76
- from fastled import Api, Docker
77
-
78
- server = Docker.spawn_server_from_fastled_repo(
79
- project_root=project_root,
74
+ # project_root = Path(".").absolute()
75
+ # print(f"Building Docker image at {project_root}")
76
+ from fastled import Api
77
+
78
+ # server = Docker.spawn_server_from_fastled_repo(
79
+ # project_root=project_root,
80
+ # interactive=interactive,
81
+ # sketch_folder=directory,
82
+ # )
83
+ # assert isinstance(server, CompileServer)
84
+ server: CompileServer = CompileServer(
80
85
  interactive=interactive,
81
- sketch_folder=directory,
86
+ auto_updates=False,
87
+ mapped_dir=directory,
88
+ auto_start=False,
89
+ remove_previous=False,
82
90
  )
83
- assert isinstance(server, CompileServer)
91
+
92
+ server.start(wait_for_startup=False)
93
+
94
+ try:
95
+ while server.process_running():
96
+ # wait for ctrl-c
97
+ time.sleep(0.1)
98
+ except KeyboardInterrupt:
99
+ print("\nExiting from server...")
100
+ server.stop()
101
+ return 0
84
102
 
85
103
  try:
86
104
  if interactive:
@@ -0,0 +1,21 @@
1
+ import sys
2
+
3
+ from fastled.app import main as app_main
4
+
5
+ if __name__ == "__main__":
6
+ # Note that the entry point for the exe is in cli.py
7
+ try:
8
+ import os
9
+
10
+ os.chdir("../fastled")
11
+ # sys.argv.append("--server")
12
+ # sys.argv.append("--local")
13
+ sys.argv.append("examples/FxWave2d")
14
+ sys.argv.append("-i")
15
+ sys.exit(app_main())
16
+ except KeyboardInterrupt:
17
+ print("\nExiting from main...")
18
+ sys.exit(1)
19
+ except Exception as e:
20
+ print(f"Error: {e}")
21
+ sys.exit(1)
fastled/client_server.py CHANGED
@@ -381,12 +381,12 @@ def run_client_server(args: Args) -> int:
381
381
  url, compile_server = _try_start_server_or_get_url(auto_update, web, localhost)
382
382
  except KeyboardInterrupt:
383
383
  print("\nExiting from first try...")
384
- if compile_server:
384
+ if compile_server is not None:
385
385
  compile_server.stop()
386
386
  return 1
387
387
  except Exception as e:
388
388
  print(f"Error: {e}")
389
- if compile_server:
389
+ if compile_server is not None:
390
390
  compile_server.stop()
391
391
  return 1
392
392
 
@@ -15,7 +15,6 @@ from fastled.docker_manager import (
15
15
  RunningContainer,
16
16
  Volume,
17
17
  )
18
- from fastled.interactive_srcs import INTERACTIVE_SOURCES
19
18
  from fastled.settings import DEFAULT_CONTAINER_NAME, IMAGE_NAME, SERVER_PORT
20
19
  from fastled.sketch import looks_like_fastled_repo
21
20
  from fastled.types import BuildMode, CompileResult, CompileServerError
@@ -37,6 +36,32 @@ def _try_get_fastled_src(path: Path) -> Path | None:
37
36
  return None
38
37
 
39
38
 
39
+ def _port_is_free(port: int) -> bool:
40
+ """Check if a port is free."""
41
+ import socket
42
+
43
+ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
44
+ try:
45
+ _ = sock.bind(("localhost", port)) and sock.bind(("0.0.0.0", port))
46
+ return True
47
+ except OSError:
48
+ return False
49
+
50
+
51
+ def _find_free_port() -> int:
52
+ """Find a free port on the system."""
53
+
54
+ start_port = 49152
55
+ tries = 10
56
+
57
+ for port in range(start_port, start_port + tries):
58
+ if _port_is_free(port):
59
+ return port
60
+ raise RuntimeError(
61
+ f"No free port found in the range {start_port}-{start_port + tries - 1}"
62
+ )
63
+
64
+
40
65
  class CompileServerImpl:
41
66
  def __init__(
42
67
  self,
@@ -202,6 +227,7 @@ class CompileServerImpl:
202
227
  image_name=IMAGE_NAME, tag="latest", upgrade=upgrade
203
228
  )
204
229
  DISK_CACHE.put("last-update", now_str)
230
+ CLIENT_PORT = 80 # TODO: Don't use port 80.
205
231
 
206
232
  print("Docker image now validated")
207
233
  port = SERVER_PORT
@@ -209,7 +235,11 @@ class CompileServerImpl:
209
235
  server_command = ["/bin/bash"]
210
236
  else:
211
237
  server_command = ["python", "/js/run.py", "server"] + SERVER_OPTIONS
212
- ports = {80: port}
238
+ if self.interactive:
239
+ print("Disabling port forwarding in interactive mode")
240
+ ports = {}
241
+ else:
242
+ ports = {CLIENT_PORT: port}
213
243
  volumes = []
214
244
  if self.fastled_src_dir:
215
245
  print(
@@ -238,20 +268,39 @@ class CompileServerImpl:
238
268
  )
239
269
  if self.fastled_src_dir is not None:
240
270
  # to allow for interactive compilation
241
- interactive_sources = list(INTERACTIVE_SOURCES)
242
- for src in interactive_sources:
243
- src_path = Path(src).absolute()
271
+ # interactive_sources = list(INTERACTIVE_SOURCES)
272
+ interactive_sources: list[tuple[Path, str]] = []
273
+ init_runtime_py = (
274
+ Path(self.fastled_src_dir)
275
+ / ".."
276
+ / ".."
277
+ / "fastled-wasm"
278
+ / "compiler"
279
+ / "init_runtime.py"
280
+ )
281
+ if init_runtime_py.exists():
282
+ # fastled-wasm is in a sister directory, mapping this in to the container.
283
+ mapping = (
284
+ init_runtime_py,
285
+ "/js/init_runtime.py",
286
+ )
287
+ interactive_sources.append(mapping)
288
+
289
+ src_host: Path
290
+ dst_container: str
291
+ for src_host, dst_container in interactive_sources:
292
+ src_path = Path(src_host).absolute()
244
293
  if src_path.exists():
245
- print(f"Mounting {src} into container")
294
+ print(f"Mounting {src_host} into container")
246
295
  volumes.append(
247
296
  Volume(
248
297
  host_path=str(src_path),
249
- container_path=f"/js/fastled/{src}",
298
+ container_path=dst_container,
250
299
  mode="rw",
251
300
  )
252
301
  )
253
302
  else:
254
- print(f"Could not find {src}")
303
+ print(f"Could not find {src_path}")
255
304
 
256
305
  cmd_str = subprocess.list2cmdline(server_command)
257
306
  if not self.interactive:
@@ -269,6 +318,13 @@ class CompileServerImpl:
269
318
  print("Compile server starting")
270
319
  return port
271
320
  else:
321
+ client_port_mapped = CLIENT_PORT in ports
322
+ port_is_free = _port_is_free(CLIENT_PORT)
323
+ if client_port_mapped and port_is_free:
324
+ warnings.warn(
325
+ f"Can't expose port {CLIENT_PORT}, disabling port forwarding in interactive mode"
326
+ )
327
+ ports = {}
272
328
  self.docker.run_container_interactive(
273
329
  image_name=IMAGE_NAME,
274
330
  tag="latest",
fastled/print_filter.py CHANGED
@@ -39,6 +39,10 @@ def _handle_ino_cpp(line: str) -> str:
39
39
  return line
40
40
 
41
41
 
42
+ def _handle_fastled_src(line: str) -> str:
43
+ return line.replace("fastled/src", "src")
44
+
45
+
42
46
  class PrintFilterDefault(PrintFilter):
43
47
  """Provides default filtering for FastLED output."""
44
48
 
@@ -61,6 +65,9 @@ class PrintFilterFastled(PrintFilter):
61
65
  # print(line)
62
66
  if "# WASM is building" in line:
63
67
  self.build_started = True
68
+ line = _handle_fastled_src(
69
+ line
70
+ ) # Always convert fastled/src to src for file matchups.
64
71
  if self.build_started or " error: " in line:
65
72
  line = _handle_ino_cpp(line)
66
73
  out.append(line)
fastled/settings.py CHANGED
@@ -12,3 +12,7 @@ SERVER_PORT = 9021
12
12
  IMAGE_NAME = "niteris/fastled-wasm"
13
13
  DEFAULT_CONTAINER_NAME = "fastled-wasm-compiler"
14
14
  # IMAGE_TAG = "latest"
15
+
16
+ DOCKER_FILE = (
17
+ "https://raw.githubusercontent.com/zackees/fastled-wasm/refs/heads/main/Dockerfile"
18
+ )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastled
3
- Version: 1.2.76
3
+ Version: 1.2.78
4
4
  Summary: FastLED Wasm Compiler
5
5
  Home-page: https://github.com/zackees/fastled-wasm
6
6
  Maintainer: Zachary Vorhies
@@ -1,27 +1,27 @@
1
- fastled/__init__.py,sha256=qOnSt1eqFW7UnWuHYVomp-m5U5G7PE5bcC0NTFZ4Mr4,6770
2
- fastled/app.py,sha256=vteMH0WvWGkQq-FR6SdAzqJcHqx0Gcj-aclXYZL7n5Q,4073
1
+ fastled/__init__.py,sha256=OO3Y9-Fio1wpJ92Fg2E6kWYfjOkaq6N_LwI0wWwGRu0,6680
2
+ fastled/app.py,sha256=0W8Mbplo5UCRzj7nMVgkmCBddQGufsUQjkUUT4pMp74,4611
3
3
  fastled/cli.py,sha256=FjVr31ht0UPlAcmX-84NwfAGMQHTkrCe4o744jCAxiw,375
4
4
  fastled/cli_test.py,sha256=qJB9yLRFR3OwOwdIWSQ0fQsWLnA37v5pDccufiP_hTs,512
5
- fastled/client_server.py,sha256=eG82h-27Y40szCew976lv9I6bP-YxtRV6sFNDVNTapo,14525
5
+ fastled/cli_test_interactive.py,sha256=BjNhveZOk5aCffHbcrxPQQjWmAuj4ClVKKcKX5eY6yM,542
6
+ fastled/client_server.py,sha256=_M3EsHOLlQI610qxcmBCLa2K5ERmNHpF1cI2C_xzkmk,14549
6
7
  fastled/compile_server.py,sha256=rkXvrvdav5vDG8lv_OlBX3YSCHtnHMt25nXbfeg_r78,2960
7
- fastled/compile_server_impl.py,sha256=LnvxeSgBQ3lvey3_dz71UnJjCb5WTUQaPYtuSc1BMvo,10706
8
+ fastled/compile_server_impl.py,sha256=_DRdt-eWTdOr2mXvO7h6dKqDSonsm523bIqCZr4wf2k,12615
8
9
  fastled/docker_manager.py,sha256=SC_qV6grNTGh0QD1ubKrULQblrN-2PORocISlaZg9NQ,35156
9
10
  fastled/filewatcher.py,sha256=3qS3L7zMQhFuVrkeGn1djsB_cB6x_E2YGJmmQWVAU_w,10033
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
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
+ fastled/print_filter.py,sha256=ZpebuqfWEraSBD3Dm0PVZhQVBnU_NSILniwBHwjC1qM,2342
18
18
  fastled/project_init.py,sha256=bBt4DwmW5hZkm9ICt9Qk-0Nr_0JQM7icCgH5Iv-bCQs,3984
19
19
  fastled/select_sketch_directory.py,sha256=-eudwCns3AKj4HuHtSkZAFwbnf005SNL07pOzs9VxnE,1383
20
20
  fastled/server_fastapi.py,sha256=ytsL4poO-yugDIhvYJq6nCNdLZ4fQJ1AFqXkF-uEkqo,1488
21
21
  fastled/server_fastapi_cli.py,sha256=fJGLvbJx5ertsZER_lgg0GfkYTX-V2rxzbNO1lEapU0,1392
22
22
  fastled/server_flask.py,sha256=i0OtDdrjiF9hjKNnI2ebf6Ag-mxMmtUCxnuHMBOzx7I,4665
23
23
  fastled/server_start.py,sha256=NfAV5pWdXn2HDvqiMrpHxuNqh2vnB4xVFltV5Pn16GM,3509
24
- fastled/settings.py,sha256=URgM6ZPlQYF-0ZTEhQCX8isLR6CbmYGwhDX4uXbh-ZI,468
24
+ fastled/settings.py,sha256=oezRvRUJWwauO-kpC4LDbKg6Q-ij4d09UtR2vkjSAPU,575
25
25
  fastled/sketch.py,sha256=tHckjDj8P6BI_LWzUFM071a9qcqPs-r-qFWIe50P5Xw,3391
26
26
  fastled/spinner.py,sha256=VHxmvB92P0Z_zYxRajb5HiNmkHHvZ5dG7hKtZltzpcs,867
27
27
  fastled/string_diff.py,sha256=NbtYxvBFxTUdmTpMLizlgZj2ULJ-7etj72GBdWDTGws,2496
@@ -35,9 +35,9 @@ fastled/site/build.py,sha256=2YKU_UWKlJdGnjdbAbaL0co6kceFMSTVYwH1KCmgPZA,13987
35
35
  fastled/site/examples.py,sha256=s6vj2zJc6BfKlnbwXr1QWY1mzuDBMt6j5MEBOWjO_U8,155
36
36
  fastled/test/can_run_local_docker_tests.py,sha256=LEuUbHctRhNNFWcvnz2kEGmjDJeXO4c3kNpizm3yVJs,400
37
37
  fastled/test/examples.py,sha256=GfaHeY1E8izBl6ZqDVjz--RHLyVR4NRnQ5pBesCFJFY,1673
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,,
38
+ fastled-1.2.78.dist-info/licenses/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
39
+ fastled-1.2.78.dist-info/METADATA,sha256=vzbxAQY1Pvv7RNJOj_Fx1Cot8ReBujjBgYcoltrNis8,22065
40
+ fastled-1.2.78.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
41
+ fastled-1.2.78.dist-info/entry_points.txt,sha256=RCwmzCSOS4-C2i9EziANq7Z2Zb4KFnEMR1FQC0bBwAw,101
42
+ fastled-1.2.78.dist-info/top_level.txt,sha256=Bbv5kpJpZhWNCvDF4K0VcvtBSDMa8B7PTOrZa9CezHY,8
43
+ fastled-1.2.78.dist-info/RECORD,,
@@ -1,5 +0,0 @@
1
- INTERACTIVE_SOURCES: list[str] = [
2
- "/js/compiler/CMakeLists.txt",
3
- "/js/compiler/build_archive.sh",
4
- "/js/compiler/build.sh",
5
- ]