fastled 1.1.29__py2.py3-none-any.whl → 1.1.31__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/parse_args.py ADDED
@@ -0,0 +1,161 @@
1
+ import argparse
2
+ import os
3
+ import sys
4
+ from pathlib import Path
5
+
6
+ from fastled import __version__
7
+ from fastled.docker_manager import DockerManager
8
+ from fastled.env import DEFAULT_URL
9
+ from fastled.project_init import project_init
10
+ from fastled.select_sketch_directory import select_sketch_directory
11
+ from fastled.sketch import (
12
+ find_sketch_directories,
13
+ looks_like_fastled_repo,
14
+ looks_like_sketch_directory,
15
+ )
16
+
17
+
18
+ def parse_args() -> argparse.Namespace:
19
+ """Parse command-line arguments."""
20
+ parser = argparse.ArgumentParser(description=f"FastLED WASM Compiler {__version__}")
21
+ parser.add_argument(
22
+ "--version", action="version", version=f"%(prog)s {__version__}"
23
+ )
24
+ parser.add_argument(
25
+ "directory",
26
+ type=str,
27
+ nargs="?",
28
+ default=None,
29
+ help="Directory containing the FastLED sketch to compile",
30
+ )
31
+ parser.add_argument(
32
+ "--init",
33
+ action="store_true",
34
+ help="Initialize the FastLED sketch in the current directory",
35
+ )
36
+ parser.add_argument(
37
+ "--just-compile",
38
+ action="store_true",
39
+ help="Just compile, skip opening the browser and watching for changes.",
40
+ )
41
+ parser.add_argument(
42
+ "--web",
43
+ "-w",
44
+ type=str,
45
+ nargs="?",
46
+ # const does not seem to be working as expected
47
+ const=DEFAULT_URL, # Default value when --web is specified without value
48
+ help="Use web compiler. Optional URL can be provided (default: https://fastled.onrender.com)",
49
+ )
50
+ parser.add_argument(
51
+ "-i",
52
+ "--interactive",
53
+ action="store_true",
54
+ help="Run in interactive mode (Not available with --web)",
55
+ )
56
+ parser.add_argument(
57
+ "--profile",
58
+ action="store_true",
59
+ help="Enable profiling for web compilation",
60
+ )
61
+ parser.add_argument(
62
+ "--force-compile",
63
+ action="store_true",
64
+ help="Skips the test to see if the current directory is a valid FastLED sketch directory",
65
+ )
66
+ parser.add_argument(
67
+ "--no-auto-updates",
68
+ action="store_true",
69
+ help="Disable automatic updates of the wasm compiler image when using docker.",
70
+ )
71
+ parser.add_argument(
72
+ "--update",
73
+ "--upgrade",
74
+ action="store_true",
75
+ help="Update the wasm compiler (if necessary) before running",
76
+ )
77
+ parser.add_argument(
78
+ "--localhost",
79
+ "--local",
80
+ "-l",
81
+ action="store_true",
82
+ help="Use localhost for web compilation from an instance of fastled --server, creating it if necessary",
83
+ )
84
+ parser.add_argument(
85
+ "--server",
86
+ "-s",
87
+ action="store_true",
88
+ help="Run the server in the current directory, volume mapping fastled if we are in the repo",
89
+ )
90
+
91
+ build_mode = parser.add_mutually_exclusive_group()
92
+ build_mode.add_argument("--debug", action="store_true", help="Build in debug mode")
93
+ build_mode.add_argument(
94
+ "--quick",
95
+ action="store_true",
96
+ default=True,
97
+ help="Build in quick mode (default)",
98
+ )
99
+ build_mode.add_argument(
100
+ "--release", action="store_true", help="Build in release mode"
101
+ )
102
+
103
+ cwd_is_fastled = looks_like_fastled_repo(Path(os.getcwd()))
104
+
105
+ args = parser.parse_args()
106
+
107
+ if args.init:
108
+ args.directory = project_init()
109
+
110
+ if not args.update:
111
+ if args.no_auto_updates:
112
+ args.auto_update = False
113
+ else:
114
+ args.auto_update = None
115
+
116
+ if (
117
+ not cwd_is_fastled
118
+ and not args.localhost
119
+ and not args.web
120
+ and not args.server
121
+ ):
122
+ # print(f"Using web compiler at {DEFAULT_URL}")
123
+ args.web = DEFAULT_URL
124
+ if DockerManager.is_docker_installed():
125
+ print("Docker is installed. Use --server to run the compiler locally.")
126
+ args.localhost = True
127
+ else:
128
+ print("Docker is not installed. Using web compiler.")
129
+ if cwd_is_fastled and not args.web and not args.server:
130
+ print("Forcing --local mode because we are in the FastLED repo")
131
+ args.localhost = True
132
+ if args.localhost:
133
+ args.web = "localhost"
134
+ if args.interactive and not args.server:
135
+ print("--interactive forces --server mode")
136
+ args.server = True
137
+ if args.directory is None and not args.server:
138
+ # does current directory look like a sketch?
139
+ maybe_sketch_dir = Path(os.getcwd())
140
+ if looks_like_sketch_directory(maybe_sketch_dir):
141
+ args.directory = str(maybe_sketch_dir)
142
+ else:
143
+ sketch_directories = find_sketch_directories(maybe_sketch_dir)
144
+ selected_dir = select_sketch_directory(
145
+ sketch_directories, cwd_is_fastled
146
+ )
147
+ if selected_dir:
148
+ print(f"Using sketch directory: {selected_dir}")
149
+ args.directory = selected_dir
150
+ else:
151
+ print(
152
+ "\nYou either need to specify a sketch directory or run in --server mode."
153
+ )
154
+ sys.exit(1)
155
+ elif args.directory is not None and os.path.isfile(args.directory):
156
+ dir_path = Path(args.directory).parent
157
+ if looks_like_sketch_directory(dir_path):
158
+ print(f"Using sketch directory: {dir_path}")
159
+ args.directory = str(dir_path)
160
+
161
+ return args
@@ -0,0 +1,37 @@
1
+ import zipfile
2
+ from pathlib import Path
3
+
4
+ import httpx
5
+
6
+ from fastled.env import DEFAULT_URL
7
+
8
+ ENDPOINT = f"{DEFAULT_URL}/project/init"
9
+
10
+
11
+ def project_init() -> Path:
12
+ """
13
+ Initialize a new FastLED project.
14
+ """
15
+ response = httpx.get(ENDPOINT, timeout=20)
16
+ response.raise_for_status()
17
+ content = response.content
18
+ output = Path("fastled.zip")
19
+ output.write_bytes(content)
20
+ # unzip the content
21
+ outdir = Path("fastled")
22
+ if outdir.exists():
23
+ print("Project already initialized.")
24
+ return Path("fastled").iterdir().__next__()
25
+ with zipfile.ZipFile(output, "r") as zip_ref:
26
+ zip_ref.extractall(outdir)
27
+ print(f"Project initialized successfully at {outdir}")
28
+ output.unlink()
29
+ return Path("fastled").iterdir().__next__()
30
+
31
+
32
+ def unit_test() -> None:
33
+ project_init()
34
+
35
+
36
+ if __name__ == "__main__":
37
+ unit_test()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fastled
3
- Version: 1.1.29
3
+ Version: 1.1.31
4
4
  Summary: FastLED Wasm Compiler
