fastled 1.1.25__py2.py3-none-any.whl → 1.1.27__py2.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
@@ -1,3 +1,3 @@
1
- """FastLED Wasm Compiler package."""
2
-
3
- __version__ = "1.1.25"
1
+ """FastLED Wasm Compiler package."""
2
+
3
+ __version__ = "1.1.27"
fastled/app.py CHANGED
@@ -154,10 +154,13 @@ def parse_args() -> argparse.Namespace:
154
154
  def run_server(args: argparse.Namespace) -> int:
155
155
  interactive = args.interactive
156
156
  auto_update = args.auto_update
157
- compile_server = CompileServer(interactive=interactive, auto_updates=auto_update)
157
+ mapped_dir = Path(args.directory).absolute() if args.directory else None
158
+ compile_server = CompileServer(
159
+ interactive=interactive, auto_updates=auto_update, mapped_dir=mapped_dir
160
+ )
158
161
  if not interactive:
159
162
  print(f"Server started at {compile_server.url()}")
160
- compile_server.wait_for_startup()
163
+ compile_server.wait_for_startup()
161
164
  try:
162
165
  while True:
163
166
  if not compile_server.proceess_running():
@@ -192,7 +195,8 @@ def main() -> int:
192
195
  if __name__ == "__main__":
193
196
  try:
194
197
  os.chdir("../fastled")
195
- sys.argv.append("--upgrade")
198
+ sys.argv.append("--interactive")
199
+ sys.argv.append("examples/NoiseRing")
196
200
  sys.exit(main())
197
201
  except KeyboardInterrupt:
198
202
  print("\nExiting from main...")
fastled/compile_server.py CHANGED
@@ -5,7 +5,12 @@ from pathlib import Path
5
5
 
6
6
  import httpx
7
7
 
8
- from fastled.docker_manager import DISK_CACHE, DockerManager, RunningContainer
8
+ from fastled.docker_manager import (
9
+ DISK_CACHE,
10
+ Container,
11
+ DockerManager,
12
+ RunningContainer,
13
+ )
9
14
  from fastled.sketch import looks_like_fastled_repo
10
15
 
11
16
  _IMAGE_NAME = "niteris/fastled-wasm"
@@ -22,8 +27,14 @@ class CompileServer:
22
27
  container_name=_DEFAULT_CONTAINER_NAME,
23
28
  interactive: bool = False,
24
29
  auto_updates: bool | None = None,
30
+ mapped_dir: Path | None = None,
25
31
  ) -> None:
26
-
32
+ if interactive and not mapped_dir:
33
+ raise ValueError(
34
+ "Interactive mode requires a mapped directory point to a sketch"
35
+ )
36
+ if not interactive and mapped_dir:
37
+ raise ValueError("Mapped directory is only used in interactive mode")
27
38
  cwd = Path(".").resolve()
28
39
  fastled_src_dir: Path | None = None
29
40
  if looks_like_fastled_repo(cwd):
@@ -33,6 +44,7 @@ class CompileServer:
33
44
  fastled_src_dir = cwd / "src"
34
45
 
35
46
  self.container_name = container_name
47
+ self.mapped_dir = mapped_dir
36
48
  self.docker = DockerManager()
37
49
  self.fastled_src_dir: Path | None = fastled_src_dir
38
50
  self.interactive = interactive
@@ -119,8 +131,6 @@ class CompileServer:
119
131
  server_command = ["/bin/bash"]
120
132
  else:
121
133
  server_command = ["python", "/js/run.py", "server"] + SERVER_OPTIONS
122
- server_cmd_str = subprocess.list2cmdline(server_command)
123
- print(f"Started Docker container with command: {server_cmd_str}")
124
134
  ports = {80: port}
125
135
  volumes = None
126
136
  if self.fastled_src_dir:
@@ -130,22 +140,47 @@ class CompileServer:
130
140
  volumes = {
131
141
  str(self.fastled_src_dir): {"bind": "/host/fastled/src", "mode": "ro"}
132
142
  }
143
+ if self.interactive:
144
+ # add the mapped directory to the container
145
+ print(f"Mounting {self.mapped_dir} into container /mapped")
146
+ # volumes = {str(self.mapped_dir): {"bind": "/mapped", "mode": "rw"}}
147
+ # add it
148
+ assert self.mapped_dir is not None
149
+ dir_name = self.mapped_dir.name
150
+ if not volumes:
151
+ volumes = {}
152
+ volumes[str(self.mapped_dir)] = {
153
+ "bind": f"/mapped/{dir_name}",
154
+ "mode": "rw",
155
+ }
133
156
 
134
157
  cmd_str = subprocess.list2cmdline(server_command)
158
+ if not self.interactive:
159
+ container: Container = self.docker.run_container_detached(
160
+ image_name=_IMAGE_NAME,
161
+ tag="main",
162
+ container_name=self.container_name,
163
+ command=cmd_str,
164
+ ports=ports,
165
+ volumes=volumes,
166
+ remove_previous=self.interactive,
167
+ )
168
+ self.running_container = self.docker.attach_and_run(container)
169
+ assert self.running_container is not None, "Container should be running"
170
+ print("Compile server starting")
171
+ return port
172
+ else:
173
+ self.docker.run_container_interactive(
174
+ image_name=_IMAGE_NAME,
175
+ tag="main",
176
+ container_name=self.container_name,
177
+ command=cmd_str,
178
+ ports=ports,
179
+ volumes=volumes,
180
+ )
135
181
 
