fastled 1.1.24__py2.py3-none-any.whl → 1.1.26__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
1
  """FastLED Wasm Compiler package."""
2
2
 
3
- __version__ = "1.1.24"
3
+ __version__ = "1.1.26"
fastled/app.py CHANGED
@@ -157,7 +157,7 @@ def run_server(args: argparse.Namespace) -> int:
157
157
  compile_server = CompileServer(interactive=interactive, auto_updates=auto_update)
158
158
  if not interactive:
159
159
  print(f"Server started at {compile_server.url()}")
160
- compile_server.wait_for_startup()
160
+ compile_server.wait_for_startup()
161
161
  try:
162
162
  while True:
163
163
  if not compile_server.proceess_running():
@@ -192,7 +192,8 @@ def main() -> int:
192
192
  if __name__ == "__main__":
193
193
  try:
194
194
  os.chdir("../fastled")
195
- sys.argv.append("--upgrade")
195
+ sys.argv.append("--interactive")
196
+ sys.argv.append("examples/NoiseRing")
196
197
  sys.exit(main())
197
198
  except KeyboardInterrupt:
198
199
  print("\nExiting from main...")
fastled/client_server.py CHANGED
@@ -269,13 +269,19 @@ def run_client_server(args: argparse.Namespace) -> int:
269
269
  timeout=1.0
270
270
  )
271
271
  file_changes = source_code_watcher.get_all_changes()
272
+ sketch_files_changed = sketch_filewatcher.get_all_changes()
272
273
 
273
- if space_bar_pressed or file_changes:
274
+ if file_changes:
275
+ print(
276
+ f"Changes detected in {file_changes}\nHit the space bar to trigger compile."
277
+ )
278
+
279
+ if space_bar_pressed or sketch_files_changed:
274
280
  if space_bar_pressed:
275
281
  print("Space bar pressed, triggering recompile...")
276
- elif file_changes:
282
+ elif sketch_files_changed:
277
283
  print(
278
- f"Changes detected in {','.join(file_changes)}, triggering recompile..."
284
+ f"Changes detected in {','.join(sketch_files_changed)}, triggering recompile..."
279
285
  )
280
286
  last_compiled_result = compile_function(
281
287
  last_hash_value=None
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"
@@ -119,8 +124,6 @@ class CompileServer:
119
124
  server_command = ["/bin/bash"]
120
125
  else:
121
126
  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
127
  ports = {80: port}
125
128
  volumes = None
126
129
  if self.fastled_src_dir:
@@ -132,20 +135,32 @@ class CompileServer:
132
135
  }
133
136
 
134
137
  cmd_str = subprocess.list2cmdline(server_command)
138
+ if not self.interactive:
139
+ container: Container = self.docker.run_container_detached(
140
+ image_name=_IMAGE_NAME,
141
+ tag="main",
142
+ container_name=self.container_name,
143
+ command=cmd_str,
144
+ ports=ports,
145
+ volumes=volumes,
146
+ remove_previous=self.interactive,
147
+ )
148
+ self.running_container = self.docker.attach_and_run(container)
149
+ assert self.running_container is not None, "Container should be running"
150
+ print("Compile server starting")
151
+ return port
152
+ else:
153
+ self.docker.run_container_interactive(
154
+ image_name=_IMAGE_NAME,
155
+ tag="main",
156
+ container_name=self.container_name,
157
+ command=cmd_str,
158
+ ports=ports,
159
+ volumes=volumes,
160
+ )
135
161
 
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
162
+ print("Exiting interactive mode")
163
+ return port
149
164
 
150
165
  def proceess_running(self) -> bool:
151
166
  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
 