5
5
  Home-page: https://github.com/zackees/fastled-wasm
6
6
  Maintainer: Zachary Vorhies
@@ -161,10 +161,10 @@ 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
-
165
-
166
164
  # Revisions
167
165
 
166
+ * 1.1.31 - `--local` is auto-enabled if docker is installed, use `--web` to force web compiler. Updating is much more pretty.
167
+ * 1.1.30 - Added `--init` to initialize a demo project.
168
168
  * 1.1.29 - Remove annoying dbg messages i left in.
169
169
  * 1.1.28 - Adds cache control headers to the live server to disable all caching in the live browser.
170
170
  * 1.1.27 - Fixed `--interactive` so that it now works correctly.
@@ -1,15 +1,17 @@
1
- fastled/__init__.py,sha256=lYctXzPgrDxsgVkkhbmwNeN6O7ypfxaV0bZIt-d7bqM,61
2
- fastled/app.py,sha256=oL_IXsYxDRaw9eU2aSkCZ57xAUedbNWT4-WwCsJT2Sc,6978
1
+ fastled/__init__.py,sha256=6jxxjP0Xri7C6EmI1qL3wfS_HKvFbZP2OMpSiZipIo8,61
2
+ fastled/app.py,sha256=Zw1RS72yyIZSDt1_08MDSzfY4YwLWzarwXM4nvy8GE4,1787
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
5
  fastled/client_server.py,sha256=IK_u71XbmOAKBX1ovHATsCmfUON8VVJJu-XtObTuYJI,11448
