fastled 1.2.35__py3-none-any.whl → 1.2.38__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
@@ -16,7 +16,7 @@ from .types import BuildMode, CompileResult, CompileServerError
16
16
  # IMPORTANT! There's a bug in github which will REJECT any version update
17
17
  # that has any other change in the repo. Please bump the version as the
18
18
  # ONLY change in a commit, or else the pypi update and the release will fail.
19
- __version__ = "1.2.35"
19
+ __version__ = "1.2.38"
20
20
 
21
21
 
22
22
  class Api:
@@ -157,10 +157,10 @@ class Docker:
157
157
  docker_mgr.purge(image_name=IMAGE_NAME)
158
158
 
159
159
  @staticmethod
160
- def build_from_github(
160
+ def spawn_server_from_github(
161
161
  url: str = "https://github.com/fastled/fastled",
162
162
  output_dir: Path | str = Path(".cache/fastled"),
163
- ) -> str:
163
+ ) -> CompileServer:
164
164
  """Build the FastLED WASM compiler Docker image from a GitHub repository.
165
165
 
166
166
  Args:
@@ -252,21 +252,32 @@ class Docker:
252
252
  platform_tag=platform_tag,
253
253
  )
254
254
 
255
- # Run the container and return it
256
- container = docker_mgr.run_container_detached(
257
- image_name=IMAGE_NAME,
258
- tag="main",
255
+ # # Run the container and return it
256
+ # container = docker_mgr.run_container_detached(
257
+ # image_name=IMAGE_NAME,
258
+ # tag="main",
259
+ # container_name=CONTAINER_NAME,
260
+ # command=None, # Use default command from Dockerfile
261
+ # volumes=None, # No volumes needed for build
262
+ # ports=None, # No ports needed for build
263
+ # remove_previous=True, # Remove any existing container
264
+ # )
265
+ # name = container.name
266
+ # container.stop()
267
+
268
+ out: CompileServer = CompileServer(
259
269
  container_name=CONTAINER_NAME,
260
- command=None, # Use default command from Dockerfile
261
- volumes=None, # No volumes needed for build
262
- ports=None, # No ports needed for build
263
- remove_previous=True, # Remove any existing container
270
+ interactive=False,
271
+ auto_updates=False,
272
+ mapped_dir=None,
273
+ auto_start=True,
274
+ remove_previous=True,
264
275
  )
265
276
 
266
- return container.name # Todo, create an external docker container api.
277
+ return out
267
278
 
268
279
  @staticmethod
269
- def build_from_fastled_repo(
280
+ def spawn_server_from_fastled_repo(
270
281
  project_root: Path | str = Path("."),
271
282
  interactive: bool = False,
272
283
  sketch_folder: Path | None = None,
fastled/app.py CHANGED
@@ -2,7 +2,6 @@
2
2
  Uses the latest wasm compiler image to compile the FastLED sketch.
3
3
  """
4
4
 
5
- import argparse
6
5
  import sys
7
6
  import time
8
7
  from pathlib import Path
@@ -10,10 +9,10 @@ from pathlib import Path
10
9
  from fastled.client_server import run_client_server
11
10
  from fastled.compile_server import CompileServer
12
11
  from fastled.filewatcher import file_watcher_set
13
- from fastled.parse_args import parse_args
12
+ from fastled.parse_args import Args, parse_args
14
13
 
15
14
 
16
- def run_server(args: argparse.Namespace) -> int:
15
+ def run_server(args: Args) -> int:
17
16
  interactive = args.interactive
18
17
  auto_update = args.auto_update
19
18
  mapped_dir = Path(args.directory).absolute() if args.directory else None
@@ -46,20 +45,13 @@ def run_server(args: argparse.Namespace) -> int:
46
45
  def main() -> int:
47
46
  args = parse_args()
48
47
  interactive: bool = args.interactive
49
- server: str | CompileServer | None = args.server
48
+ has_server = args.server
50
49
  update: bool = args.update
51
50
  build: bool = args.build
52
51
  just_compile: bool = args.just_compile
53
52
  # directory: Path | None = Path(args.directory).absolute() if args.directory else None
54
53
  directory: Path | None = Path(args.directory) if args.directory else None
55
54
 
56
- # broken for now
57
- if directory is None and interactive:
58
- # if examples/wasm exists
59
- if Path("examples/wasm").exists():
60
- print(f"Using {Path('examples/wasm')} as the sketch directory")
61
- directory = Path("examples/wasm").absolute()
62
-
63
55
  if update:
