Skip to content

Port project_init + chrome extension downloaders to Rust; drop httpx #63

Closed

Description

@zackees

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 --init flow (currently delegates to Python).
  • Api.project_init() (public Python API, consumed by tests/unit/test_api.py).
  • Api.get_examples() (public Python API).

What it does today:

  1. Resolves a ref string → archive URL.
    • None / \"latest_release\" → fetches GitHub API /repos/FastLED/FastLED/releases/latest, falls back to master.
    • 7-40 hex chars → commit SHA URL.
    • else → tries as tag, falls back to branch.
  2. Downloads the zip from GitHub via httpx.
  3. Extracts to a tmpdir, finds the FastLED* root, copies the requested example to the user's output dir, writes fastled.json.

Proposed Rust port:

  • New install::ensure_fastled_repo(ref: Option<&str>) -> Result<PathBuf> in crates/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 (cheap library.json existence check).
  • main.rs --init path: call ensure_fastled_repo before delegating to Python; export FASTLED_LOCAL_REPO_DIR.
  • Python: project_init.py reads FASTLED_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:

  1. Builds CRX URL from extension ID (chromewebstore.googleapis.com).
  2. httpx.Client(follow_redirects=True).get() with a User-Agent header (the endpoint is picky about UA).
  3. Strips the CRX header (locates PK\x03\x04 magic), extracts the ZIP portion to an output directory.

Proposed Rust port:

  • New install::ensure_chrome_extension(extension_id, name) in install.rs. Reuses archive::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-tauri launches 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.toml runtime deps shrink from httpx + zcmds_win32 to just zcmds_win32; sys_platform == 'win32'.
  • All unit tests pass; the cold-cache --init and Tauri viewer launch flows still work.
  • grep -r 'import httpx' src/ returns nothing.

Activity

  1. added a commit that references this issue on May 13, 2026
    0115e09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions