Repository navigation
Closed
Description
Follow-up to #59 / PR #62. PR #62 moved the emscripten and esbuild installs into Rust (crates/fastled-cli/src/install.rs) and dropped 6 Python deps. Two HTTP-using Python files remain, keeping httpx alive in the runtime deps.
Remaining callers of httpx
src/fastled/project_init.py — FastLED repo download
Used by:
- The Rust CLI's
--initflow (currently delegates to Python). Api.project_init()(public Python API, consumed bytests/unit/test_api.py).Api.get_examples()(public Python API).
What it does today:
- Resolves a ref string → archive URL.
None/\"latest_release\"→ fetches GitHub API/repos/FastLED/FastLED/releases/latest, falls back tomaster.- 7-40 hex chars → commit SHA URL.
- else → tries as tag, falls back to branch.
- Downloads the zip from GitHub via httpx.
- Extracts to a tmpdir, finds the
FastLED*root, copies the requested example to the user's output dir, writesfastled.json.
Proposed Rust port:
- New
install::ensure_fastled_repo(ref: Option<&str>) -> Result<PathBuf>incrates/fastled-cli/src/install.rs.- Handles GitHub API latest-release lookup (single GET + serde_json parse for
tag_name). - Reuses
archive::download+archive::extract_zip. - Caches at
~/.fastled/cache/fastled-{ref}/; reuses on subsequent calls (cheaplibrary.jsonexistence check).
- Handles GitHub API latest-release lookup (single GET + serde_json parse for
main.rs--initpath: callensure_fastled_repobefore delegating to Python; exportFASTLED_LOCAL_REPO_DIR.- Python:
project_init.pyreadsFASTLED_LOCAL_REPO_DIR, drops all httpx code. Api.project_init()/Api.get_examples(): invoke the Rust binary via subprocess to populate the env var, then call the Python helpers.
Risk: the interactive example-disambiguation prompt (_disambiguate_user_choice) stays in Python — Rust just guarantees the local repo exists before Python lists examples/.
src/fastled/playwright/chrome_extension_downloader.py — Chrome Web Store CRX fetch
Used by playwright_browser.py:84 during browser init (C++ DevTools extension for the Tauri viewer).
What it does today:
- Builds CRX URL from extension ID (chromewebstore.googleapis.com).
httpx.Client(follow_redirects=True).get()with a User-Agent header (the endpoint is picky about UA).- Strips the CRX header (locates
PK\x03\x04magic), extracts the ZIP portion to an output directory.
Proposed Rust port:
- New
install::ensure_chrome_extension(extension_id, name)ininstall.rs. Reusesarchive::download(after setting the right User-Agent on the reqwest client). Need a CRX-header-stripping helper that can wrap a file-like over the bytes after the magic. - Wiring: either (a)
crates/fastled-taurilaunches the install lazily before opening the Chromium window, or (b) Python's chrome_extension_downloader.py keeps the orchestration but subprocesses the Rust binary for the download itself.
Acceptance
- After both ports:
pyproject.tomlruntime deps shrink fromhttpx + zcmds_win32to justzcmds_win32; sys_platform == 'win32'. - All unit tests pass; the cold-cache
--initand Tauri viewer launch flows still work. grep -r 'import httpx' src/returns nothing.
Metadata
Metadata
Assignees
Labels
No labels
Activity
chore: move all HTTP downloads from Python to Rust; drop httpx (closes …