@@ -26,7 +26,7 @@ def select_sketch_directory(
26
26
  return str(sketch_directories[index])
27
27
  except (ValueError, IndexError):
28
28
  inputs = [p for p in sketch_directories]
29
- top_hits: list[tuple[int, Path]] = string_diff_paths(which, inputs)
29
+ top_hits: list[tuple[float, Path]] = string_diff_paths(which, inputs)
30
30
  if len(top_hits) == 1:
31
31
  example = top_hits[0][1]
32
32
  return str(example)
fastled/string_diff.py CHANGED
@@ -1,6 +1,6 @@
1
1
  from pathlib import Path
2
2
 
3
- from rapidfuzz.distance import Levenshtein
3
+ from rapidfuzz import fuzz
4
4
 
5
5
 
6
6
  # Returns the min distance strings. If there is a tie, it returns
@@ -8,29 +8,35 @@ from rapidfuzz.distance import Levenshtein
8
8
  # Returns a tuple of index and string.
9
9
  def string_diff(
10
10
  input_string: str, string_list: list[str], ignore_case=True
11
- ) -> list[tuple[int, str]]:
11
+ ) -> list[tuple[float, str]]:
12
12
 
13
13
  def normalize(s: str) -> str:
14
14
  return s.lower() if ignore_case else s
15
15
 
16
- distances = [
17
- Levenshtein.distance(normalize(input_string), normalize(s)) for s in string_list
18
- ]
16
+ # distances = [
17
+ # #Levenshtein.distance(normalize(input_string), normalize(s)) for s in string_list
18
+ # fuzz.partial_ratio(normalize(input_string), normalize(s)) for s in string_list
19
+ # ]
20
+ distances: list[float] = []
21
+ for s in string_list:
22
+ dist = fuzz.token_sort_ratio(normalize(input_string), normalize(s))
23
+ print("partial_ratio", dist)
24
+ distances.append(1.0 / (dist + 1.0))
19
25
  min_distance = min(distances)
20
- out: list[tuple[int, str]] = []
26
+ out: list[tuple[float, str]] = []
21
27
  for i, d in enumerate(distances):
22
28
  if d == min_distance:
23
29
  out.append((i, string_list[i]))
30
+
24
31
  return out
25
32
 
26
33
 
27
34
  def string_diff_paths(
28
35
  input_string: str | Path, path_list: list[Path], ignore_case=True
29
- ) -> list[tuple[int, Path]]:
36
+ ) -> list[tuple[float, Path]]:
30
37
  string_list = [str(p) for p in path_list]
31
38
  tmp = string_diff(str(input_string), string_list, ignore_case)
32
- # out: list[tuple[int, Path]] = [(i, Path(path_list[j])) for i, j in tmp]
33
- out: list[tuple[int, Path]] = []
39
+ out: list[tuple[float, Path]] = []
34
40
  for i, j in tmp:
35
41
  p = Path(j)
36
42
  out.append((i, p))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fastled
3
- Version: 1.1.24
3
+ Version: 1.1.26
4
4
  Summary: FastLED Wasm Compiler
5
5
  Home-page: https://github.com/zackees/fastled-wasm
6
6
  Maintainer: Zachary Vorhies
@@ -161,8 +161,12 @@ A: `delay()` will block `loop()` which blocks the main thread of the browser. Th
161
161
  Q: How can I get the compiled size of my FastLED sketch smaller?
162
162
  A: A big chunk of space is being used by unnecessary javascript `emscripten` is bundling. This can be tweeked by the wasm_compiler_settings.py file in the FastLED repo.
163
163
 
164
- # Revisions
165
164
 
165
+
166
+ # Revisions
167
+
168
+ * 1.1.26 - Fixed `--interactive` so that it now works correctly.
169
+ * 1.1.25 - Improved detecting which sketch directory the user means by fuzzy matching.
166
170
  * 1.1.24 - Adds progress spinning bar for pulling images, which take a long time.
167
171
  * 1.1.23 - Various fixes for MacOS
168
172
  * 1.1.22 - Selecting sketch now allows strings and narrowing down paths if ambiguity
