fastled 1.2.29__tar.gz → 1.2.31__tar.gz

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.
Files changed (88) hide show
  1. {fastled-1.2.29 → fastled-1.2.31}/.github/workflows/test_build_exe.yml +1 -1
  2. {fastled-1.2.29 → fastled-1.2.31}/PKG-INFO +2 -1
  3. {fastled-1.2.29 → fastled-1.2.31}/README.md +1 -0
  4. {fastled-1.2.29 → fastled-1.2.31}/src/fastled/__init__.py +62 -21
  5. {fastled-1.2.29 → fastled-1.2.31}/src/fastled/app.py +49 -30
  6. {fastled-1.2.29 → fastled-1.2.31}/src/fastled/compile_server.py +6 -0
  7. {fastled-1.2.29 → fastled-1.2.31}/src/fastled/compile_server_impl.py +6 -2
  8. {fastled-1.2.29 → fastled-1.2.31}/src/fastled/filewatcher.py +14 -2
  9. {fastled-1.2.29 → fastled-1.2.31}/src/fastled/live_client.py +5 -0
  10. {fastled-1.2.29 → fastled-1.2.31}/src/fastled/test/examples.py +1 -0
  11. {fastled-1.2.29 → fastled-1.2.31}/src/fastled.egg-info/PKG-INFO +2 -1
  12. {fastled-1.2.29 → fastled-1.2.31}/src/fastled.egg-info/SOURCES.txt +2 -0
  13. {fastled-1.2.29 → fastled-1.2.31}/tests/test_build.py +5 -5
  14. fastled-1.2.31/tests/test_build_from_docker.py +47 -0
  15. fastled-1.2.31/tests/test_build_from_github.py +46 -0
  16. {fastled-1.2.29 → fastled-1.2.31}/.aiderignore +0 -0
  17. {fastled-1.2.29 → fastled-1.2.31}/.github/workflows/build_multi_docker_image.yml +0 -0
  18. {fastled-1.2.29 → fastled-1.2.31}/.github/workflows/build_webpage.yml +0 -0
  19. {fastled-1.2.29 → fastled-1.2.31}/.github/workflows/lint.yml +0 -0
  20. {fastled-1.2.29 → fastled-1.2.31}/.github/workflows/publish_release.yml +0 -0
  21. {fastled-1.2.29 → fastled-1.2.31}/.github/workflows/test_macos.yml +0 -0
  22. {fastled-1.2.29 → fastled-1.2.31}/.github/workflows/test_ubuntu.yml +0 -0
  23. {fastled-1.2.29 → fastled-1.2.31}/.github/workflows/test_win.yml +0 -0
  24. {fastled-1.2.29 → fastled-1.2.31}/.gitignore +0 -0
  25. {fastled-1.2.29 → fastled-1.2.31}/.pylintrc +0 -0
  26. {fastled-1.2.29 → fastled-1.2.31}/.vscode/launch.json +0 -0
  27. {fastled-1.2.29 → fastled-1.2.31}/.vscode/settings.json +0 -0
  28. {fastled-1.2.29 → fastled-1.2.31}/.vscode/tasks.json +0 -0
  29. {fastled-1.2.29 → fastled-1.2.31}/LICENSE +0 -0
  30. {fastled-1.2.29 → fastled-1.2.31}/MANIFEST.in +0 -0
  31. {fastled-1.2.29 → fastled-1.2.31}/RELEASE.md +0 -0
  32. {fastled-1.2.29 → fastled-1.2.31}/TODO.md +0 -0
  33. {fastled-1.2.29 → fastled-1.2.31}/build_exe.py +0 -0
  34. {fastled-1.2.29 → fastled-1.2.31}/build_site.py +0 -0
  35. {fastled-1.2.29 → fastled-1.2.31}/clean +0 -0
  36. {fastled-1.2.29 → fastled-1.2.31}/install +0 -0
  37. {fastled-1.2.29 → fastled-1.2.31}/install_linux.sh +0 -0
  38. {fastled-1.2.29 → fastled-1.2.31}/lint +0 -0
  39. {fastled-1.2.29 → fastled-1.2.31}/pyproject.toml +0 -0
  40. {fastled-1.2.29 → fastled-1.2.31}/requirements.testing.txt +0 -0
  41. {fastled-1.2.29 → fastled-1.2.31}/setup.cfg +0 -0
  42. {fastled-1.2.29 → fastled-1.2.31}/setup.py +0 -0
  43. {fastled-1.2.29 → fastled-1.2.31}/src/fastled/assets/example.txt +0 -0
  44. {fastled-1.2.29 → fastled-1.2.31}/src/fastled/cli.py +0 -0
  45. {fastled-1.2.29 → fastled-1.2.31}/src/fastled/client_server.py +0 -0
  46. {fastled-1.2.29 → fastled-1.2.31}/src/fastled/docker_manager.py +0 -0
  47. {fastled-1.2.29 → fastled-1.2.31}/src/fastled/keyboard.py +0 -0
  48. {fastled-1.2.29 → fastled-1.2.31}/src/fastled/open_browser.py +0 -0
  49. {fastled-1.2.29 → fastled-1.2.31}/src/fastled/open_browser2.py +0 -0
  50. {fastled-1.2.29 → fastled-1.2.31}/src/fastled/parse_args.py +0 -0
  51. {fastled-1.2.29 → fastled-1.2.31}/src/fastled/paths.py +0 -0
  52. {fastled-1.2.29 → fastled-1.2.31}/src/fastled/project_init.py +0 -0
  53. {fastled-1.2.29 → fastled-1.2.31}/src/fastled/select_sketch_directory.py +0 -0
  54. {fastled-1.2.29 → fastled-1.2.31}/src/fastled/settings.py +0 -0
  55. {fastled-1.2.29 → fastled-1.2.31}/src/fastled/site/build.py +0 -0
  56. {fastled-1.2.29 → fastled-1.2.31}/src/fastled/sketch.py +0 -0
  57. {fastled-1.2.29 → fastled-1.2.31}/src/fastled/spinner.py +0 -0
  58. {fastled-1.2.29 → fastled-1.2.31}/src/fastled/string_diff.py +0 -0
  59. {fastled-1.2.29 → fastled-1.2.31}/src/fastled/test/can_run_local_docker_tests.py +0 -0
  60. {fastled-1.2.29 → fastled-1.2.31}/src/fastled/types.py +0 -0
  61. {fastled-1.2.29 → fastled-1.2.31}/src/fastled/util.py +0 -0
  62. {fastled-1.2.29 → fastled-1.2.31}/src/fastled/web_compile.py +0 -0
  63. {fastled-1.2.29 → fastled-1.2.31}/src/fastled.egg-info/dependency_links.txt +0 -0
  64. {fastled-1.2.29 → fastled-1.2.31}/src/fastled.egg-info/entry_points.txt +0 -0
  65. {fastled-1.2.29 → fastled-1.2.31}/src/fastled.egg-info/requires.txt +0 -0
  66. {fastled-1.2.29 → fastled-1.2.31}/src/fastled.egg-info/top_level.txt +0 -0
  67. {fastled-1.2.29 → fastled-1.2.31}/test +0 -0
  68. {fastled-1.2.29 → fastled-1.2.31}/tests/html/index.html +0 -0
  69. {fastled-1.2.29 → fastled-1.2.31}/tests/test_api.py +0 -0
  70. {fastled-1.2.29 → fastled-1.2.31}/tests/test_bad_ino.py +0 -0
  71. {fastled-1.2.29 → fastled-1.2.31}/tests/test_build_examples.py +0 -0
  72. {fastled-1.2.29 → fastled-1.2.31}/tests/test_cli.py +0 -0
  73. {fastled-1.2.29 → fastled-1.2.31}/tests/test_compile_server.py +0 -0
  74. {fastled-1.2.29 → fastled-1.2.31}/tests/test_docker_linux_on_windows.py +0 -0
  75. {fastled-1.2.29 → fastled-1.2.31}/tests/test_embedded_data.py +0 -0
  76. {fastled-1.2.29 → fastled-1.2.31}/tests/test_examples.py +0 -0
  77. {fastled-1.2.29 → fastled-1.2.31}/tests/test_filechanger.py +0 -0
  78. {fastled-1.2.29 → fastled-1.2.31}/tests/test_http_server.py +0 -0
  79. {fastled-1.2.29 → fastled-1.2.31}/tests/test_ino/bad/bad.ino +0 -0
  80. {fastled-1.2.29 → fastled-1.2.31}/tests/test_ino/bad_platformio/bad_platformio.ino +0 -0
  81. {fastled-1.2.29 → fastled-1.2.31}/tests/test_ino/bad_platformio/platformio.ini +0 -0
  82. {fastled-1.2.29 → fastled-1.2.31}/tests/test_ino/embedded/data/bigdata.dat +0 -0
  83. {fastled-1.2.29 → fastled-1.2.31}/tests/test_ino/embedded/wasm.ino +0 -0
  84. {fastled-1.2.29 → fastled-1.2.31}/tests/test_ino/wasm/wasm.ino +0 -0
  85. {fastled-1.2.29 → fastled-1.2.31}/tests/test_project_init.py +0 -0
  86. {fastled-1.2.29 → fastled-1.2.31}/tests/test_server_and_client_seperatly.py +0 -0
  87. {fastled-1.2.29 → fastled-1.2.31}/tests/test_webcompile.py +0 -0
  88. {fastled-1.2.29 → fastled-1.2.31}/upload_package.sh +0 -0
