fastled 1.2.39__py3-none-any.whl → 1.2.41__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
@@ -3,11 +3,14 @@
3
3
  # context
4
4
  import shutil
5
5
  import subprocess
6
+ import tempfile
6
7
  from contextlib import contextmanager
7
8
  from multiprocessing import Process
8
9
  from pathlib import Path
9
10
  from typing import Generator
10
11
 
12
+ import httpx
13
+
11
14
  from .compile_server import CompileServer
12
15
  from .live_client import LiveClient
13
16
  from .site.build import build
@@ -16,7 +19,11 @@ from .types import BuildMode, CompileResult, CompileServerError
16
19
  # IMPORTANT! There's a bug in github which will REJECT any version update
17
20
  # that has any other change in the repo. Please bump the version as the
18
21
  # ONLY change in a commit, or else the pypi update and the release will fail.
19
- __version__ = "1.2.39"
22
+ __version__ = "1.2.41"
23
+
24
+ DOCKER_FILE = (
25
+ "https://raw.githubusercontent.com/zackees/fastled-wasm/refs/heads/main/Dockerfile"
26
+ )
20
27
 
21
28
 
22
29
  class Api:
@@ -222,36 +229,40 @@ class Docker:
222
229
  ["git", "clone", "--depth", "1", url, str(output_dir)], check=True
223
230
  )
224
231
 
225
- dockerfile_path = (
226
- output_dir / "src" / "platforms" / "wasm" / "compiler" / "Dockerfile"
227
- )
232
+ with tempfile.TemporaryDirectory() as tempdir:
233
+ dockerfiles_dst = Path(tempdir) / "Dockerfile"
234
+ # download the file and write it to dockerfiles_dst path
235
+ with open(dockerfiles_dst, "wb") as f:
236
+ with httpx.stream("GET", DOCKER_FILE) as response:
237
+ for chunk in response.iter_bytes():
238
+ f.write(chunk)
239
+
240
+ if not dockerfiles_dst.exists():
241
+ raise FileNotFoundError(
242
+ f"Dockerfile not found at {dockerfiles_dst}. "
243
+ "This may not be a valid FastLED repository."
244
+ )
228
245
 
