Repository navigation
Description
Context
PR #65 fixed the helper that locates the Rust fastled binary, but the binary still has to be materialised somewhere the helper can find it. Currently it isn't:
cargo binstall fastled-clifails (no published release yet).cargo test --workspaceproduces a test binary attarget/<arch>/debug/deps/fastled-<hash>but not always the regulartarget/<arch>/debug/fastled[.exe].- The
deploy(Build Webpage) workflow never runscargo test.
PR #66 is the current band-aid — it tacks cargo build --release --bin fastled onto ./install, so the binary materialises during install. That works, but it bakes a multi-minute Rust compile into every install, every CI job, and every dev ./install. We should never compile fastled from source as part of installing the Python package.
The right fix
Use Python's first-class mechanism for shipping a native binary in a wheel: the <pkg>-<ver>.data/scripts/<name> slot, which pip extracts to the venv's Scripts/ (or bin/) at install time. maturin builds this directly when a project has both a [lib] (cdylib) target and one or more [[bin]] targets.
After the change:
pip install fastled(or the wheel built from this repo) drops the Rustfastled[.exe]straight into.venv/Scripts/. No Python shim with the same name. No cargo build during install._find_rust_fastled_clibecomes a one-liner:Path(shutil.which(\"fastled\"))returns the Rust binary directly../installdrops thecargo build --release --bin fastledstep (PR fix(ci): build the Rust fastled CLI from source when binstall fails #66's band-aid).- CI's unit-test + deploy jobs work without any extra Rust step.
Concrete plan
-
Refactor
crates/fastled-clito expose a library entry point (pub fn run() -> std::process::ExitCode) by moving the body ofmain.rsintolib.rs.crates/fastled-cli/src/main.rsshrinks tofn main() -> ExitCode { fastled_cli::run() }. -
Add a
[[bin]]tocrates/fastled-py/Cargo.toml:[[bin]] name = "fastled" path = "src/bin/fastled.rs" [dependencies] pyo3 = { workspace = true } fastled-cli = { path = "../fastled-cli" }
crates/fastled-py/src/bin/fastled.rs:fn main() -> std::process::ExitCode { fastled_cli::run() }
-
Drop
fastled = \"fastled.cli:main\"from[project.scripts]inpyproject.toml(keepfledandfastled-wasmif we still want Python entry-points for those names — but actually those collide too, so probably drop them as well and add them as additional[[bin]]targets). -
Delete the install-side
cargo build --release --bin fastledfallback added in PR fix(ci): build the Rust fastled CLI from source when binstall fails #66 once this lands. -
Sanity:
pip install -e .is editable mode, which doesn't run maturin's wheel-build path. Editable installs still need./installto materialise the binary somehow — leave the cargo-build fallback active only whenMATURIN_PEP517_ARGSindicates editable mode, or just keep a cargo-build call as a dev-only path.
Verification
bash lintclean.bash test— 119 unit tests pass without any cargo-build step.- Build a wheel (
uv run maturin build --release),pip installit into a fresh venv, runwhich fastled, confirm it's the Rust binary andfastled --versionmatches. - CI unit-test + deploy jobs green without the install-script fallback.
Out of scope
fastled-viewer(Tauri) bundling — also a Rust bin; same approach if/when desired, but separate PR.- Publishing pre-built wheels — orthogonal.
Activity
feat: bundle the Rust fastled CLI binary in the wheel (closes #67) (#68)