@@ -46,7 +46,7 @@ jobs:
46
46
  fi
47
47
 
48
48
  - name: Upload artifacts
49
- uses: actions/upload-artifact@v3
49
+ uses: actions/upload-artifact@v4
50
50
  with:
51
51
  name: fastled-${{ matrix.os }}
52
52
  path: |
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: fastled
3
- Version: 1.2.29
3
+ Version: 1.2.31
4
4
  Summary: FastLED Wasm Compiler
5
5
  Home-page: https://github.com/zackees/fastled-wasm
6
6
  Maintainer: Zachary Vorhies
@@ -295,6 +295,7 @@ A: A big chunk of space is being used by unnecessary javascript `emscripten` bun
295
295
 
296
296
  # Revisions
297
297
 
298
+ * 1.2.31 - Bunch of fixes and ease of use while compiling code in the repo.
298
299
  * 1.2.22 - Prefer to use `live-server` from npm. If npm exists on the system then do a background install of `live-server` for next run.
299
300
  * 1.2.20 - Fixed up path issue for web browser launch for hot reload.
300
301
  * 1.2.19 - Compilation failure now overwrites the index.html file with error message.
@@ -269,6 +269,7 @@ A: A big chunk of space is being used by unnecessary javascript `emscripten` bun
269
269
 
