Repository navigation
Port remaining Python app orchestration to Rust (closes #72) - #77
Merged
Merged
Conversation
Make the Rust _native extension authoritative for sketch discovery, fuzzy matching, project init, and prompt resolution. Strip the try/except fallback branches that re-implemented this logic in pure Python -- now hard imports from fastled._native; fail loud if the extension is unavailable. Delete three modules that have no callers on the primary path (Rust clap parser owns CLI argument parsing now): - src/fastled/parse_args.py (286 lines) - src/fastled/args.py (88 lines) - src/fastled/compile_native.py (125 lines) Update tests that asserted shape of the deleted Args dataclass or parse_args.py source. Delete test_parse_args.py (refs deleted module) and test_purge.py (already broken: imported nonexistent fastled.app.purge_cache). Update test_init_ref_args.py mutex tests to check stderr+stdout since Rust CLI correctly emits errors to stderr. Net: -1530 lines across 18 files. Refs #72
Two related cuts that move authoritative app orchestration onto Rust:
1. **Frontend bundling moved to Rust.** New crates/fastled-cli/src/frontend.rs
(487 lines) implements esbuild orchestration, mtime-marker caching,
sha256 dist-hash, and idempotent copy-to-output. Exposed via
#[pyfunction] copy_frontend_to_output in crates/fastled-py. The Python
shim at src/fastled/frontend_esbuild.py shrinks from 160 to ~20 lines
and forwards to _native; toolchain callers in
src/fastled/toolchain/{emscripten,internal_wasm_build}.py keep their
existing imports unchanged.
2. **Eliminate Rust to Python BuildService round-trip.**
crates/fastled-cli/src/build.rs::run_build_embedded now constructs
fastled._native.NativeBuildService directly, registers the
Emscripten toolchain inline, and parses the returned PyDict instead
of round-tripping through src/fastled/build_service.py. KeyboardInterrupt
is translated through fastled.interrupts.handle_keyboard_interrupt
in Rust before the subprocess fallback. The Python BuildService
class stays as the public external API surface.
3. **Viewer / CLI discovery dedupe.** crates/fastled-cli/src/viewer.rs gains
target/<arch-triple>/<profile>/ scan (parity with the deleted Python
walker). New #[pyfunction] find_fastled_viewer delegates to it.
src/fastled/open_browser.py drops _find_tauri_viewer,
_launch_tauri_viewer, and _find_fastled_cli (now use _native.find_fastled_viewer
and existing _rust_cli.find_rust_fastled_cli). spawn_http_server keeps
its signature; the Tauri spawn branch is removed since the Rust CLI's
--serve-dir already auto-launches the viewer.
Refs #72
This was referenced May 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #72. The final cut of the Python→Rust migration tracked in #14 (after #71, #73).
Stream A — Python fallback strip + dead-code delete. Replace
try/except _nativefallbacks with hard imports instring_diff.py,sketch.py,project_init.py. Deleteparse_args.py,args.py,compile_native.py(zero callers on the primary path — Rust clap is authoritative). Deletetests/unit/test_parse_args.pyandtests/unit/test_purge.py(already broken; imported nonexistentfastled.app.purge_cache). Updatetest_init_ref_args.pymutex assertions to checkstdout + stderrsince the Rust CLI correctly emits errors to stderr.Stream B — Port
frontend_esbuild.pyto Rust. Newcrates/fastled-cli/src/frontend.rs(487 lines) implements esbuild orchestration, mtime-marker caching, sha256 dist-hash, and idempotent copy-to-output. Exposed via#[pyfunction] copy_frontend_to_outputinfastled-py. The Python file shrinks from 160 to ~20 lines and forwards to_native; toolchain callers keep their imports.Stream C — Unwind Rust↔Python BuildService round-trip + viewer/CLI discovery dedupe.
crates/fastled-cli/src/build.rs::run_build_embeddednow constructsfastled._native.NativeBuildServicedirectly and parses thePyDictresult, skipping the PythonBuildServicewrapper (which stays as the public external API).crates/fastled-cli/src/viewer.rsgainstarget/<arch-triple>/<profile>/scan (parity with deleted Python walker); new#[pyfunction] find_fastled_viewerletssrc/fastled/open_browser.pydrop 130 lines of duplicate discovery code.Docs. New
CLAUDE.md(agent playbook: layout, soldr/zccache build cache, slow-test guidance, architecture, gotchas) andCODEX.md(one-line pointer toCLAUDE.md).Net diff
Acceptance criteria (from #72)
fastledapp/compile/watch flows are driven by Rust-native code paths by default.toolchain/).rg "python -m fastled.app|parse_args\(|BuildService\(" src/fastledno longer shows Python as the primary runtime owner (only theBuildServiceexternal API survives).Test plan
bash lint— green (cargo fmt + clippy + ruff + black + isort + pyright: 0 errors)soldr cargo test -p fastled-cli— build.rs and viewer.rs tests pass (incl. newtoolchain_key+ arch-triple scan tests)soldr cargo test -p fastled-cli frontend— 4 new frontend tests pass (hash determinism, dist skip, marker behavior)test_build_service,test_post_migration,test_http_server,test_select_sketch_directory,test_string_diff*,test_sketch_partial_match,test_project_init,test_init_ref_args) — all passbash testincluding end-to-endtest_cli.py(needs full EMSDK toolchain)from fastled._native import copy_frontend_to_output, find_fastled_viewer, NativeBuildServiceresolvesfrom fastled.frontend_esbuild import copy_frontend_to_output, FRONTEND_DIRresolvesfrom fastled.open_browser import spawn_http_server, add_cleanupresolvesRelated
./_cargobypasses them)./_cargo,./_rustc,./_rustfmttrampolines in favor ofsoldr🤖 Generated with Claude Code