feat(sdk)!: make the HTTP libraries optional and drop the saved token

Merged
AD
1mo ago
+853-422

Type of change

  • Breaking change

What

Optional HTTP libraries. reflex-build-sdk no longer requires aiohttp, httpx or platformdirs; its dependencies list is empty. There are three extras:

pip install "reflex-build-sdk[httpx2]"   # ReflexBuild and AsyncReflexBuild
pip install "reflex-build-sdk[aiohttp]"  # AsyncReflexBuild only
pip install "reflex-build-sdk[httpx]"    # ReflexBuild and AsyncReflexBuild

When no transport is passed, each client uses the first library installed:

  • AsyncReflexBuild: aiohttp, then httpx2, then httpx
  • ReflexBuild: httpx2, then httpx

With none installed, the SDK still imports; creating a client raises ImportError naming the extra to install. The transports load their library only when first used.

httpx2. Adds Httpx2Transport / AsyncHttpx2Transport for pydantic/httpx2. _httpx2.py and test_httpx2.py are generated from the httpx versions by scripts/unasync.py, which already generates the sync client, and the pre-commit hook keeps them in sync. httpx is kept for now.

No saved token. The clients no longer read the token reflex login saves, and reflex_build_sdk.credentials is removed: the hosting CLI owns that file. Tokens come from token= or REFLEX_ACCESS_TOKEN.

check_min_deps.py. The script skipped packages with no required dependencies, which would have left the extras' minimum versions unchecked. It now skips only packages with neither required nor optional dependencies. The SDK passes against aiohttp 3.10.0, httpx 0.25.1 and httpx2 2.0.0.

Notes for review

  • unasync.py now renames AiohttpTransport to Httpx2Transport when generating sync code, so the async client test's default-transport check becomes the sync one.
  • Most of the uv.lock diff is uv 0.12.18 reordering keys and rewriting markers; the real change is the new extras.

Testing

  • uv run pytest tests/units/reflex_build_sdk: 758 passed
  • uv run pyright, ruff, pre-commit, and scripts/check_min_deps.py reflex-build-sdk pass
  • A subprocess test blocks aiohttp, httpx and httpx2 and checks that the SDK imports and both clients raise the install hint