270
270
  # Revisions
271
271
 
272
+ * 1.2.31 - Bunch of fixes and ease of use while compiling code in the repo.
272
273
  * 1.2.22 - Prefer to use `live-server` from npm. If npm exists on the system then do a background install of `live-server` for next run.
273
274
  * 1.2.20 - Fixed up path issue for web browser launch for hot reload.
274
275
  * 1.2.19 - Compilation failure now overwrites the index.html file with error message.
@@ -1,6 +1,7 @@
1
1
  """FastLED Wasm Compiler package."""
2
2
 
3
3
  # context
4
+ import shutil
4
5
  import subprocess
5
6
  from contextlib import contextmanager
6
7
  from multiprocessing import Process
@@ -15,7 +16,7 @@ from .types import BuildMode, CompileResult, CompileServerError
15
16
  # IMPORTANT! There's a bug in github which will REJECT any version update
16
17
  # that has any other change in the repo. Please bump the version as the
17
18
  # ONLY change in a commit, or else the pypi update and the release will fail.
18
- __version__ = "1.2.29"
19
+ __version__ = "1.2.31"
19
20
 
20
21
 
21
22
  class Api:
@@ -60,6 +61,7 @@ class Api:
60
61
  def live_client(
61
62
  sketch_directory: Path,
62
63
  host: str | CompileServer | None = None,
64
+ auto_updates: bool = True,
63
65
  auto_start=True,
64
66
  open_web_browser=True,
65
67
  keep_running=True,
@@ -69,6 +71,7 @@ class Api:
69
71
  return LiveClient(
70
72
  sketch_directory=sketch_directory,
71
73
  host=host,
74
+ auto_updates=auto_updates,
72
75
  auto_start=auto_start,
73
76
  open_web_browser=open_web_browser,
74
77
  keep_running=keep_running,
@@ -81,16 +84,20 @@ class Api:
81
84
  interactive=False,
82
85
  auto_updates=None,
83
86
  auto_start=True,
84
- container_name: str | None = None,
87
+ mapped_dir: Path | None = None, # Sketch directory.
88
+ container_name: str | None = None, # Specific docker container name.
89
+ remove_previous: bool = False,
85
90
  ) -> CompileServer:
91
+ """Uses docker to spawn a compile server from the given name."""
86
92
  from fastled.compile_server import CompileServer
87
93
 
88
94
  out = CompileServer(
89
95
  container_name=container_name,
90
96
  interactive=interactive,
91
97
  auto_updates=auto_updates,
92
- mapped_dir=None,
98
+ mapped_dir=mapped_dir,
93
99
  auto_start=auto_start,
100
+ remove_previous=remove_previous,
94
101
  )
95
102
  return out
96
103
 
@@ -100,13 +107,17 @@ class Api:
100
107
  interactive=False,
101
108
  auto_updates=None,
102
109
  auto_start=True,
103
- container_name: str | None = None,
110
+ mapped_dir: Path | None = None, # Sketch directory.
111
+ container_name: str | None = None, # Specific docker container name.
112
+ remove_previous=False,
104
113
  ) -> Generator[CompileServer, None, None]:
105
114
  server = Api.spawn_server(
106
115
  interactive=interactive,
107
116
  auto_updates=auto_updates,
108
117
  auto_start=auto_start,
118
+ mapped_dir=mapped_dir,
109
119
  container_name=container_name,
120
+ remove_previous=remove_previous,
110
121
  )
111
122
  try:
112
123
  yield server
@@ -169,14 +180,37 @@ class Docker:
169
180
  # Create output directory if it doesn't exist
170
181
  output_dir.mkdir(parents=True, exist_ok=True)
171
182
 
183
+ git_dir = output_dir / ".git"
184
+ library_properties = output_dir / "library.properties"
185
+
186
+ git_dir_exists = git_dir.exists()
187
+ library_properties_exists = library_properties.exists()
188
+ library_properties_text = (
189
+ library_properties.read_text().strip() if library_properties_exists else ""
190
+ )
191
+
192
+ already_exists = (
193
+ git_dir_exists
194
+ and library_properties_exists
195
+ and "FastLED" in library_properties_text
196
+ )
197
+ if git_dir_exists and not already_exists:
198
+ if ".cache/fastled" in str(output_dir.as_posix()):
199
+ shutil.rmtree(output_dir)
200
+ already_exists = False
201
+ else:
202
+ raise ValueError(
203
+ f"Output directory {output_dir} already exists but does not appear to be a FastLED repository."
204
+ )
205
+
172
206
  # Clone or update the repository
173
- if (output_dir / ".git").exists():
207
+ if already_exists:
174
208
  print(f"Updating existing repository in {output_dir}")
175
209
  # Reset local changes and move HEAD back to handle force pushes
176
210
  subprocess.run(
177
211
  ["git", "reset", "--hard", "HEAD~10"],
178
212
  cwd=output_dir,
179
- check=True,
213
+ check=False,
180
214
  capture_output=True, # Suppress output of reset
181
215
  )
182
216
  subprocess.run(
@@ -229,12 +263,14 @@ class Docker:
229
263
  remove_previous=True, # Remove any existing container
230
264
  )
231
265
 
232
- return container.name
266
+ return container.name # Todo, create an external docker container api.
233
267
 
234
268
  @staticmethod
235
269
  def build_from_fastled_repo(
236
- project_root: Path | str = Path("."), platform_tag: str = ""
237
- ) -> str:
270
+ project_root: Path | str = Path("."),
271
+ interactive: bool = False,
272
+ sketch_folder: Path | None = None,
273
+ ) -> CompileServer:
238
274
  """Build the FastLED WASM compiler Docker image, which will be tagged as "main".
239
275
 
240
276
  Args:
@@ -247,15 +283,22 @@ class Docker:
247
283
  from fastled.docker_manager import DockerManager
248
284
  from fastled.settings import CONTAINER_NAME, IMAGE_NAME
249
285
 
286
+ project_root = Path(project_root)
287
+ if interactive:
288
+ if sketch_folder is None:
289
+ sketch_folder = project_root / "examples" / "wasm"
290
+ else:
291
+ if sketch_folder is not None:
292
+ raise ValueError(
293
+ "Cannot specify sketch_folder when not in interactive mode."
294
+ )
250
295
  if isinstance(project_root, str):
251
296
  project_root = Path(project_root)
252
297
 
253
298
  dockerfile_path = (
254
299
  project_root / "src" / "platforms" / "wasm" / "compiler" / "Dockerfile"
255
300
  )
256
-
257
301
  docker_mgr = DockerManager()
258
-
259
302
  platform_tag = ""
260
303
  # if "arm" in docker_mgr.architecture():
261
304
  if (
@@ -277,18 +320,16 @@ class Docker:
277
320
  platform_tag=platform_tag,
278
321
  )
279
322
 
280
- # Run the container and return it
281
- container = docker_mgr.run_container_detached(
282
- image_name=IMAGE_NAME,
283
- tag="main",
323
+ out: CompileServer = CompileServer(
284
324
  container_name=CONTAINER_NAME,
285
- command=None, # Use default command from Dockerfile
286
- volumes=None, # No volumes needed for build
287
- ports=None, # No ports needed for build
288
- remove_previous=True, # Remove any existing container
325
+ interactive=interactive,
326
+ auto_updates=False,
327
+ mapped_dir=sketch_folder,
328
+ auto_start=True,
329
+ remove_previous=True,
289
330
  )
290
- container_name = f"{container.name}"
291
- return container_name
331
+
332
+ return out
292
333
 
293
334
 
294
335
  class Tools:
@@ -7,8 +7,9 @@ import sys
7
7
  import time
8
8
  from pathlib import Path
9
9
 
10
- from fastled.client_server import run_client, run_client_server
10
+ from fastled.client_server import run_client_server
11
11
  from fastled.compile_server import CompileServer
12
+ from fastled.filewatcher import file_watcher_set
12
13
  from fastled.parse_args import parse_args
13
14
 
14
15
 
@@ -44,53 +45,65 @@ def run_server(args: argparse.Namespace) -> int:
44
45
 
45
46
  def main() -> int:
46
47
  args = parse_args()
47
- if args.update:
48
+ interactive: bool = args.interactive
49
+ server: str | CompileServer | None = args.server
50
+ update: bool = args.update
51
+ build: bool = args.build
52
+ just_compile: bool = args.just_compile
53
+ # directory: Path | None = Path(args.directory).absolute() if args.directory else None
54
+ directory: Path | None = Path(args.directory) if args.directory else None
55
+
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
+ if update:
48
64
  # Force auto_update to ensure update check happens
49
65
  compile_server = CompileServer(interactive=False, auto_updates=True)
50
66
  compile_server.stop()
51
67
  print("Finished updating.")
52
68
  return 0
53
69
 
54
- if args.build:
70
+ if build:
55
71
  try:
72
+ file_watcher_set(False)
56
73
  project_root = Path(".").absolute()
57
74
  print(f"Building Docker image at {project_root}")
58
75
  from fastled import Api, Docker
59
76
 
60
- docker_image_name = Docker.build_from_fastled_repo(
61
- project_root=project_root
77
+ server = Docker.build_from_fastled_repo(
78
+ project_root=project_root, interactive=interactive
62
79
  )
63
- print(f"Built Docker image: {docker_image_name}")
64
- if not args.directory:
65
- print("No sketch directory specified. So exiting...")
80
+ assert isinstance(server, CompileServer)
81
+
82
+ if interactive:
83
+ server.stop()
66
84
  return 0
85
+ print(f"Built Docker image: {server.name}")
86
+ if not directory:
87
+ if not directory:
88
+ print("No directory specified")
89
+ server.stop()
90
+ return 0
91
+
67
92
  print("Running server")
68
- with Api.server(
69
- auto_updates=False, container_name=docker_image_name
70
- ) as server:
71
- sketch_dir = Path("examples/wasm")
72
- if args.just_compile:
73
- rtn = run_client(
74
- directory=sketch_dir,
75
- host=server,
76
- open_web_browser=False,
77
- keep_running=False,
78
- )
79
- if rtn != 0:
80
- print(f"Failed to compile: {rtn})")
81
- return rtn
82
- print(f"Server started at {server.url()}")
83
- with Api.live_client(
84
- sketch_directory=sketch_dir, host=server
85
- ) as client:
86
- print(f"Client started at {client.url()}")
87
- while True:
88
- time.sleep(0.1)
93
+ with Api.live_client(
94
+ auto_updates=False,
95
+ sketch_directory=directory,
96
+ host=server,
97
+ auto_start=True,
98
+ keep_running=not just_compile,
99
+ ) as client:
100
+ print(f"Exited client {client.url()}")
101
+ print(f"Exiting {server.name}")
89
102
  except KeyboardInterrupt:
90
103
  print("\nExiting from client...")
91
104
  return 1
92
105
 
93
- if args.server:
106
+ if server:
94
107
  print("Running in server only mode.")
95
108
  return run_server(args)
96
109
  else:
@@ -101,6 +114,12 @@ def main() -> int:
101
114
  if __name__ == "__main__":
102
115
  # Note that the entry point for the exe is in cli.py
103
116
  try:
117
+ sys.argv.append("-b")
118
+ sys.argv.append("examples/wasm")
119
+ # sys.argv.append()
120
+ import os
121
+
122
+ os.chdir("../fastled")
104
123
  sys.exit(main())
105
124
  except KeyboardInterrupt:
106
125
  print("\nExiting from main...")
@@ -14,6 +14,7 @@ class CompileServer:
14
14
  auto_start: bool = True,
15
15
  container_name: str | None = None,
16
16
  platform: Platform = Platform.WASM,
17
+ remove_previous: bool = False,
17
18
  ) -> None:
18
19
  from fastled.compile_server_impl import ( # avoid circular import
19
20
  CompileServerImpl,
@@ -27,6 +28,7 @@ class CompileServer:
27
28
  auto_updates=auto_updates,
28
29
  mapped_dir=mapped_dir,
29
30
  auto_start=auto_start,
31
+ remove_previous=remove_previous,
30
32
  )
31
33
 
32
34
  # May throw CompileServerError if server could not be started.
@@ -51,6 +53,10 @@ class CompileServer:
51
53
 
52
54
  project_init(example=example, outputdir=outputdir)
53
55
 
56
+ @property
57
+ def name(self) -> str:
58
+ return self.impl.container_name
59
+
54
60
  @property
55
61
  def running(self) -> bool:
56
62
  return self.impl.running
@@ -42,6 +42,7 @@ class CompileServerImpl:
42
42
  mapped_dir: Path | None = None,
43
43
  auto_start: bool = True,
44
44
  container_name: str | None = None,
45
+ remove_previous: bool = False,
45
46
  ) -> None:
46
47
  container_name = container_name or DEFAULT_CONTAINER_NAME
47
48
  if interactive and not mapped_dir:
@@ -49,7 +50,9 @@ class CompileServerImpl:
49
50
  "Interactive mode requires a mapped directory point to a sketch"
50
51
  )
51
52
  if not interactive and mapped_dir:
52
- raise ValueError("Mapped directory is only used in interactive mode")
53
+ warnings.warn(
54
+ f"Mapped directory {mapped_dir} is ignored in non-interactive mode"
55
+ )
53
56
  self.container_name = container_name
54
57
  self.mapped_dir = mapped_dir
55
58
  self.docker = DockerManager()
@@ -57,6 +60,7 @@ class CompileServerImpl:
57
60
  self.interactive = interactive
58
61
  self.running_container: RunningContainer | None = None
59
62
  self.auto_updates = auto_updates
63
+ self.remove_previous = remove_previous
60
64
  self._port = 0 # 0 until compile server is started
61
65
  if auto_start:
62
66
  self.start()
@@ -242,7 +246,7 @@ class CompileServerImpl:
242
246
  command=cmd_str,
243
247
  ports=ports,
244
248
  volumes=volumes,
245
- remove_previous=self.interactive,
249
+ remove_previous=self.interactive or self.remove_previous,
246
250
  )
247
251
  self.running_container = self.docker.attach_and_run(container)
248
252
  assert self.running_container is not None, "Container should be running"
@@ -1,5 +1,4 @@
1
- """File system watcher implementation using watchdog
2
- """
1
+ """File system watcher implementation using watchdog"""
3
2
 
4
3
  import hashlib
5
4
  import os
@@ -17,6 +16,16 @@ from watchdog.observers import Observer
17
16
  from watchdog.observers.api import BaseObserver
18
17
 
19
18
 
19
+ def file_watcher_enabled() -> bool:
20
+ """Check if watchdog is disabled"""
21
+ return os.getenv("NO_FILE_WATCHING", "0") == "1"
22
+
23
+
24
+ def file_watcher_set(enabled: bool) -> None:
25
+ """Set the file watcher enabled state"""
26
+ os.environ["NO_FILE_WATCHING"] = "1" if not enabled else "0"
27
+
28
+
20
29
  class MyEventHandler(FileSystemEventHandler):
21
30
  def __init__(
22
31
  self,
@@ -120,6 +129,9 @@ class FileChangedNotifier(threading.Thread):
120
129
  Returns:
121
130
  Changed filepath or None if no change within timeout
122
131
  """