136
- self.docker.run_container(
137
- image_name=_IMAGE_NAME,
138
- tag="main",
139
- container_name=self.container_name,
140
- command=cmd_str,
141
- ports=ports,
142
- volumes=volumes,
143
- )
144
- self.running_container = self.docker.attach_and_run(self.container_name)
145
- assert self.running_container is not None, "Container should be running"
146
-
147
- print("Compile server starting")
148
- return port
182
+ print("Exiting interactive mode")
183
+ return port
149
184
 
150
185
  def proceess_running(self) -> bool:
151
186
  return self.docker.is_container_running(self.container_name)
fastled/docker_manager.py CHANGED
@@ -339,7 +339,7 @@ class DockerManager:
339
339
  return False
340
340
  return True
341
341
 
342
- def run_container(
342
+ def run_container_detached(
343
343
  self,
344
344
  image_name: str,
345
345
  tag: str,
@@ -347,6 +347,7 @@ class DockerManager:
347
347
  command: str | None = None,
348
348
  volumes: dict[str, dict[str, str]] | None = None,
349
349
  ports: dict[int, int] | None = None,
350
+ remove_previous: bool = False,
350
351
  ) -> Container:
351
352
  """
352
353
  Run a container from an image. If it already exists with matching config, start it.
@@ -362,8 +363,12 @@ class DockerManager:
362
363
  try:
363
364
  container: Container = self.client.containers.get(container_name)
364
365
 
366
+ if remove_previous:
367
+ print(f"Removing existing container {container_name}...")
368
+ container.remove(force=True)
369
+ raise docker.errors.NotFound("Container removed due to remove_previous")
365
370
  # Check if configuration matches
366
- if not self._container_configs_match(container, command, volumes, ports):
371
+ elif not self._container_configs_match(container, command, volumes, ports):
367
372
  print(
368
373
  f"Container {container_name} exists but with different configuration. Removing and recreating..."
369
374
  )
@@ -400,6 +405,11 @@ class DockerManager:
400
405
  container.start()
401
406
  except docker.errors.NotFound:
402
407
  print(f"Creating and starting {container_name}")
408
+ out_msg = f"# Running in container: {command}"
409
+ msg_len = len(out_msg)
410
+ print("\n" + "#" * msg_len)
411
+ print(out_msg)
412
+ print("#" * msg_len + "\n")
403
413
  container = self.client.containers.run(
404
414
  image_name,
405
415
  command,
@@ -411,6 +421,46 @@ class DockerManager:
411
421
  )
412
422
  return container
413
423
 
424
+ def run_container_interactive(
425
+ self,
426
+ image_name: str,
427
+ tag: str,
428
+ container_name: str,
429
+ command: str | None = None,
430
+ volumes: dict[str, dict[str, str]] | None = None,
431
+ ports: dict[int, int] | None = None,
432
+ ) -> None:
433
+ # Remove existing container
434
+ try:
435
+ container: Container = self.client.containers.get(container_name)
436
+ container.remove(force=True)
437
+ except docker.errors.NotFound:
438
+ pass
439
+ try:
440
+ docker_command: list[str] = [
441
+ "docker",
442
+ "run",
443
+ "-it",
444
+ "--rm",
445
+ "--name",
446
+ container_name,
447
+ ]
448
+ if volumes:
449
+ for host_dir, mount in volumes.items():
450
+ docker_command.extend(["-v", f"{host_dir}:{mount['bind']}"])
451
+ if ports:
452
+ for host_port, container_port in ports.items():
453
+ docker_command.extend(["-p", f"{host_port}:{container_port}"])
454
+ docker_command.append(f"{image_name}:{tag}")
455
+ if command:
456
+ docker_command.append(command)
457
+ cmd_str: str = subprocess.list2cmdline(docker_command)
458
+ print(f"Running command: {cmd_str}")
459
+ subprocess.run(docker_command, check=True)
460
+ except subprocess.CalledProcessError as e:
461
+ print(f"Error running Docker command: {e}")
462
+ raise
463
+
414
464
  def attach_and_run(self, container: Container | str) -> RunningContainer:
415
465
  """
416
466
  Attach to a running container and monitor its logs in a background thread.
@@ -499,7 +549,7 @@ def main():
499
549
  # docker_manager.tag_image(image_name, tag, new_tag)
500
550
 
501
551
  # Step 3: Run the container
502
- container = docker_manager.run_container(
552
+ container = docker_manager.run_container_detached(
503
553
  image_name, tag, container_name, command
504
554
  )
505
555
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fastled
3
- Version: 1.1.25
3
+ Version: 1.1.27
4
4
  Summary: FastLED Wasm Compiler
5
5
  Home-page: https://github.com/zackees/fastled-wasm
6
6
  Maintainer: Zachary Vorhies
@@ -165,6 +165,7 @@ A: A big chunk of space is being used by unnecessary javascript `emscripten` is
165
165
 
166
166
  # Revisions
167
167
 
168
+ * 1.1.27 - Fixed `--interactive` so that it now works correctly.
168
169
  * 1.1.25 - Improved detecting which sketch directory the user means by fuzzy matching.
169
170
  * 1.1.24 - Adds progress spinning bar for pulling images, which take a long time.
170
171
  * 1.1.23 - Various fixes for MacOS
@@ -1,10 +1,10 @@
1
- fastled/__init__.py,sha256=e5n65cupSlM41aRjoBsTReaO1NiY5it6yu3XFaYSbBQ,64
2
- fastled/app.py,sha256=VZP65zT1qLQLcOXA8oElPdZiladIAMvW9MVnqy5QTRM,6806
1
+ fastled/__init__.py,sha256=mjC0WCvol1btJDkCz8i8NbyHnPxX7MoKjTnKk6sCQxo,61
2
+ fastled/app.py,sha256=oL_IXsYxDRaw9eU2aSkCZ57xAUedbNWT4-WwCsJT2Sc,6978
3
3
  fastled/build_mode.py,sha256=joMwsV4K1y_LijT4gEAcjx69RZBoe_KmFmHZdPYbL_4,631
4
4
  fastled/cli.py,sha256=CNR_pQR0sNVPNuv8e_nmm-0PI8sU-eUBUgnWgWkzW9c,237
5
5
  fastled/client_server.py,sha256=KdjgAiYJ2mKXIfYVFcVZtVDtbZhzkjqrzatAwNa_QWw,11437
6
- fastled/compile_server.py,sha256=aBdpILSRrDsCJ5e9g5uwIqt9bcqE_8FrSddCV2ygtrI,5401
7
- fastled/docker_manager.py,sha256=awQCAB0XfHMy6y1jfdEZx1qyzXTtYBmAwVyuQjxwuf0,20157
6
+ fastled/compile_server.py,sha256=Adb2lvJ_p6Ui7UMxijRtYJhbO4YPTERKVQeuoQgibSE,6724
7
+ fastled/docker_manager.py,sha256=Ok8TC1JXMoNMWt4P9clFFEVE29Xd-4C_MvIMIfvNo78,22134
8
8
  fastled/env.py,sha256=8wctQwl5qE4CI8NBugHtgMmUfEfHZ869JX5lGdSOJxc,304
9
9
  fastled/filewatcher.py,sha256=5dVmjEG23kMeJa29tRVm5XKSr9sTD4ME2boo-CFDuUM,6910
10
10
  fastled/keyboard.py,sha256=Zz_ggxOUTX2XQEy6K6kAoorVlUev4wEk9Awpvv9aStA,3241
@@ -18,9 +18,9 @@ fastled/types.py,sha256=dDIsGHJkHNJ7B61wNp6X0JSLs_nrHiq7RlNqNWbwFec,194
18
18
  fastled/util.py,sha256=t4M3NFMhnCzfYbLvIyJi0RdFssZqbTN_vVIaej1WV-U,265
19
19
  fastled/web_compile.py,sha256=KuvKGdX6SSUUqC7YgX4T9SMSP5wdcPUhpg9-K9zPoTI,10378
20
20
  fastled/assets/example.txt,sha256=lTBovRjiz0_TgtAtbA1C5hNi2ffbqnNPqkKg6UiKCT8,54
21
- fastled-1.1.25.dist-info/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
22
- fastled-1.1.25.dist-info/METADATA,sha256=ZC9sOPn37oR4i96ddFOlgtiy_wfI2OOK7FXGruZif_I,14256
23
- fastled-1.1.25.dist-info/WHEEL,sha256=0VNUDWQJzfRahYI3neAhz2UVbRCtztpN5dPHAGvmGXc,109
24
- fastled-1.1.25.dist-info/entry_points.txt,sha256=RCwmzCSOS4-C2i9EziANq7Z2Zb4KFnEMR1FQC0bBwAw,101
25
- fastled-1.1.25.dist-info/top_level.txt,sha256=xfG6Z_ol9V5YmBROkZq2QTRwjbS2ouCUxaTJsOwfkOo,14
26
- fastled-1.1.25.dist-info/RECORD,,
21
+ fastled-1.1.27.dist-info/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
22
+ fastled-1.1.27.dist-info/METADATA,sha256=XOkF-RbQNvRne_R6BEM2jDvR8Wma3RlhENXMk8dyxHI,14324
23
+ fastled-1.1.27.dist-info/WHEEL,sha256=0VNUDWQJzfRahYI3neAhz2UVbRCtztpN5dPHAGvmGXc,109
24
+ fastled-1.1.27.dist-info/entry_points.txt,sha256=RCwmzCSOS4-C2i9EziANq7Z2Zb4KFnEMR1FQC0bBwAw,101
25
+ fastled-1.1.27.dist-info/top_level.txt,sha256=xfG6Z_ol9V5YmBROkZq2QTRwjbS2ouCUxaTJsOwfkOo,14
26
+ fastled-1.1.27.dist-info/RECORD,,