229
- if not dockerfile_path.exists():
230
- raise FileNotFoundError(
231
- f"Dockerfile not found at {dockerfile_path}. "
232
- "This may not be a valid FastLED repository."
246
+ docker_mgr = DockerManager()
247
+
248
+ platform_tag = ""
249
+ # if "arm" in docker_mgr.architecture():
250
+ if (
251
+ "arm"
252
+ in subprocess.run(["uname", "-m"], capture_output=True).stdout.decode()
253
+ ):
254
+ platform_tag = "-arm64"
255
+
256
+ # Build the image
257
+ docker_mgr.build_image(
258
+ image_name=IMAGE_NAME,
259
+ tag="main",
260
+ dockerfile_path=dockerfiles_dst,
261
+ build_context=output_dir,
262
+ build_args={"NO_PREWARM": "1"},
263
+ platform_tag=platform_tag,
233
264
  )
234
265
 
235
- docker_mgr = DockerManager()
236
-
237
- platform_tag = ""
238
- # if "arm" in docker_mgr.architecture():
239
- if (
240
- "arm"
241
- in subprocess.run(["uname", "-m"], capture_output=True).stdout.decode()
242
- ):
243
- platform_tag = "-arm64"
244
-
245
- # Build the image
246
- docker_mgr.build_image(
247
- image_name=IMAGE_NAME,
248
- tag="main",
249
- dockerfile_path=dockerfile_path,
250
- build_context=output_dir,
251
- build_args={"NO_PREWARM": "1"},
252
- platform_tag=platform_tag,
253
- )
254
-
255
266
  # # Run the container and return it
256
267
  # container = docker_mgr.run_container_detached(
257
268
  # image_name=IMAGE_NAME,
@@ -298,18 +309,17 @@ class Docker:
298
309
  if interactive:
299
310
  if sketch_folder is None:
300
311
  sketch_folder = project_root / "examples" / "wasm"
301
- else:
302
- if sketch_folder is not None:
303
- raise ValueError(
304
- "Cannot specify sketch_folder when not in interactive mode."
305
- )
312
+
306
313
  if isinstance(project_root, str):
307
314
  project_root = Path(project_root)
308
315
 
309
- dockerfile_path = (
310
- project_root / "src" / "platforms" / "wasm" / "compiler" / "Dockerfile"
311
- )
316
+ if DockerManager.is_docker_installed() is False:
317
+ raise Exception("Docker is not installed.")
318
+
312
319
  docker_mgr = DockerManager()
320
+ if DockerManager.is_running() is False:
321
+ docker_mgr.start()
322
+
313
323
  platform_tag = ""
314
324
  # if "arm" in docker_mgr.architecture():
315
325
  if (
@@ -321,15 +331,24 @@ class Docker:
321
331
  # if image exists, remove it
322
332
  docker_mgr.purge(image_name=IMAGE_NAME)
323
333
 
324
- # Build the image
325
- docker_mgr.build_image(
326
- image_name=IMAGE_NAME,
327
- tag="main",
328
- dockerfile_path=dockerfile_path,
329
- build_context=project_root,
330
- build_args={"NO_PREWARM": "1"},
331
- platform_tag=platform_tag,
332
- )
334
+ with tempfile.TemporaryDirectory() as tempdir:
335
+ dockerfile_dst = Path(tempdir) / "Dockerfile"
336
+
337
+ # download the file and write it to dockerfiles_dst path
338
+ with open(dockerfile_dst, "wb") as f:
339
+ with httpx.stream("GET", DOCKER_FILE) as response:
340
+ for chunk in response.iter_bytes():
341
+ f.write(chunk)
342
+
343
+ # Build the image
344
+ docker_mgr.build_image(
345
+ image_name=IMAGE_NAME,
346
+ tag="main",
347
+ dockerfile_path=dockerfile_dst,
348
+ build_context=project_root,
349
+ build_args={"NO_PREWARM": "1"},
350
+ platform_tag=platform_tag,
351
+ )
333
352
 
334
353
  out: CompileServer = CompileServer(
335
354
  container_name=CONTAINER_NAME,
fastled/app.py CHANGED
@@ -60,17 +60,19 @@ def main() -> int:
60
60
  return 0
61
61
 
62
62
  if build:
63
- try:
64
- file_watcher_set(False)
65
- project_root = Path(".").absolute()
66
- print(f"Building Docker image at {project_root}")
67
- from fastled import Api, Docker
68
-
69
- server = Docker.spawn_server_from_fastled_repo(
70
- project_root=project_root, interactive=interactive
71
- )
72
- assert isinstance(server, CompileServer)
63
+ file_watcher_set(False)
64
+ project_root = Path(".").absolute()
65
+ print(f"Building Docker image at {project_root}")
66
+ from fastled import Api, Docker
67
+
68
+ server = Docker.spawn_server_from_fastled_repo(
69
+ project_root=project_root,
70
+ interactive=interactive,
71
+ sketch_folder=directory,
72
+ )
73
+ assert isinstance(server, CompileServer)
73
74
 
75
+ try:
74
76
  if interactive:
75
77
  server.stop()
76
78
  return 0
@@ -82,17 +84,19 @@ def main() -> int:
82
84
  return 0
83
85
 
84
86
  print("Running server")
87
+
85
88
  with Api.live_client(
86
89
  auto_updates=False,
87
90
  sketch_directory=directory,
88
91
  host=server,
89
92
  auto_start=True,
90
93
  keep_running=not just_compile,
91
- ) as client:
92
- print(f"Exited client {client.url()}")
93
- print(f"Exiting {server.name}")
94
+ ) as _:
95
+ while True:
96
+ time.sleep(0.2) # wait for user to exit
94
97
  except KeyboardInterrupt:
95
98
  print("\nExiting from client...")
99
+ server.stop()
96
100
  return 1
97
101
 
98
102
  if has_server:
@@ -106,12 +110,13 @@ def main() -> int:
106
110
  if __name__ == "__main__":
107
111
  # Note that the entry point for the exe is in cli.py
108
112
  try:
109
- sys.argv.append("-i")
113
+ sys.argv.append("-b")
110
114
  # sys.argv.append("examples/wasm")
111
115
  # sys.argv.append()
112
116
  import os
113
117
 
114
118
  os.chdir("../fastled")
119
+ sys.argv.append("examples/wasm")
115
120
  sys.exit(main())
116
121
  except KeyboardInterrupt:
117
122
  print("\nExiting from main...")
@@ -220,7 +220,6 @@ class CompileServerImpl:
220
220
  "mode": "rw",
221
221
  }
222
222
  if self.fastled_src_dir is not None:
223
- # add volume for src/platforms/wasm/compiler/CMakelists.txt
224
223
  # to allow for interactive compilation
225
224
  interactive_sources = list(INTERACTIVE_SOURCES)
226
225
  for src in interactive_sources:
fastled/docker_manager.py CHANGED
@@ -694,7 +694,9 @@ class DockerManager:
694
694
  print("Error decoding line")
695
695
  rtn = proc.wait()
696
696
  if rtn != 0:
697
- print(f"Error building Docker image: {rtn}")
697
+ warnings.warn(
698
+ f"Error building Docker image, is docker running? {rtn}, stdout: {stdout}, stderr: {proc.stderr}"
699
+ )
698
700
  raise subprocess.CalledProcessError(rtn, cmd_str)
699
701
  print(f"Successfully built image {image_name}:{tag}")
700
702
 
@@ -1,5 +1,5 @@
1
1
  INTERACTIVE_SOURCES: list[str] = [
2
- "src/platforms/wasm/compiler/CMakeLists.txt",
3
- "src/platforms/wasm/compiler/build_archive.sh",
4
- "src/platforms/wasm/compiler/build.sh",
2
+ "/js/compiler/CMakeLists.txt",
3
+ "/js/compiler/build_archive.sh",
4
+ "/js/compiler/build.sh",
5
5
  ]
fastled/open_browser.py CHANGED
@@ -45,9 +45,8 @@ def open_http_server_subprocess(
45
45
  stderr=subprocess.DEVNULL,
46
46
  ) # type ignore
47
47
  except KeyboardInterrupt:
48
- import _thread
49
-
50
- _thread.interrupt_main()
48
+ print("Exiting from server...")
49
+ sys.exit(0)
51
50
 
52
51
 
53
52
  def is_port_free(port: int) -> bool:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: fastled
3
- Version: 1.2.39
3
+ Version: 1.2.41
4
4
  Summary: FastLED Wasm Compiler
5
5
  Home-page: https://github.com/zackees/fastled-wasm
6
6
  Maintainer: Zachary Vorhies
@@ -37,6 +37,7 @@ Dynamic: maintainer
37
37
  [![Build Webpage](https://github.com/zackees/fastled-wasm/actions/workflows/build_webpage.yml/badge.svg)](https://github.com/zackees/fastled-wasm/actions/workflows/build_webpage.yml)
38
38
 
39
39
 
40
+
40
41
  ## Compile your FastLED sketch and run it on the Browser!
41
42
 
42
43
  ![image](https://github.com/user-attachments/assets/243aeb4d-e42f-4cc3-9c31-0af51271f3e0)
@@ -293,6 +294,8 @@ A: `delay()` will block `loop()` which blocks the main thread of the browser. Th
293
294
  Q: How can I get the compiled size of my FastLED sketch smaller?
294
295
  A: A big chunk of space is being used by unnecessary javascript `emscripten` bundling. The wasm_compiler_settings.py file in the FastLED repo can tweak this.
295
296
 
297
+
298
+
296
299
  # Revisions
297
300
 
298
301
  * 1.2.31 - Bunch of fixes and ease of use while compiling code in the repo.
@@ -1,15 +1,15 @@
1
- fastled/__init__.py,sha256=G7jKW5FxIFKFHmudUx5d8_BMzncikXsQ8a1O-KvQ0EI,13035
2
- fastled/app.py,sha256=dnbDSVpn7_wB3JZl-JAIROYbmmy0-K1RTyi7CaktKsc,3696
1
+ fastled/__init__.py,sha256=3zpR2cQiWURhu56q_8wGqNj_kL_m7fORfnc3T4x-JHk,13851
2
+ fastled/app.py,sha256=6EE7mRcKKFm1wTyvpk3zy6OtlbHovSlDGU8bSq-Pjws,3763
3
3
  fastled/cli.py,sha256=FjVr31ht0UPlAcmX-84NwfAGMQHTkrCe4o744jCAxiw,375
4
4
  fastled/client_server.py,sha256=Q_-ALIbp474gY1zkYHoaU36eVSIa87nRcSB6IZOoaCg,14315
5
5
  fastled/compile_server.py,sha256=ul3eiZNX2wwmInooo3PJC3_kNpdejYVDIo94G3sV9HQ,2941
6
- fastled/compile_server_impl.py,sha256=vCuy4RlMm1FTJ6Xp6eFjV84xLVtLpdCaStz0N7Bi3n8,9977
7
- fastled/docker_manager.py,sha256=cIxOSeHnDqrT5IWPP1sl1cF8XYy3sUNfoOE-JpuKr3U,29815
6
+ fastled/compile_server_impl.py,sha256=QPCzmSKoAm8rMftuvbxbojCAAcaazXSWFkjPv_UI7vk,9901
7
+ fastled/docker_manager.py,sha256=QRHMdXugaegwOgXix8I0yvkjq2vY3jG8jBbYjnCxLps,29921
8
8
  fastled/filewatcher.py,sha256=XjFTo6NvEaosGTPr2Uhj91aqmtFdYHzJfxPzjBTMkKA,7086
9
- fastled/interactive_srcs.py,sha256=BZJ2IJNzUg4BuE_QWyD_y_xX978clY5CMzTSz8lvFcw,183
9
+ fastled/interactive_srcs.py,sha256=F5nHdJc60xsnmOtnKhngE9JytqGn56PmYw_MVSIX1ac,138
10
10
  fastled/keyboard.py,sha256=vyYxE98WCXjvMpcUJd0YXPVvt7TzvBmifLYI-K7jtKg,3524
11
11
  fastled/live_client.py,sha256=MDauol0mxtXggV1Pv9ahC0Jjg_4wnnV6FjGEtdd9cxU,2763
12
- fastled/open_browser.py,sha256=DDzOXNYVYLIDWVdmpJ-jLxZSAs5mw3VGHo2UIJ-T8SE,4339
12
+ fastled/open_browser.py,sha256=KX2h9PUaPsKcwZ84i01DrXOnNpvaKLpB63u5kzcnEKQ,4342
13
13
  fastled/open_browser2.py,sha256=jUgN81bEYX-sr0zKTVJkwj9tXEVq7aZTxGUP_ShyCbs,3614
14
14
  fastled/parse_args.py,sha256=d0Aa_XPOpTjgxkBPZ_UyG-xNP9PgEjBQgrtzykVBeSc,7887
15
15
  fastled/paths.py,sha256=VsPmgu0lNSCFOoEC0BsTYzDygXqy15AHUfN-tTuzDZA,99
@@ -26,9 +26,9 @@ fastled/assets/example.txt,sha256=lTBovRjiz0_TgtAtbA1C5hNi2ffbqnNPqkKg6UiKCT8,54
26
26
  fastled/site/build.py,sha256=l4RajIk0bApiAifT1lyLjIZi9lpPtSba4cnwWP5UOKc,14064
27
27
  fastled/test/can_run_local_docker_tests.py,sha256=LEuUbHctRhNNFWcvnz2kEGmjDJeXO4c3kNpizm3yVJs,400
28
28
  fastled/test/examples.py,sha256=GfaHeY1E8izBl6ZqDVjz--RHLyVR4NRnQ5pBesCFJFY,1673
29
- fastled-1.2.39.dist-info/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
30
- fastled-1.2.39.dist-info/METADATA,sha256=C9UAsR0nUCIg7wm9qXuLF-NgBs7Ze7L0sOl2-E7nZLw,21261
31
- fastled-1.2.39.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
32
- fastled-1.2.39.dist-info/entry_points.txt,sha256=RCwmzCSOS4-C2i9EziANq7Z2Zb4KFnEMR1FQC0bBwAw,101
33
- fastled-1.2.39.dist-info/top_level.txt,sha256=Bbv5kpJpZhWNCvDF4K0VcvtBSDMa8B7PTOrZa9CezHY,8
34
- fastled-1.2.39.dist-info/RECORD,,
29
+ fastled-1.2.41.dist-info/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
30
+ fastled-1.2.41.dist-info/METADATA,sha256=ZscaHfPqTwVv19ihdqqO6799oW8Q3PN58j6hUEFbAsc,21264
31
+ fastled-1.2.41.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
32
+ fastled-1.2.41.dist-info/entry_points.txt,sha256=RCwmzCSOS4-C2i9EziANq7Z2Zb4KFnEMR1FQC0bBwAw,101
33
+ fastled-1.2.41.dist-info/top_level.txt,sha256=Bbv5kpJpZhWNCvDF4K0VcvtBSDMa8B7PTOrZa9CezHY,8
34
+ fastled-1.2.41.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.8.0)
2
+ Generator: setuptools (75.8.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5