132
+ if file_watcher_enabled():
133
+ time.sleep(timeout)
134
+ return None
123
135
  try:
124
136
  filepath = self.change_queue.get(timeout=timeout)
125
137
  current_time = time.time()
@@ -1,4 +1,5 @@
1
1
  import threading
2
+ import warnings
2
3
  from pathlib import Path
3
4
 
4
5
  from fastled.compile_server import CompileServer
@@ -13,6 +14,7 @@ class LiveClient:
13
14
  sketch_directory: Path,
14
15
  host: str | CompileServer | None = None,
15
16
  auto_start: bool = True,
17
+ auto_updates: bool = True,
16
18
  open_web_browser: bool = True,
17
19
  keep_running: bool = True,
18
20
  build_mode: BuildMode = BuildMode.QUICK,
@@ -27,8 +29,11 @@ class LiveClient:
27
29
  self.auto_start = auto_start
28
30
  self.shutdown = threading.Event()
29
31
  self.thread: threading.Thread | None = None
32
+ self.auto_updates = auto_updates
30
33
  if auto_start:
31
34
  self.start()
35
+ if self.auto_updates is False:
36
+ warnings.warn("Auto updates False are not supported yet.")
32
37
 
33
38
  def run(self) -> int:
34
39
  """Run the client."""
@@ -32,6 +32,7 @@ def test_examples(
32
32
  print(f"Compilation took: {diff:.2f} seconds")
33
33
  result = Api.web_compile(sketch_dir, host=host)
34
34
  if not result.success:
35
+ print(f"Compilation failed for {example}: {result.stdout}")
35
36
  out[example] = Exception(result.stdout)
36
37
  return out
37
38
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: fastled
3
- Version: 1.2.29
3
+ Version: 1.2.31
4
4
  Summary: FastLED Wasm Compiler
5
5
  Home-page: https://github.com/zackees/fastled-wasm
6
6
  Maintainer: Zachary Vorhies
@@ -295,6 +295,7 @@ A: A big chunk of space is being used by unnecessary javascript `emscripten` bun
295
295
 
296
296
  # Revisions
297
297
 
298
+ * 1.2.31 - Bunch of fixes and ease of use while compiling code in the repo.
298
299
  * 1.2.22 - Prefer to use `live-server` from npm. If npm exists on the system then do a background install of `live-server` for next run.
299
300
  * 1.2.20 - Fixed up path issue for web browser launch for hot reload.
300
301
  * 1.2.19 - Compilation failure now overwrites the index.html file with error message.
@@ -65,6 +65,8 @@ tests/test_api.py
65
65
  tests/test_bad_ino.py
66
66
  tests/test_build.py
67
67
  tests/test_build_examples.py
68
+ tests/test_build_from_docker.py
69
+ tests/test_build_from_github.py
68
70
  tests/test_cli.py
69
71
  tests/test_compile_server.py
70
72
  tests/test_docker_linux_on_windows.py
@@ -35,11 +35,11 @@ class BuildDockerFromRepoTester(unittest.TestCase):
35
35
  def test_build_docker(self) -> None:
36
36
  """Builds the docker file from the fastled repo."""
37
37
 
38
- docker_image_name = Docker.build_from_fastled_repo(FASTLED_SISTER_REPO)
39
- self.assertTrue(docker_image_name, "Failed to build docker image")
40
- server: CompileServer
41
- with Api.server(auto_updates=True, container_name=docker_image_name) as server:
42
- self.assertTrue(server.ping())
38
+ container = Docker.build_from_fastled_repo(FASTLED_SISTER_REPO)
39
+ try:
40
+ self.assertTrue(container.ping())
41
+ finally:
42
+ container.stop()
43
43
 
44
44
  @unittest.skipUnless(_enabled(), "Skipping test on non-Linux system on github")
45
45
  def test_build_docker_from_github(self) -> None:
@@ -0,0 +1,47 @@
1
+ """
2
+ Unit test file.
3
+ """
4
+
5
+ import unittest
6
+ from pathlib import Path
7
+
8
+ from fastled import CompileServer, Docker, Test
9
+
10
+ HERE = Path(__file__).parent
11
+ PROJECT_ROOT = HERE.parent
12
+ FASTLED_SISTER_REPO = PROJECT_ROOT / ".." / "FastLED"
13
+
14
+ DEFAULT_GITHUB_URL = "https://github.com/fastled/fastled"
15
+ OUTPUT_DIR = Path(".cache/fastled")
16
+
17
+
18
+ def _enabled() -> bool:
19
+ """Check if this system can run the tests."""
20
+ sister_repo_does_not_exist = not FASTLED_SISTER_REPO.exists()
21
+
22
+ if sister_repo_does_not_exist:
23
+ print(
24
+ f"This test is only enable when FastLED is a repo in the same directly as the project root folder: {FASTLED_SISTER_REPO} does not exist"
25
+ )
26
+ return False
27
+
28
+ return Test.can_run_local_docker_tests()
29
+
30
+
31
+ class BuildDockerFromRepoTester(unittest.TestCase):
32
+ """Main tester class."""
33
+
34
+ @unittest.skipUnless(_enabled(), "Skipping test on non-Linux system on github")
35
+ def test_build_docker(self) -> None:
36
+ """Builds the docker file from the fastled repo."""
37
+ server: CompileServer = Docker.build_from_fastled_repo(FASTLED_SISTER_REPO)
38
+ self.assertIsNotNone(server, "Failed to build docker image")
39
+
40
+ try:
41
+ self.assertTrue(server.ping())
42
+ finally:
43
+ server.stop()
44
+
45
+
46
+ if __name__ == "__main__":
47
+ unittest.main()
@@ -0,0 +1,46 @@
1
+ """
2
+ Unit test file.
3
+ """
4
+
5
+ import unittest
6
+ from pathlib import Path
7
+
8
+ from fastled import Api, CompileServer, Docker, Test # type: ignore
9
+
10
+ HERE = Path(__file__).parent
11
+ PROJECT_ROOT = HERE.parent
12
+ FASTLED_SISTER_REPO = PROJECT_ROOT / ".." / "FastLED"
13
+
14
+ DEFAULT_GITHUB_URL = "https://github.com/fastled/fastled"
15
+ OUTPUT_DIR = Path(".cache/fastled")
16
+
17
+
18
+ def _enabled() -> bool:
19
+ """Check if this system can run the tests."""
20
+ sister_repo_does_not_exist = not FASTLED_SISTER_REPO.exists()
21
+
22
+ if sister_repo_does_not_exist:
23
+ print(
24
+ f"This test is only enable when FastLED is a repo in the same directly as the project root folder: {FASTLED_SISTER_REPO} does not exist"
25
+ )
26
+ return False
27
+
28
+ return Test.can_run_local_docker_tests()
29
+
30
+
31
+ class BuildDockerFromGithubTester(unittest.TestCase):
32
+
33
+ @unittest.skipUnless(_enabled(), "Skipping test on non-Linux system on github")
34
+ def test_build_docker_from_github(self) -> None:
35
+ """Builds the docker file from the fastled repo."""
36
+ url = DEFAULT_GITHUB_URL
37
+ print("Building from github")
38
+ docker_image_name = Docker.build_from_github(url=url, output_dir=OUTPUT_DIR)
39
+ self.assertTrue(docker_image_name, "Failed to build docker image")
40
+ server: CompileServer
41
+ with Api.server(auto_updates=True, container_name=docker_image_name) as server:
42
+ self.assertTrue(server.ping())
43
+
44
+
45
+ if __name__ == "__main__":
46
+ unittest.main()
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes