Skip to content

[HTTPXodus] migrate httpx to httpx2 with dual import - #471

Open
ProgrammerPlus1998 wants to merge 1 commit into
replicate:mainfrom
ProgrammerPlus1998:httpxodus/httpx2-migration
Open

[HTTPXodus] migrate httpx to httpx2 with dual import#471
ProgrammerPlus1998 wants to merge 1 commit into
replicate:mainfrom
ProgrammerPlus1998:httpxodus/httpx2-migration

Conversation

@ProgrammerPlus1998

@ProgrammerPlus1998 ProgrammerPlus1998 commented Sep 4, 2026

Copy link
Copy Markdown

Closes #470

🏷️ Part of HTTPXodus — a community effort to help major Python projects plan their path off the stalled httpx stable line onto httpx2, the actively maintained fork by Pydantic Services. One coordinated PR per project — no drive-by changes.

What this PR does

This is the implementation of the migration discussed in the linked issue. It switches replicate/replicate-python's HTTP client from httpx to httpx2 via dual import: on Python ≥ 3.10 the runtime binds to httpx2; on 3.9 the import falls back to httpx. requires-python is not changed.

Diff summary

N files, +A / −B (commit f2fb991):

File Change
pyproject.toml Added httpx2>=2.12.0; python_version >= "3.10" next to the existing httpx runtime dep
replicate/** All import httpx → dual import (Option A)

The public API surface is preserved because the dual-import alias keeps the name httpx everywhere. No call-site changes are needed beyond the import.

Test results

Validated in a fresh venv on Python 3.12 with both httpx and httpx2 installed (SUT resolves to httpx2):

  • pip install -e ".[dev]" resolves to both
  • python -c "import replicate; ..." smoke test passes
  • Full pytest requires live API credentials; not run in this dev env

Notes for reviewer

  • The httpx.Client / httpx.AsyncClient / httpx.Response.raise_for_status() types used in replicate exist in both httpx and httpx2 with identical signatures, so no call-site changes are needed beyond the import.
  • ⚠️ TLS behavior change: httpx2 verifies TLS against the OS trust store instead of the bundled certifi. Replicate SDK deployments that rely on a custom CA bundle may need SSL_CERT_FILE / SSL_CERT_DIR after the switch. Worth a line in the changelog.
  • Dual import is the right call here: replicate-python's requires-python floor is below httpx2's >=3.10 floor, and dropping 3.9 would be out of scope. If replicate-python later raises the floor, this can be replaced with a hard import httpx2 as httpx in a follow-up.

Happy to revise per review — and equally happy to close this PR if the maintainers would rather wait for httpx 1.0 stable. 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[HTTPXodus] Consider migrating from httpx to httpx2 (the actively maintained fork)

1 participant