@@ -1,26 +1,26 @@
1
- fastled/__init__.py,sha256=KmpV56lsAg31rlm1PyvbeZuohDl5DpIlQpi9SDuldc4,64
2
- fastled/app.py,sha256=VZP65zT1qLQLcOXA8oElPdZiladIAMvW9MVnqy5QTRM,6806
1
+ fastled/__init__.py,sha256=5-jQK-HR_0kUeBf2hyQ72AApd6GSPIjapr6fk2DY-Dg,64
2
+ fastled/app.py,sha256=U8JN0VGC2adw6BKC7INco4iDG5zLj4L2Etzr9smWyeQ,6861
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
- fastled/client_server.py,sha256=CBgicRyunn96tVeAHQOuo4q2gkDFAtLEPxhTf2EnQ_0,11113
6
- fastled/compile_server.py,sha256=aBdpILSRrDsCJ5e9g5uwIqt9bcqE_8FrSddCV2ygtrI,5401
7
- fastled/docker_manager.py,sha256=awQCAB0XfHMy6y1jfdEZx1qyzXTtYBmAwVyuQjxwuf0,20157
5
+ fastled/client_server.py,sha256=KdjgAiYJ2mKXIfYVFcVZtVDtbZhzkjqrzatAwNa_QWw,11437
6
+ fastled/compile_server.py,sha256=rtAW9zllb8WOSzhoRUMtdMGDzYFL4CtyoWVa7Y-jK24,5810
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
11
11
  fastled/open_browser.py,sha256=RRHcsZ5Vzsw1AuZUEYuSfjKmf_9j3NGMDUR-FndHmqs,1483
12
12
  fastled/paths.py,sha256=VsPmgu0lNSCFOoEC0BsTYzDygXqy15AHUfN-tTuzDZA,99
13
- fastled/select_sketch_directory.py,sha256=ih8Voua8ecMIZ9m0ZEBp_EuuBzz8xGfMxC_UhAKuoA0,1312
13
+ fastled/select_sketch_directory.py,sha256=TZdCjl1D7YMKjodMTvDRurPcpAmN3x0TcJxffER2NfM,1314
14
14
  fastled/sketch.py,sha256=5nRjg281lMH8Bo9wKjbcpTQCfEP574ZCG-lukvFmyQ8,2656
15
15
  fastled/spinner.py,sha256=ZGFXona3SJxmuHIzMGa6tqB0IVDSRr8W_dju09Z1Hwg,901
16
- fastled/string_diff.py,sha256=svtaQFGp4a6r2Qjx-Gxhna94wK-d8LKV4OCpKMXiHso,1164
16
+ fastled/string_diff.py,sha256=1AbgAxPFl7F_K4HunwQr0em8WZSvwxJ1MOOLA-ylFbM,1391
17
17
  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.24.dist-info/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
22
- fastled-1.1.24.dist-info/METADATA,sha256=tiMyoOLRhVYmwuoqohRRk5xxTBD9M41cqyL_g1cE24o,14160
23
- fastled-1.1.24.dist-info/WHEEL,sha256=0VNUDWQJzfRahYI3neAhz2UVbRCtztpN5dPHAGvmGXc,109
24
- fastled-1.1.24.dist-info/entry_points.txt,sha256=RCwmzCSOS4-C2i9EziANq7Z2Zb4KFnEMR1FQC0bBwAw,101
25
- fastled-1.1.24.dist-info/top_level.txt,sha256=xfG6Z_ol9V5YmBROkZq2QTRwjbS2ouCUxaTJsOwfkOo,14
26
- fastled-1.1.24.dist-info/RECORD,,
21
+ fastled-1.1.26.dist-info/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
22
+ fastled-1.1.26.dist-info/METADATA,sha256=Sp3HqgomtVTcvohI_6j5V1z6xt7GpKWZjgmhRSPOjLs,14324
23
+ fastled-1.1.26.dist-info/WHEEL,sha256=0VNUDWQJzfRahYI3neAhz2UVbRCtztpN5dPHAGvmGXc,109
24
+ fastled-1.1.26.dist-info/entry_points.txt,sha256=RCwmzCSOS4-C2i9EziANq7Z2Zb4KFnEMR1FQC0bBwAw,101
25
+ fastled-1.1.26.dist-info/top_level.txt,sha256=xfG6Z_ol9V5YmBROkZq2QTRwjbS2ouCUxaTJsOwfkOo,14
26
+ fastled-1.1.26.dist-info/RECORD,,