64
56
  # Force auto_update to ensure update check happens
65
57
  compile_server = CompileServer(interactive=False, auto_updates=True)
@@ -74,7 +66,7 @@ def main() -> int:
74
66
  print(f"Building Docker image at {project_root}")
75
67
  from fastled import Api, Docker
76
68
 
77
- server = Docker.build_from_fastled_repo(
69
+ server = Docker.spawn_server_from_fastled_repo(
78
70
  project_root=project_root, interactive=interactive
79
71
  )
80
72
  assert isinstance(server, CompileServer)
@@ -103,7 +95,7 @@ def main() -> int:
103
95
  print("\nExiting from client...")
104
96
  return 1
105
97
 
106
- if server:
98
+ if has_server:
107
99
  print("Running in server only mode.")
108
100
  return run_server(args)
109
101
  else:
@@ -114,8 +106,8 @@ def main() -> int:
114
106
  if __name__ == "__main__":
115
107
  # Note that the entry point for the exe is in cli.py
116
108
  try:
117
- sys.argv.append("-b")
118
- sys.argv.append("examples/wasm")
109
+ sys.argv.append("-i")
110
+ # sys.argv.append("examples/wasm")
119
111
  # sys.argv.append()
120
112
  import os
121
113
 
fastled/client_server.py CHANGED
@@ -1,4 +1,3 @@
1
- import argparse
2
1
  import shutil
3
2
  import tempfile
4
3
  import threading
@@ -11,6 +10,7 @@ from fastled.docker_manager import DockerManager
11
10
  from fastled.filewatcher import FileWatcherProcess
12
11
  from fastled.keyboard import SpaceBarWatcher
13
12
  from fastled.open_browser import open_browser_process
13
+ from fastled.parse_args import Args
14
14
  from fastled.settings import DEFAULT_URL
15
15
  from fastled.sketch import looks_like_sketch_directory
16
16
  from fastled.types import BuildMode, CompileResult, CompileServerError
@@ -334,12 +334,12 @@ def run_client(
334
334
  browser_proc.kill()
335
335
 
336
336
 
337
- def run_client_server(args: argparse.Namespace) -> int:
337
+ def run_client_server(args: Args) -> int:
338
338
  profile = bool(args.profile)
339
339
  web: str | bool = args.web if isinstance(args.web, str) else bool(args.web)
340
340
  auto_update = bool(args.auto_update)
341
341
  localhost = bool(args.localhost)
342
- directory = Path(args.directory)
342
+ directory = args.directory if args.directory else Path(".")
343
343
  just_compile = bool(args.just_compile)
344
344
  interactive = bool(args.interactive)
345
345
  force_compile = bool(args.force_compile)
fastled/parse_args.py CHANGED
@@ -12,8 +12,10 @@ from fastled.sketch import (
12
12
  looks_like_fastled_repo,
13
13
  looks_like_sketch_directory,
14
14
  )
15
+ from fastled.types import Args
15
16
 
16
- def _find_fastled_repo(start: Path) -> Path:
17
+
18
+ def _find_fastled_repo(start: Path) -> Path | None:
17
19
  """Find the FastLED repo directory by searching upwards from the current directory."""
18
20
  current = start
19
21
  while current != current.parent:
@@ -23,7 +25,7 @@ def _find_fastled_repo(start: Path) -> Path:
23
25
  return None
24
26
 
25
27
 
26
- def parse_args() -> argparse.Namespace:
28
+ def parse_args() -> Args:
27
29
  """Parse command-line arguments."""
28
30
  parser = argparse.ArgumentParser(description=f"FastLED WASM Compiler {__version__}")
29
31
  parser.add_argument("--version", action="version", version=f"{__version__}")
@@ -143,15 +145,17 @@ def parse_args() -> argparse.Namespace:
143
145
  if args.build or args.interactive:
144
146
  cwd: Path = Path(os.getcwd())
145
147
  fastled_dir: Path | None = _find_fastled_repo(cwd)
148
+ if args.directory is not None:
149
+ args.directory = str(Path(args.directory).absolute())
146
150
  if fastled_dir is None:
147
- print(
148
- "This command must be run from within the FastLED repo. Exiting..."
149
- )
151
+ print("This command must be run from within the FastLED repo. Exiting...")
150
152
  sys.exit(1)
151
153
  if cwd != fastled_dir:
152
154
  print(f"Switching to FastLED repo at {fastled_dir}")
153
155
  os.chdir(fastled_dir)
154
- return args
156
+ if args.directory is None:
157
+ args.directory = str(Path("examples/wasm").absolute())
158
+ return Args.from_namespace(args)
155
159
 
156
160
  if not args.update:
157
161
  if args.no_auto_updates:
@@ -214,4 +218,4 @@ def parse_args() -> argparse.Namespace:
214
218
  print(f"Using sketch directory: {dir_path}")
215
219
  args.directory = str(dir_path)
216
220
 
217
- return args
221
+ return Args.from_namespace(args)
fastled/sketch.py CHANGED
@@ -72,7 +72,10 @@ def _lots_and_lots_of_files(directory: Path) -> bool:
72
72
  return len(get_sketch_files(directory)) > 100
73
73
 
74
74
 
75
- def looks_like_sketch_directory(directory: Path, quick=False) -> bool:
75
+ def looks_like_sketch_directory(directory: Path | str | None, quick=False) -> bool:
76
+ if directory is None:
77
+ return False
78
+ directory = Path(directory)
76
79
  if looks_like_fastled_repo(directory):
77
80
  print("Directory looks like the FastLED repo")
78
81
  return False
fastled/types.py CHANGED
@@ -1,9 +1,94 @@
1
1
  import argparse
2
2
  from dataclasses import dataclass
3
3
  from enum import Enum
4
+ from pathlib import Path
4
5
  from typing import Any
5
6
 
6
7
 
8
+ @dataclass
9
+ class Args:
10
+ directory: Path | None
11
+ init: bool | str
12
+ just_compile: bool
13
+ web: str | None
14
+ interactive: bool
15
+ profile: bool
16
+ force_compile: bool
17
+ auto_update: bool | None
18
+ update: bool
19
+ localhost: bool
20
+ build: bool
21
+ server: bool
22
+ purge: bool
23
+ debug: bool
24
+ quick: bool
25
+ release: bool
26
+
27
+ @staticmethod
28
+ def from_namespace(args: argparse.Namespace) -> "Args":
29
+ assert isinstance(
30
+ args.directory, str | None
31
+ ), f"expected str | None, got {type(args.directory)}"
32
+ assert isinstance(
33
+ args.init, bool | str | None
34
+ ), f"expected bool, got {type(args.init)}"
35
+ assert isinstance(
36
+ args.just_compile, bool
37
+ ), f"expected bool, got {type(args.just_compile)}"
38
+ assert isinstance(
39
+ args.web, str | None
40
+ ), f"expected str | None, got {type(args.web)}"
41
+ assert isinstance(
42
+ args.interactive, bool
43
+ ), f"expected bool, got {type(args.interactive)}"
44
+ assert isinstance(
45
+ args.profile, bool
46
+ ), f"expected bool, got {type(args.profile)}"
47
+ assert isinstance(
48
+ args.force_compile, bool
49
+ ), f"expected bool, got {type(args.force_compile)}"
50
+ assert isinstance(
51
+ args.no_auto_updates, bool | None
52
+ ), f"expected bool | None, got {type(args.no_auto_updates)}"
53
+ assert isinstance(args.update, bool), f"expected bool, got {type(args.update)}"
54
+ assert isinstance(
55
+ args.localhost, bool
56
+ ), f"expected bool, got {type(args.localhost)}"
57
+ assert isinstance(args.build, bool), f"expected bool, got {type(args.build)}"
58
+ assert isinstance(args.server, bool), f"expected bool, got {type(args.server)}"
59
+ assert isinstance(args.purge, bool), f"expected bool, got {type(args.purge)}"
60
+ assert isinstance(args.debug, bool), f"expected bool, got {type(args.debug)}"
61
+ assert isinstance(args.quick, bool), f"expected bool, got {type(args.quick)}"
62
+ assert isinstance(
63
+ args.release, bool
64
+ ), f"expected bool, got {type(args.release)}"
65
+ init: bool | str = False
66
+ if args.init is None:
67
+ init = False
68
+ elif isinstance(args.init, bool):
69
+ init = args.init
70
+ elif isinstance(args.init, str):
71
+ init = args.init
72
+ return Args(
73
+ directory=Path(args.directory) if args.directory else None,
74
+ init=init,
75
+ just_compile=args.just_compile,
76
+ web=args.web,
77
+ interactive=args.interactive,
78
+ profile=args.profile,
79
+ force_compile=args.force_compile,
80
+ auto_update=not args.no_auto_updates,
81
+ update=args.update,
82
+ localhost=args.localhost,
83
+ build=args.build,
84
+ server=args.server,
85
+ purge=args.purge,
86
+ debug=args.debug,
87
+ quick=args.quick,
88
+ release=args.release,
89
+ )
90
+
91
+
7
92
  @dataclass
8
93
  class CompileResult:
9
94
  success: bool
@@ -38,7 +123,7 @@ class BuildMode(Enum):
38
123
  raise ValueError(f"BUILD_MODE must be one of {valid_modes}, got {mode_str}")
39
124
 
40
125
  @staticmethod
41
- def from_args(args: argparse.Namespace) -> "BuildMode":
126
+ def from_args(args: Args) -> "BuildMode":
42
127
  if args.debug:
43
128
  return BuildMode.DEBUG
44
129
  elif args.release:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: fastled
3
- Version: 1.2.35
3
+ Version: 1.2.38
4
4
  Summary: FastLED Wasm Compiler
5
5
  Home-page: https://github.com/zackees/fastled-wasm
6
6
  Maintainer: Zachary Vorhies
@@ -211,7 +211,7 @@ with Api.server() as server:
211
211
  **Build Docker Image from a local copy of the FastLED repo**
212
212
  ```python
213
213
  from fastapi import Docker, Api
214
- container_name: str = Docker.build_from_fastled_repo()
214
+ container_name: str = Docker.spawn_server_from_fastled_repo()
215
215
  with Api.server(container_name=container_name) as server:
216
216
  ...
217
217
  ```
@@ -293,7 +293,6 @@ A: `delay()` will block `loop()` which blocks the main thread of the browser. Th
293
293
  Q: How can I get the compiled size of my FastLED sketch smaller?
294
294
  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
295
 
296
-
297
296
  # Revisions
298
297
 
299
298
  * 1.2.31 - Bunch of fixes and ease of use while compiling code in the repo.
@@ -1,7 +1,7 @@
1
- fastled/__init__.py,sha256=Ql0xUlEvxKwunw-Z0RfaWskCjdtSYL-3mys9-hJNRIc,12740
2
- fastled/app.py,sha256=H1V4_BKQTH0jARJZT8zGrabCkREHBxTXSbgZeSOPwuk,4005
1
+ fastled/__init__.py,sha256=EMGIHk8k4c_BU_-hXMaPDntdxPyOQYPIh8jBsBIMwVs,13035
2
+ fastled/app.py,sha256=dnbDSVpn7_wB3JZl-JAIROYbmmy0-K1RTyi7CaktKsc,3696
3
3
  fastled/cli.py,sha256=FjVr31ht0UPlAcmX-84NwfAGMQHTkrCe4o744jCAxiw,375
4
- fastled/client_server.py,sha256=eORWVyI1PvyowmhLWt3V9aI_AemPSBL9bAkjMBD2kAw,14282
4
+ fastled/client_server.py,sha256=Q_-ALIbp474gY1zkYHoaU36eVSIa87nRcSB6IZOoaCg,14315
5
5
  fastled/compile_server.py,sha256=ul3eiZNX2wwmInooo3PJC3_kNpdejYVDIo94G3sV9HQ,2941
6
6
  fastled/compile_server_impl.py,sha256=ygE471lKGidQKYnGNRt-PRYtf3MW1i293QT5ULuOhLE,10048
7
7
  fastled/docker_manager.py,sha256=cIxOSeHnDqrT5IWPP1sl1cF8XYy3sUNfoOE-JpuKr3U,29815
@@ -10,24 +10,24 @@ fastled/keyboard.py,sha256=vyYxE98WCXjvMpcUJd0YXPVvt7TzvBmifLYI-K7jtKg,3524
10
10
  fastled/live_client.py,sha256=MDauol0mxtXggV1Pv9ahC0Jjg_4wnnV6FjGEtdd9cxU,2763
11
11
  fastled/open_browser.py,sha256=DDzOXNYVYLIDWVdmpJ-jLxZSAs5mw3VGHo2UIJ-T8SE,4339
12
12
  fastled/open_browser2.py,sha256=jUgN81bEYX-sr0zKTVJkwj9tXEVq7aZTxGUP_ShyCbs,3614
13
- fastled/parse_args.py,sha256=iwCxYKu6TO7RrWTvE6Dwn-O5ALq2ktDK8Vz_GVulLW0,7643
13
+ fastled/parse_args.py,sha256=d0Aa_XPOpTjgxkBPZ_UyG-xNP9PgEjBQgrtzykVBeSc,7887
14
14
  fastled/paths.py,sha256=VsPmgu0lNSCFOoEC0BsTYzDygXqy15AHUfN-tTuzDZA,99
15
15
  fastled/project_init.py,sha256=bBt4DwmW5hZkm9ICt9Qk-0Nr_0JQM7icCgH5Iv-bCQs,3984
16
16
  fastled/select_sketch_directory.py,sha256=TZdCjl1D7YMKjodMTvDRurPcpAmN3x0TcJxffER2NfM,1314
17
17
  fastled/settings.py,sha256=WwNYzZEGb_fk_25lx03_yIBNGRXWloyRm7FnQhHiJf8,430
18
- fastled/sketch.py,sha256=483TrrIdZJfo1MIu5FkD-V5OGmOfHmsZ2f6VvNsJBJM,3299
18
+ fastled/sketch.py,sha256=tHckjDj8P6BI_LWzUFM071a9qcqPs-r-qFWIe50P5Xw,3391
19
19
  fastled/spinner.py,sha256=VHxmvB92P0Z_zYxRajb5HiNmkHHvZ5dG7hKtZltzpcs,867
20
20
  fastled/string_diff.py,sha256=UR1oRhg9lsPzAG4bn_MwJMCn0evP5AigkBiwLiI9fgA,1354
21
- fastled/types.py,sha256=PpSEtzFCkWtSIEMC0QXGl966R97vLoryVl3yFW0YhTs,1475
21
+ fastled/types.py,sha256=ZFqHxYIGSeQb9FiImA5KDXZLhmmVSjOrIQDduwxmCZw,4494
22
22
  fastled/util.py,sha256=t4M3NFMhnCzfYbLvIyJi0RdFssZqbTN_vVIaej1WV-U,265
23
23
  fastled/web_compile.py,sha256=05PeLJ77QQC6PUKjDhsntBmyBola6QQIfF2k-zjYNE4,10261
24
24
  fastled/assets/example.txt,sha256=lTBovRjiz0_TgtAtbA1C5hNi2ffbqnNPqkKg6UiKCT8,54
25
25
  fastled/site/build.py,sha256=l4RajIk0bApiAifT1lyLjIZi9lpPtSba4cnwWP5UOKc,14064
26
26
  fastled/test/can_run_local_docker_tests.py,sha256=LEuUbHctRhNNFWcvnz2kEGmjDJeXO4c3kNpizm3yVJs,400
27
27
  fastled/test/examples.py,sha256=GfaHeY1E8izBl6ZqDVjz--RHLyVR4NRnQ5pBesCFJFY,1673
28
- fastled-1.2.35.dist-info/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
29
- fastled-1.2.35.dist-info/METADATA,sha256=yF7hZ1fpN2bkPFL3V6xn0yK2BN-skQyhUOwCDYRS3Us,21255
30
- fastled-1.2.35.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
31
- fastled-1.2.35.dist-info/entry_points.txt,sha256=RCwmzCSOS4-C2i9EziANq7Z2Zb4KFnEMR1FQC0bBwAw,101
32
- fastled-1.2.35.dist-info/top_level.txt,sha256=Bbv5kpJpZhWNCvDF4K0VcvtBSDMa8B7PTOrZa9CezHY,8
33
- fastled-1.2.35.dist-info/RECORD,,
28
+ fastled-1.2.38.dist-info/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
29
+ fastled-1.2.38.dist-info/METADATA,sha256=K3BK-FQqkndHCj34Xbr4l09USCoyqlyY2FpExknvFEA,21261
30
+ fastled-1.2.38.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
31
+ fastled-1.2.38.dist-info/entry_points.txt,sha256=RCwmzCSOS4-C2i9EziANq7Z2Zb4KFnEMR1FQC0bBwAw,101
32
+ fastled-1.2.38.dist-info/top_level.txt,sha256=Bbv5kpJpZhWNCvDF4K0VcvtBSDMa8B7PTOrZa9CezHY,8
33
+ fastled-1.2.38.dist-info/RECORD,,