fastled 1.1.21__py2.py3-none-any.whl → 1.1.22__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/__init__.py +1 -1
- fastled/app.py +187 -197
- fastled/select_sketch_directory.py +35 -0
- fastled/string_diff.py +37 -0
- {fastled-1.1.21.dist-info → fastled-1.1.22.dist-info}/METADATA +3 -1
- {fastled-1.1.21.dist-info → fastled-1.1.22.dist-info}/RECORD +10 -8
- {fastled-1.1.21.dist-info → fastled-1.1.22.dist-info}/LICENSE +0 -0
- {fastled-1.1.21.dist-info → fastled-1.1.22.dist-info}/WHEEL +0 -0
- {fastled-1.1.21.dist-info → fastled-1.1.22.dist-info}/entry_points.txt +0 -0
- {fastled-1.1.21.dist-info → fastled-1.1.22.dist-info}/top_level.txt +0 -0
fastled/__init__.py
CHANGED
fastled/app.py
CHANGED
@@ -1,197 +1,187 @@
|
|
1
|
-
"""
|
2
|
-
Uses the latest wasm compiler image to compile the FastLED sketch.
|
3
|
-
"""
|
4
|
-
|
5
|
-
import argparse
|
6
|
-
import os
|
7
|
-
import sys
|
8
|
-
import time
|
9
|
-
from pathlib import Path
|
10
|
-
|
11
|
-
from fastled import __version__
|
12
|
-
from fastled.client_server import run_client_server
|
13
|
-
from fastled.compile_server import CompileServer
|
14
|
-
from fastled.env import DEFAULT_URL
|
15
|
-
from fastled.
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
parser.
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
"
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
"
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
"--
|
78
|
-
"
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
"
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
build_mode
|
90
|
-
build_mode.add_argument(
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
print(
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
print("
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
try:
|
189
|
-
os.chdir("../fastled")
|
190
|
-
sys.argv.append("--server")
|
191
|
-
sys.exit(main())
|
192
|
-
except KeyboardInterrupt:
|
193
|
-
print("\nExiting from main...")
|
194
|
-
sys.exit(1)
|
195
|
-
except Exception as e:
|
196
|
-
print(f"Error: {e}")
|
197
|
-
sys.exit(1)
|
1
|
+
"""
|
2
|
+
Uses the latest wasm compiler image to compile the FastLED sketch.
|
3
|
+
"""
|
4
|
+
|
5
|
+
import argparse
|
6
|
+
import os
|
7
|
+
import sys
|
8
|
+
import time
|
9
|
+
from pathlib import Path
|
10
|
+
|
11
|
+
from fastled import __version__
|
12
|
+
from fastled.client_server import run_client_server
|
13
|
+
from fastled.compile_server import CompileServer
|
14
|
+
from fastled.env import DEFAULT_URL
|
15
|
+
from fastled.select_sketch_directory import select_sketch_directory
|
16
|
+
from fastled.sketch import (
|
17
|
+
find_sketch_directories,
|
18
|
+
looks_like_fastled_repo,
|
19
|
+
looks_like_sketch_directory,
|
20
|
+
)
|
21
|
+
|
22
|
+
|
23
|
+
def parse_args() -> argparse.Namespace:
|
24
|
+
"""Parse command-line arguments."""
|
25
|
+
parser = argparse.ArgumentParser(description=f"FastLED WASM Compiler {__version__}")
|
26
|
+
parser.add_argument(
|
27
|
+
"--version", action="version", version=f"%(prog)s {__version__}"
|
28
|
+
)
|
29
|
+
parser.add_argument(
|
30
|
+
"directory",
|
31
|
+
type=str,
|
32
|
+
nargs="?",
|
33
|
+
default=None,
|
34
|
+
help="Directory containing the FastLED sketch to compile",
|
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
|
+
action="store_true",
|
74
|
+
help="Update the wasm compiler (if necessary) before running",
|
75
|
+
)
|
76
|
+
parser.add_argument(
|
77
|
+
"--localhost",
|
78
|
+
"--local",
|
79
|
+
"-l",
|
80
|
+
action="store_true",
|
81
|
+
help="Use localhost for web compilation from an instance of fastled --server, creating it if necessary",
|
82
|
+
)
|
83
|
+
parser.add_argument(
|
84
|
+
"--server",
|
85
|
+
"-s",
|
86
|
+
action="store_true",
|
87
|
+
help="Run the server in the current directory, volume mapping fastled if we are in the repo",
|
88
|
+
)
|
89
|
+
build_mode = parser.add_mutually_exclusive_group()
|
90
|
+
build_mode.add_argument("--debug", action="store_true", help="Build in debug mode")
|
91
|
+
build_mode.add_argument(
|
92
|
+
"--quick",
|
93
|
+
action="store_true",
|
94
|
+
default=True,
|
95
|
+
help="Build in quick mode (default)",
|
96
|
+
)
|
97
|
+
build_mode.add_argument(
|
98
|
+
"--release", action="store_true", help="Build in release mode"
|
99
|
+
)
|
100
|
+
|
101
|
+
cwd_is_fastled = looks_like_fastled_repo(Path(os.getcwd()))
|
102
|
+
|
103
|
+
args = parser.parse_args()
|
104
|
+
if args.update:
|
105
|
+
args.auto_update = True
|
106
|
+
elif args.no_auto_updates:
|
107
|
+
args.auto_update = False
|
108
|
+
else:
|
109
|
+
args.auto_update = None
|
110
|
+
|
111
|
+
if not cwd_is_fastled and not args.localhost and not args.web and not args.server:
|
112
|
+
print(f"Using web compiler at {DEFAULT_URL}")
|
113
|
+
args.web = DEFAULT_URL
|
114
|
+
if cwd_is_fastled and not args.web and not args.server:
|
115
|
+
print("Forcing --local mode because we are in the FastLED repo")
|
116
|
+
args.localhost = True
|
117
|
+
if args.localhost:
|
118
|
+
args.web = "localhost"
|
119
|
+
if args.interactive and not args.server:
|
120
|
+
print("--interactive forces --server mode")
|
121
|
+
args.server = True
|
122
|
+
if args.directory is None and not args.server:
|
123
|
+
# does current directory look like a sketch?
|
124
|
+
maybe_sketch_dir = Path(os.getcwd())
|
125
|
+
if looks_like_sketch_directory(maybe_sketch_dir):
|
126
|
+
args.directory = str(maybe_sketch_dir)
|
127
|
+
else:
|
128
|
+
sketch_directories = find_sketch_directories(maybe_sketch_dir)
|
129
|
+
selected_dir = select_sketch_directory(sketch_directories, cwd_is_fastled)
|
130
|
+
if selected_dir:
|
131
|
+
print(f"Using sketch directory: {selected_dir}")
|
132
|
+
args.directory = selected_dir
|
133
|
+
else:
|
134
|
+
print(
|
135
|
+
"\nYou either need to specify a sketch directory or run in --server mode."
|
136
|
+
)
|
137
|
+
sys.exit(1)
|
138
|
+
elif args.directory is not None and os.path.isfile(args.directory):
|
139
|
+
dir_path = Path(args.directory).parent
|
140
|
+
if looks_like_sketch_directory(dir_path):
|
141
|
+
print(f"Using sketch directory: {dir_path}")
|
142
|
+
args.directory = str(dir_path)
|
143
|
+
|
144
|
+
return args
|
145
|
+
|
146
|
+
|
147
|
+
def run_server(args: argparse.Namespace) -> int:
|
148
|
+
interactive = args.interactive
|
149
|
+
auto_update = args.auto_update
|
150
|
+
compile_server = CompileServer(interactive=interactive, auto_updates=auto_update)
|
151
|
+
if not interactive:
|
152
|
+
print(f"Server started at {compile_server.url()}")
|
153
|
+
compile_server.wait_for_startup()
|
154
|
+
try:
|
155
|
+
while True:
|
156
|
+
if not compile_server.proceess_running():
|
157
|
+
print("Server process is not running. Exiting...")
|
158
|
+
return 1
|
159
|
+
time.sleep(1)
|
160
|
+
except KeyboardInterrupt:
|
161
|
+
print("\nExiting from server...")
|
162
|
+
return 1
|
163
|
+
finally:
|
164
|
+
compile_server.stop()
|
165
|
+
return 0
|
166
|
+
|
167
|
+
|
168
|
+
def main() -> int:
|
169
|
+
args = parse_args()
|
170
|
+
if args.server:
|
171
|
+
print("Running in server only mode.")
|
172
|
+
return run_server(args)
|
173
|
+
else:
|
174
|
+
print("Running in client/server mode.")
|
175
|
+
return run_client_server(args)
|
176
|
+
|
177
|
+
|
178
|
+
if __name__ == "__main__":
|
179
|
+
try:
|
180
|
+
os.chdir("../fastled")
|
181
|
+
sys.exit(main())
|
182
|
+
except KeyboardInterrupt:
|
183
|
+
print("\nExiting from main...")
|
184
|
+
sys.exit(1)
|
185
|
+
except Exception as e:
|
186
|
+
print(f"Error: {e}")
|
187
|
+
sys.exit(1)
|
@@ -0,0 +1,35 @@
|
|
1
|
+
from pathlib import Path
|
2
|
+
|
3
|
+
from fastled.string_diff import string_diff_paths
|
4
|
+
|
5
|
+
|
6
|
+
def select_sketch_directory(
|
7
|
+
sketch_directories: list[Path], cwd_is_fastled: bool
|
8
|
+
) -> str | None:
|
9
|
+
if cwd_is_fastled:
|
10
|
+
exclude = ["src", "dev", "tests"]
|
11
|
+
for ex in exclude:
|
12
|
+
p = Path(ex)
|
13
|
+
if p in sketch_directories:
|
14
|
+
sketch_directories.remove(p)
|
15
|
+
|
16
|
+
if len(sketch_directories) == 1:
|
17
|
+
print(f"\nUsing sketch directory: {sketch_directories[0]}")
|
18
|
+
return str(sketch_directories[0])
|
19
|
+
elif len(sketch_directories) > 1:
|
20
|
+
print("\nMultiple Directories found, choose one:")
|
21
|
+
for i, sketch_dir in enumerate(sketch_directories):
|
22
|
+
print(f" [{i+1}]: {sketch_dir}")
|
23
|
+
which = input("\nPlease specify a sketch directory: ")
|
24
|
+
try:
|
25
|
+
index = int(which) - 1
|
26
|
+
return str(sketch_directories[index])
|
27
|
+
except (ValueError, IndexError):
|
28
|
+
inputs = [p for p in sketch_directories]
|
29
|
+
top_hits: list[tuple[int, Path]] = string_diff_paths(which, inputs)
|
30
|
+
if len(top_hits) == 1:
|
31
|
+
example = top_hits[0][1]
|
32
|
+
return str(example)
|
33
|
+
else:
|
34
|
+
return select_sketch_directory([p for _, p in top_hits], cwd_is_fastled)
|
35
|
+
return None
|
fastled/string_diff.py
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
from pathlib import Path
|
2
|
+
|
3
|
+
from rapidfuzz.distance import Levenshtein
|
4
|
+
|
5
|
+
|
6
|
+
# Returns the min distance strings. If there is a tie, it returns
|
7
|
+
# all the strings that have the same min distance.
|
8
|
+
# Returns a tuple of index and string.
|
9
|
+
def string_diff(
|
10
|
+
input_string: str, string_list: list[str], ignore_case=True
|
11
|
+
) -> list[tuple[int, str]]:
|
12
|
+
|
13
|
+
def normalize(s: str) -> str:
|
14
|
+
return s.lower() if ignore_case else s
|
15
|
+
|
16
|
+
distances = [
|
17
|
+
Levenshtein.distance(normalize(input_string), normalize(s)) for s in string_list
|
18
|
+
]
|
19
|
+
min_distance = min(distances)
|
20
|
+
out: list[tuple[int, str]] = []
|
21
|
+
for i, d in enumerate(distances):
|
22
|
+
if d == min_distance:
|
23
|
+
out.append((i, string_list[i]))
|
24
|
+
return out
|
25
|
+
|
26
|
+
|
27
|
+
def string_diff_paths(
|
28
|
+
input_string: str | Path, path_list: list[Path], ignore_case=True
|
29
|
+
) -> list[tuple[int, Path]]:
|
30
|
+
string_list = [str(p) for p in path_list]
|
31
|
+
tmp = string_diff(str(input_string), string_list, ignore_case)
|
32
|
+
# out: list[tuple[int, Path]] = [(i, Path(path_list[j])) for i, j in tmp]
|
33
|
+
out: list[tuple[int, Path]] = []
|
34
|
+
for i, j in tmp:
|
35
|
+
p = Path(j)
|
36
|
+
out.append((i, p))
|
37
|
+
return out
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: fastled
|
3
|
-
Version: 1.1.
|
3
|
+
Version: 1.1.22
|
4
4
|
Summary: FastLED Wasm Compiler
|
5
5
|
Home-page: https://github.com/zackees/fastled-wasm
|
6
6
|
Maintainer: Zachary Vorhies
|
@@ -18,6 +18,7 @@ Requires-Dist: download
|
|
18
18
|
Requires-Dist: filelock
|
19
19
|
Requires-Dist: disklru>=2.0.1
|
20
20
|
Requires-Dist: appdirs
|
21
|
+
Requires-Dist: rapidfuzz
|
21
22
|
|
22
23
|
# FastLED Wasm compiler
|
23
24
|
|
@@ -161,6 +162,7 @@ A: A big chunk of space is being used by unnecessary javascript `emscripten` is
|
|
161
162
|
|
162
163
|
# Revisions
|
163
164
|
|
165
|
+
* 1.1.22 - Selecting sketch now allows strings and narrowing down paths if ambiguity
|
164
166
|
* 1.1.21 - Now always watches for space/enter key events to trigger a recompile.
|
165
167
|
* 1.1.20 - Fixed a regression for 1.1.16 involving docker throwing an exception before DockerManager.is_running() could be called so it can be launched.
|
166
168
|
* 1.1.19 - Automatically does a limit searches for sketch directories if you leave it blank.
|
@@ -1,5 +1,5 @@
|
|
1
|
-
fastled/__init__.py,sha256=
|
2
|
-
fastled/app.py,sha256=
|
1
|
+
fastled/__init__.py,sha256=Vwrw9C5ep3js4u63kaxEdkec1V40HfactjPKA7tUZv4,64
|
2
|
+
fastled/app.py,sha256=UXHR4nFJzdU-3WGk9J7BB0RxkQVwKZ7XKCgfLp2yqW0,6281
|
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=TLEmCxafrcBzo9FAz3OlIIgsSbNpVGsSuvZnIXpHXBA,11090
|
@@ -10,14 +10,16 @@ fastled/filewatcher.py,sha256=5dVmjEG23kMeJa29tRVm5XKSr9sTD4ME2boo-CFDuUM,6910
|
|
10
10
|
fastled/keyboard.py,sha256=TkFjDxGtGdDbjQF_LRqp54hmdcKaXjf1olTT8l6dEJk,3170
|
11
11
|
fastled/open_browser.py,sha256=RRHcsZ5Vzsw1AuZUEYuSfjKmf_9j3NGMDUR-FndHmqs,1483
|
12
12
|
fastled/paths.py,sha256=VsPmgu0lNSCFOoEC0BsTYzDygXqy15AHUfN-tTuzDZA,99
|
13
|
+
fastled/select_sketch_directory.py,sha256=S9h8pHCDshaUGHdXaaFoh8g189ewA-GbKVEHKyaO2iQ,1304
|
13
14
|
fastled/sketch.py,sha256=5nRjg281lMH8Bo9wKjbcpTQCfEP574ZCG-lukvFmyQ8,2656
|
15
|
+
fastled/string_diff.py,sha256=svtaQFGp4a6r2Qjx-Gxhna94wK-d8LKV4OCpKMXiHso,1164
|
14
16
|
fastled/types.py,sha256=dDIsGHJkHNJ7B61wNp6X0JSLs_nrHiq7RlNqNWbwFec,194
|
15
17
|
fastled/util.py,sha256=t4M3NFMhnCzfYbLvIyJi0RdFssZqbTN_vVIaej1WV-U,265
|
16
18
|
fastled/web_compile.py,sha256=KuvKGdX6SSUUqC7YgX4T9SMSP5wdcPUhpg9-K9zPoTI,10378
|
17
19
|
fastled/assets/example.txt,sha256=lTBovRjiz0_TgtAtbA1C5hNi2ffbqnNPqkKg6UiKCT8,54
|
18
|
-
fastled-1.1.
|
19
|
-
fastled-1.1.
|
20
|
-
fastled-1.1.
|
21
|
-
fastled-1.1.
|
22
|
-
fastled-1.1.
|
23
|
-
fastled-1.1.
|
20
|
+
fastled-1.1.22.dist-info/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
|
21
|
+
fastled-1.1.22.dist-info/METADATA,sha256=Xr6-uF2ohZ8Jjg3FSxLojs5nK6w7nbJ_cZ_e_1eGVeY,14012
|
22
|
+
fastled-1.1.22.dist-info/WHEEL,sha256=0VNUDWQJzfRahYI3neAhz2UVbRCtztpN5dPHAGvmGXc,109
|
23
|
+
fastled-1.1.22.dist-info/entry_points.txt,sha256=RCwmzCSOS4-C2i9EziANq7Z2Zb4KFnEMR1FQC0bBwAw,101
|
24
|
+
fastled-1.1.22.dist-info/top_level.txt,sha256=xfG6Z_ol9V5YmBROkZq2QTRwjbS2ouCUxaTJsOwfkOo,14
|
25
|
+
fastled-1.1.22.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|