fastled 1.2.35__tar.gz → 1.2.38__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.
- {fastled-1.2.35 → fastled-1.2.38}/PKG-INFO +2 -3
- {fastled-1.2.35 → fastled-1.2.38}/README.md +1 -2
- {fastled-1.2.35 → fastled-1.2.38}/src/fastled/__init__.py +24 -13
- {fastled-1.2.35 → fastled-1.2.38}/src/fastled/app.py +7 -15
- {fastled-1.2.35 → fastled-1.2.38}/src/fastled/client_server.py +3 -3
- {fastled-1.2.35 → fastled-1.2.38}/src/fastled/parse_args.py +11 -7
- {fastled-1.2.35 → fastled-1.2.38}/src/fastled/sketch.py +4 -1
- fastled-1.2.38/src/fastled/types.py +146 -0
- {fastled-1.2.35 → fastled-1.2.38}/src/fastled.egg-info/PKG-INFO +2 -3
- {fastled-1.2.35 → fastled-1.2.38}/src/fastled.egg-info/SOURCES.txt +0 -1
- {fastled-1.2.35 → fastled-1.2.38}/tests/test_build_from_docker.py +3 -1
- {fastled-1.2.35 → fastled-1.2.38}/tests/test_build_from_github.py +8 -5
- {fastled-1.2.35 → fastled-1.2.38}/tests/test_http_server.py +12 -4
- fastled-1.2.35/src/fastled/types.py +0 -61
- fastled-1.2.35/tests/test_build.py +0 -57
- {fastled-1.2.35 → fastled-1.2.38}/.aiderignore +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/.github/workflows/build_multi_docker_image.yml +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/.github/workflows/build_webpage.yml +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/.github/workflows/lint.yml +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/.github/workflows/publish_release.yml +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/.github/workflows/test_build_exe.yml +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/.github/workflows/test_macos.yml +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/.github/workflows/test_ubuntu.yml +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/.github/workflows/test_win.yml +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/.gitignore +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/.pylintrc +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/.vscode/launch.json +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/.vscode/settings.json +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/.vscode/tasks.json +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/LICENSE +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/MANIFEST.in +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/RELEASE.md +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/TODO.md +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/build_exe.py +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/build_site.py +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/clean +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/install +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/install_linux.sh +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/lint +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/pyproject.toml +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/requirements.testing.txt +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/setup.cfg +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/setup.py +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/src/fastled/assets/example.txt +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/src/fastled/cli.py +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/src/fastled/compile_server.py +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/src/fastled/compile_server_impl.py +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/src/fastled/docker_manager.py +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/src/fastled/filewatcher.py +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/src/fastled/keyboard.py +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/src/fastled/live_client.py +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/src/fastled/open_browser.py +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/src/fastled/open_browser2.py +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/src/fastled/paths.py +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/src/fastled/project_init.py +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/src/fastled/select_sketch_directory.py +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/src/fastled/settings.py +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/src/fastled/site/build.py +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/src/fastled/spinner.py +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/src/fastled/string_diff.py +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/src/fastled/test/can_run_local_docker_tests.py +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/src/fastled/test/examples.py +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/src/fastled/util.py +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/src/fastled/web_compile.py +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/src/fastled.egg-info/dependency_links.txt +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/src/fastled.egg-info/entry_points.txt +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/src/fastled.egg-info/requires.txt +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/src/fastled.egg-info/top_level.txt +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/test +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/tests/html/index.html +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/tests/test_api.py +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/tests/test_bad_ino.py +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/tests/test_build_examples.py +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/tests/test_cli.py +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/tests/test_compile_server.py +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/tests/test_docker_linux_on_windows.py +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/tests/test_embedded_data.py +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/tests/test_examples.py +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/tests/test_filechanger.py +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/tests/test_ino/bad/bad.ino +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/tests/test_ino/bad_platformio/bad_platformio.ino +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/tests/test_ino/bad_platformio/platformio.ini +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/tests/test_ino/embedded/data/bigdata.dat +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/tests/test_ino/embedded/wasm.ino +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/tests/test_ino/wasm/wasm.ino +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/tests/test_project_init.py +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/tests/test_server_and_client_seperatly.py +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/tests/test_webcompile.py +0 -0
- {fastled-1.2.35 → fastled-1.2.38}/upload_package.sh +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: fastled
|
3
|
-
Version: 1.2.
|
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.
|
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.
|
@@ -185,7 +185,7 @@ with Api.server() as server:
|
|
185
185
|
**Build Docker Image from a local copy of the FastLED repo**
|
186
186
|
```python
|
187
187
|
from fastapi import Docker, Api
|
188
|
-
container_name: str = Docker.
|
188
|
+
container_name: str = Docker.spawn_server_from_fastled_repo()
|
189
189
|
with Api.server(container_name=container_name) as server:
|
190
190
|
...
|
191
191
|
```
|
@@ -267,7 +267,6 @@ A: `delay()` will block `loop()` which blocks the main thread of the browser. Th
|
|
267
267
|
Q: How can I get the compiled size of my FastLED sketch smaller?
|
268
268
|
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.
|
269
269
|
|
270
|
-
|
271
270
|
# Revisions
|
272
271
|
|
273
272
|
* 1.2.31 - Bunch of fixes and ease of use while compiling code in the repo.
|
@@ -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.
|
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
|
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
|
-
) ->
|
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
|
-
|
258
|
-
|
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
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
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
|
277
|
+
return out
|
267
278
|
|
268
279
|
@staticmethod
|
269
|
-
def
|
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,
|
@@ -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:
|
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
|
-
|
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.
|
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
|
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("-
|
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
|
|
@@ -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:
|
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(
|
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)
|
@@ -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
|
-
|
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() ->
|
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
|
-
|
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)
|
@@ -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
|
@@ -0,0 +1,146 @@
|
|
1
|
+
import argparse
|
2
|
+
from dataclasses import dataclass
|
3
|
+
from enum import Enum
|
4
|
+
from pathlib import Path
|
5
|
+
from typing import Any
|
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
|
+
|
92
|
+
@dataclass
|
93
|
+
class CompileResult:
|
94
|
+
success: bool
|
95
|
+
stdout: str
|
96
|
+
hash_value: str | None
|
97
|
+
zip_bytes: bytes
|
98
|
+
|
99
|
+
def __bool__(self) -> bool:
|
100
|
+
return self.success
|
101
|
+
|
102
|
+
def to_dict(self) -> dict[str, Any]:
|
103
|
+
return self.__dict__.copy()
|
104
|
+
|
105
|
+
|
106
|
+
class CompileServerError(Exception):
|
107
|
+
"""Error class for failing to instantiate CompileServer."""
|
108
|
+
|
109
|
+
pass
|
110
|
+
|
111
|
+
|
112
|
+
class BuildMode(Enum):
|
113
|
+
DEBUG = "DEBUG"
|
114
|
+
QUICK = "QUICK"
|
115
|
+
RELEASE = "RELEASE"
|
116
|
+
|
117
|
+
@classmethod
|
118
|
+
def from_string(cls, mode_str: str) -> "BuildMode":
|
119
|
+
try:
|
120
|
+
return cls[mode_str.upper()]
|
121
|
+
except KeyError:
|
122
|
+
valid_modes = [mode.name for mode in cls]
|
123
|
+
raise ValueError(f"BUILD_MODE must be one of {valid_modes}, got {mode_str}")
|
124
|
+
|
125
|
+
@staticmethod
|
126
|
+
def from_args(args: Args) -> "BuildMode":
|
127
|
+
if args.debug:
|
128
|
+
return BuildMode.DEBUG
|
129
|
+
elif args.release:
|
130
|
+
return BuildMode.RELEASE
|
131
|
+
else:
|
132
|
+
return BuildMode.QUICK
|
133
|
+
|
134
|
+
|
135
|
+
class Platform(Enum):
|
136
|
+
WASM = "WASM"
|
137
|
+
|
138
|
+
@classmethod
|
139
|
+
def from_string(cls, platform_str: str) -> "Platform":
|
140
|
+
try:
|
141
|
+
return cls[platform_str.upper()]
|
142
|
+
except KeyError:
|
143
|
+
valid_modes = [mode.name for mode in cls]
|
144
|
+
raise ValueError(
|
145
|
+
f"Platform must be one of {valid_modes}, got {platform_str}"
|
146
|
+
)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: fastled
|
3
|
-
Version: 1.2.
|
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.
|
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.
|
@@ -34,7 +34,9 @@ class BuildDockerFromRepoTester(unittest.TestCase):
|
|
34
34
|
@unittest.skipUnless(_enabled(), "Skipping test on non-Linux system on github")
|
35
35
|
def test_build_docker(self) -> None:
|
36
36
|
"""Builds the docker file from the fastled repo."""
|
37
|
-
server: CompileServer = Docker.
|
37
|
+
server: CompileServer = Docker.spawn_server_from_fastled_repo(
|
38
|
+
FASTLED_SISTER_REPO
|
39
|
+
)
|
38
40
|
self.assertIsNotNone(server, "Failed to build docker image")
|
39
41
|
|
40
42
|
try:
|
@@ -5,7 +5,7 @@ Unit test file.
|
|
5
5
|
import unittest
|
6
6
|
from pathlib import Path
|
7
7
|
|
8
|
-
from fastled import
|
8
|
+
from fastled import CompileServer, Docker, Test # type: ignore
|
9
9
|
|
10
10
|
HERE = Path(__file__).parent
|
11
11
|
PROJECT_ROOT = HERE.parent
|
@@ -35,11 +35,14 @@ class BuildDockerFromGithubTester(unittest.TestCase):
|
|
35
35
|
"""Builds the docker file from the fastled repo."""
|
36
36
|
url = DEFAULT_GITHUB_URL
|
37
37
|
print("Building from github")
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
38
|
+
server: CompileServer = Docker.spawn_server_from_github(
|
39
|
+
url=url, output_dir=OUTPUT_DIR
|
40
|
+
)
|
41
|
+
self.assertTrue(server, "Failed to build docker image")
|
42
|
+
try:
|
42
43
|
self.assertTrue(server.ping())
|
44
|
+
finally:
|
45
|
+
server.stop()
|
43
46
|
|
44
47
|
|
45
48
|
if __name__ == "__main__":
|
@@ -2,6 +2,7 @@
|
|
2
2
|
Unit test file.
|
3
3
|
"""
|
4
4
|
|
5
|
+
import random
|
5
6
|
import unittest
|
6
7
|
from pathlib import Path
|
7
8
|
|
@@ -16,20 +17,27 @@ TIMEOUT = 120
|
|
16
17
|
assert INDEX_HTML.exists()
|
17
18
|
|
18
19
|
|
20
|
+
# realistic range, 8021 - 8030
|
21
|
+
PORT = random.randint(8021, 8030)
|
22
|
+
PORT2 = PORT + 1
|
23
|
+
|
24
|
+
|
19
25
|
class HttpServerTester(unittest.TestCase):
|
20
26
|
"""Main tester class."""
|
21
27
|
|
22
28
|
def test_http_server(self) -> None:
|
23
29
|
"""Test the http server."""
|
24
|
-
|
25
|
-
|
30
|
+
port = PORT
|
31
|
+
proc = Test.spawn_http_server(INDEX_HTML.parent, port=port, open_browser=False)
|
32
|
+
response = httpx.get(f"http://localhost:{port}", timeout=1)
|
26
33
|
self.assertEqual(response.status_code, 200)
|
27
34
|
proc.terminate()
|
28
35
|
|
29
36
|
def test_http_server_404(self) -> None:
|
30
37
|
"""Test the http server returns 404 for non-existent files."""
|
31
|
-
|
32
|
-
|
38
|
+
port = PORT2
|
39
|
+
proc = Test.spawn_http_server(INDEX_HTML.parent, port=port, open_browser=False)
|
40
|
+
response = httpx.get(f"http://localhost:{port}/nonexistent.html", timeout=1)
|
33
41
|
self.assertEqual(response.status_code, 404)
|
34
42
|
proc.terminate()
|
35
43
|
|
@@ -1,61 +0,0 @@
|
|
1
|
-
import argparse
|
2
|
-
from dataclasses import dataclass
|
3
|
-
from enum import Enum
|
4
|
-
from typing import Any
|
5
|
-
|
6
|
-
|
7
|
-
@dataclass
|
8
|
-
class CompileResult:
|
9
|
-
success: bool
|
10
|
-
stdout: str
|
11
|
-
hash_value: str | None
|
12
|
-
zip_bytes: bytes
|
13
|
-
|
14
|
-
def __bool__(self) -> bool:
|
15
|
-
return self.success
|
16
|
-
|
17
|
-
def to_dict(self) -> dict[str, Any]:
|
18
|
-
return self.__dict__.copy()
|
19
|
-
|
20
|
-
|
21
|
-
class CompileServerError(Exception):
|
22
|
-
"""Error class for failing to instantiate CompileServer."""
|
23
|
-
|
24
|
-
pass
|
25
|
-
|
26
|
-
|
27
|
-
class BuildMode(Enum):
|
28
|
-
DEBUG = "DEBUG"
|
29
|
-
QUICK = "QUICK"
|
30
|
-
RELEASE = "RELEASE"
|
31
|
-
|
32
|
-
@classmethod
|
33
|
-
def from_string(cls, mode_str: str) -> "BuildMode":
|
34
|
-
try:
|
35
|
-
return cls[mode_str.upper()]
|
36
|
-
except KeyError:
|
37
|
-
valid_modes = [mode.name for mode in cls]
|
38
|
-
raise ValueError(f"BUILD_MODE must be one of {valid_modes}, got {mode_str}")
|
39
|
-
|
40
|
-
@staticmethod
|
41
|
-
def from_args(args: argparse.Namespace) -> "BuildMode":
|
42
|
-
if args.debug:
|
43
|
-
return BuildMode.DEBUG
|
44
|
-
elif args.release:
|
45
|
-
return BuildMode.RELEASE
|
46
|
-
else:
|
47
|
-
return BuildMode.QUICK
|
48
|
-
|
49
|
-
|
50
|
-
class Platform(Enum):
|
51
|
-
WASM = "WASM"
|
52
|
-
|
53
|
-
@classmethod
|
54
|
-
def from_string(cls, platform_str: str) -> "Platform":
|
55
|
-
try:
|
56
|
-
return cls[platform_str.upper()]
|
57
|
-
except KeyError:
|
58
|
-
valid_modes = [mode.name for mode in cls]
|
59
|
-
raise ValueError(
|
60
|
-
f"Platform must be one of {valid_modes}, got {platform_str}"
|
61
|
-
)
|
@@ -1,57 +0,0 @@
|
|
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 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
|
-
|
38
|
-
container = Docker.build_from_fastled_repo(FASTLED_SISTER_REPO)
|
39
|
-
try:
|
40
|
-
self.assertTrue(container.ping())
|
41
|
-
finally:
|
42
|
-
container.stop()
|
43
|
-
|
44
|
-
@unittest.skipUnless(_enabled(), "Skipping test on non-Linux system on github")
|
45
|
-
def test_build_docker_from_github(self) -> None:
|
46
|
-
"""Builds the docker file from the fastled repo."""
|
47
|
-
url = DEFAULT_GITHUB_URL
|
48
|
-
print("Building from github")
|
49
|
-
docker_image_name = Docker.build_from_github(url=url, output_dir=OUTPUT_DIR)
|
50
|
-
self.assertTrue(docker_image_name, "Failed to build docker image")
|
51
|
-
server: CompileServer
|
52
|
-
with Api.server(auto_updates=True, container_name=docker_image_name) as server:
|
53
|
-
self.assertTrue(server.ping())
|
54
|
-
|
55
|
-
|
56
|
-
if __name__ == "__main__":
|
57
|
-
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
|
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
|
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
|