6
6
  fastled/compile_server.py,sha256=Adb2lvJ_p6Ui7UMxijRtYJhbO4YPTERKVQeuoQgibSE,6724
7
- fastled/docker_manager.py,sha256=Ok8TC1JXMoNMWt4P9clFFEVE29Xd-4C_MvIMIfvNo78,22134
7
+ fastled/docker_manager.py,sha256=WVWg8ABWjdrX1P4vRRbW2z6yMOhhrHVtQ9H_cBBBAlI,23275
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=-2_vyf6dbi2xGex-CMZHVVcXvwXGJkLOwFcjHGxknUQ,1769
12
+ fastled/parse_args.py,sha256=2O6lB6Nf0ZfNv10AHFK3fkN35DCrpX4dBByZa0u6XR4,5537
12
13
  fastled/paths.py,sha256=VsPmgu0lNSCFOoEC0BsTYzDygXqy15AHUfN-tTuzDZA,99
14
+ fastled/project_init.py,sha256=9GmyaRsXa1fNuzqpv0lcpkSFTOFszpEZ3jr788zZNp0,870
13
15
  fastled/select_sketch_directory.py,sha256=TZdCjl1D7YMKjodMTvDRurPcpAmN3x0TcJxffER2NfM,1314
14
16
  fastled/sketch.py,sha256=5nRjg281lMH8Bo9wKjbcpTQCfEP574ZCG-lukvFmyQ8,2656
15
17
  fastled/spinner.py,sha256=ZGFXona3SJxmuHIzMGa6tqB0IVDSRr8W_dju09Z1Hwg,901
@@ -18,9 +20,9 @@ fastled/types.py,sha256=dDIsGHJkHNJ7B61wNp6X0JSLs_nrHiq7RlNqNWbwFec,194
18
20
  fastled/util.py,sha256=t4M3NFMhnCzfYbLvIyJi0RdFssZqbTN_vVIaej1WV-U,265
19
21
  fastled/web_compile.py,sha256=KuvKGdX6SSUUqC7YgX4T9SMSP5wdcPUhpg9-K9zPoTI,10378
20
22
  fastled/assets/example.txt,sha256=lTBovRjiz0_TgtAtbA1C5hNi2ffbqnNPqkKg6UiKCT8,54
21
- fastled-1.1.29.dist-info/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
22
- fastled-1.1.29.dist-info/METADATA,sha256=LtpoLOstFU2_ViPEJYvc7o9PiUZpY5pqK_7PeUkDIiU,14482
23
- fastled-1.1.29.dist-info/WHEEL,sha256=0VNUDWQJzfRahYI3neAhz2UVbRCtztpN5dPHAGvmGXc,109
24
- fastled-1.1.29.dist-info/entry_points.txt,sha256=RCwmzCSOS4-C2i9EziANq7Z2Zb4KFnEMR1FQC0bBwAw,101
25
- fastled-1.1.29.dist-info/top_level.txt,sha256=xfG6Z_ol9V5YmBROkZq2QTRwjbS2ouCUxaTJsOwfkOo,14
26
- fastled-1.1.29.dist-info/RECORD,,
23
+ fastled-1.1.31.dist-info/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
24
+ fastled-1.1.31.dist-info/METADATA,sha256=Q4cS70DetU08f-0-GUc6CxTrCI3R9FJArBszGUA7r_I,14666
25
+ fastled-1.1.31.dist-info/WHEEL,sha256=0VNUDWQJzfRahYI3neAhz2UVbRCtztpN5dPHAGvmGXc,109
26
+ fastled-1.1.31.dist-info/entry_points.txt,sha256=RCwmzCSOS4-C2i9EziANq7Z2Zb4KFnEMR1FQC0bBwAw,101
27
+ fastled-1.1.31.dist-info/top_level.txt,sha256=xfG6Z_ol9V5YmBROkZq2QTRwjbS2ouCUxaTJsOwfkOo,14
28
+ fastled-1.1.31.dist-info/RECORD,,