build(rust): bump pyo3 to 0.29 so litellm-rust compiles on Python 3.14 - #33457
build(rust): bump pyo3 to 0.29 so litellm-rust compiles on Python 3.14#33457ryan-crabbe-berri wants to merge 2 commits into
Conversation
Greptile SummaryThis PR bumps
Confidence Score: 5/5Safe to merge — the change is a focused dependency bump with three mechanical API renames; all call sites are updated, the lockfile is regenerated, and a new CI job guards against the same class of breakage recurring. All three PyO3 API rename sites (Python::with_gil → Python::attach, py.allow_threads → py.detach) are correctly updated. The pyo3 and pyo3-async-runtimes versions are kept in sync at 0.29.0 as required. The new CI job correctly uses cargo check rather than a heavier full build, namespaces its cache key to avoid collisions, and pins action SHAs. No behavior changes and no custom rules are violated. No files require special attention.
|
| Filename | Overview |
|---|---|
| litellm-rust/Cargo.toml | Bumps pyo3 to 0.29.0 and pyo3-async-runtimes to 0.29.0; versions match as required by pyo3-async-runtimes' re-export of pyo3 types. |
| litellm-rust/crates/python-bridge/src/lib.rs | Renames Python::with_gil to Python::attach in the async aocr helper; correct usage for re-acquiring the GIL after an await point. |
| litellm-rust/crates/python-bridge/src/gil.rs | Renames py.allow_threads to py.detach and updates the doc-comment; semantics unchanged. |
| litellm-rust/crates/ai-gateway/src/python/config.rs | Renames Python::with_gil to Python::attach under the python-config feature gate; no behavioral change. |
| .github/workflows/test-rust.yml | Adds a python-bridge-newest-python CI job that runs cargo check against Python 3.14; action commits are pinned to SHA, cache keys are namespaced to avoid collisions with the existing job. |
| litellm-rust/Cargo.lock | Lockfile regenerated to reflect pyo3 0.29.0 tree; removals (memoffset, indoc, unindent, futures-executor, autocfg) are expected as pyo3 0.29 dropped those dependencies. |
Reviews (1): Last reviewed commit: "ci(rust): compile the PyO3 bridge agains..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
| rustup toolchain install stable --profile minimal | ||
| rustup default stable | ||
|
|
||
| - name: Cache Cargo registry and target |
There was a problem hiding this comment.
Why do we need to cache this?
|
closign cus yuneng got it |
Relevant issues
Addresses the PyO3 half of #33116. The
requires-pythonmetadata bump it also asks for is #33438, and publishing cp314 wheels happens in the wheel build matrix outside this repo, so this PR does not auto-close the issueLinear ticket
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
@greptileaito re-request a review after pushing changes)Delays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
Before, at 24a438a (current litellm_internal_staging HEAD, with the #33438 requires-python bump applied so the build is even attempted, which is exactly what a Python 3.14 user hits once #33438 ships):
This is the same failure reported in #33116
After, at 1fc700e:
The native extension builds, loads, and round-trips a real call on 3.14: Python input marshaling, GIL release through the renamed
Python::detach(the release counter increments), the tokio runtime, and the Rust error mapped back to a PythonValueError. A 3.13 build of the same commit still succeeds (litellm-1.94.0-cp313-cp313-macosx_11_0_arm64.whl) and the existing bridge unit tests pass (34 passed)Type
🚄 Infrastructure
Changes
PyO3 0.23.5 refuses to compile against CPython 3.14 (it supports up to 3.13), so any Python 3.14 install that reaches the sdist fails in maturin. This bumps
pyo3andpyo3-async-runtimesfrom 0.23 to 0.29, the current stable line, which supports 3.14The API fallout is small because the bridge is thin:
Python::with_gilwas renamed toPython::attachandPython::allow_threadstoPython::detach(PyO3 dropped GIL-centric naming for free-threading support), so the three call sites inpython-bridgeand the feature-gated config embed inai-gatewayare renamed accordingly. No behavior changeTo keep this class of breakage from coming back silently,
test-rust.ymlgains a job that compileslitellm-python-bridgeagainst Python 3.14 viaPYO3_PYTHON; it fails on exactly the pyo3-ffi version gate shown above whenever the pinned PyO3 falls behind the CPython we claim to supportNote for release sequencing: this should land before or together with #33438. Lifting the requires-python cap without this bump would turn today's silent fallback to 1.83.7 into a hard build failure for every 3.14 pip install. Publishing cp314 wheels in the wheel build matrix remains as a follow-up so 3.14 users get prebuilt wheels instead of sdist builds
Final Attestation