Skip to content

fix(packaging): support Python 3.14 builds - #33120

Open
devin-ai-integration[bot] wants to merge 3 commits into
litellm_internal_stagingfrom
litellm_fix_python314_pyo3
Open

fix(packaging): support Python 3.14 builds#33120
devin-ai-integration[bot] wants to merge 3 commits into
litellm_internal_stagingfrom
litellm_fix_python314_pyo3

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Relevant issues

Fixes #33116

Linear ticket

Pre-Submission checklist

  • I have added meaningful tests
  • My PR passes all CI/CD checks (e.g., lint, format, unit tests)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review (Greptile reviews automatically once the PR is opened; only comment @greptileai to 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 f448ea5762:

$ uv build --wheel --python 3.14 --out-dir /tmp/litellm-wheel
error: the configured Python interpreter version (3.14) is newer than PyO3's maximum supported version (3.13)
Current version: 0.23.5
Error: command ['maturin', 'pep517', 'build-wheel', ...] returned non-zero exit status 1

After at 8cf53d446f:

$ uv build --wheel --python 3.14 --out-dir /tmp/litellm-wheel
Found CPython 3.14
Built wheel for CPython 3.14
Successfully built litellm-1.93.0-cp314-cp314-linux_x86_64.whl

$ uv pip install --python /tmp/litellm-py314/bin/python /tmp/litellm-wheel/litellm-1.93.0-cp314-cp314-linux_x86_64.whl
Installed 48 packages

$ /tmp/litellm-py314/bin/python -c 'import sys; import litellm; from litellm.rust_bridge import _native; print(sys.version.split()[0], litellm.__file__, _native.gil_stats())'
3.14.3 /tmp/litellm-py314/lib/python3.14/site-packages/litellm/__init__.py {'releases': 0}

The python-config feature path (used by the Dockerfile with --features python-config) also compiles clean under 0.29:

$ cargo clippy -p litellm-ai-gateway --all-targets --features server,python-config -- -D warnings
Finished dev profile

Type

Bug Fix

Test

Changes

Upgrades pyo3 and pyo3-async-runtimes from 0.23 to the aligned 0.29 series, with the corresponding allow_threads to detach and with_gil to attach API migrations. This covers both python-bridge and the python-config feature path in ai-gateway/src/python/config.rs, which the standard CI clippy step did not previously exercise

Extends package metadata and the uv lock to Python 3.14, updates installer compatibility text, and adds CI that builds a CPython 3.14 wheel plus a clippy run over the python-config feature so the Dockerfile build path stays covered

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

Link to Devin session: https://app.devin.ai/sessions/9c98d988360a42cd85a1f606b4a75844

@devin-ai-integration
devin-ai-integration Bot requested a review from a team July 13, 2026 21:09
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@greptile-apps

greptile-apps Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR upgrades pyo3 and pyo3-async-runtimes from 0.23 to 0.29 and migrates the corresponding API calls (with_gilattach, allow_threadsdetach), enabling the package to build wheels for Python 3.14. It also extends pyproject.toml to declare 3.14 support and adds CI coverage for the previously untested python-config Cargo feature.

  • pyo3 0.29 API migration: Python::with_gil replaced with Python::attach in both python-bridge/src/lib.rs and ai-gateway/src/python/config.rs; py.allow_threads replaced with py.detach in python-bridge/src/gil.rs.
  • Python 3.14 packaging: pyproject.toml adds the Programming Language :: Python :: 3.14 classifier and tightens requires-python to >=3.10, <3.15; uv.lock updated accordingly.
  • CI hardening: test-rust.yml now sets up Python 3.14 + uv, runs a dedicated clippy pass over --features python-config, and builds a 3.14 wheel — closing the gap where the Dockerfile build path was not exercised in CI.

Confidence Score: 5/5

Safe to merge — all three changed Rust call sites correctly adopt the pyo3 0.29 API, the packaging metadata is consistent, and the new CI steps verify both the wheel build and the previously uncovered python-config feature path.

The pyo3 API migration is mechanically straightforward and all three call sites (lib.rs, config.rs, gil.rs) are updated correctly. The pyproject.toml upper bound (<3.15) is consistent with the newly added 3.14 classifier. The CI additions give direct evidence the wheel builds successfully on 3.14, and the --features python-config clippy step closes the gap for the Dockerfile path. The one lingering item — a stale Python::allow_threads reference in the module-level doc comment of gil.rs — was flagged in a prior review and is cosmetic.

No files require special attention; litellm-rust/crates/python-bridge/src/gil.rs has an outstanding stale doc-comment nit from a prior review cycle that is still unaddressed.

Important Files Changed

Filename Overview
.github/workflows/test-rust.yml Adds Python 3.14 + uv setup steps, a separate clippy run for the python-config feature, and a wheel build step; CI path triggers also extended to cover pyproject.toml and uv.lock changes.
litellm-rust/Cargo.toml Bumps pyo3 and pyo3-async-runtimes from 0.23 to 0.29.0, the minimum version required for Python 3.14 support.
litellm-rust/crates/python-bridge/src/gil.rs Migrates py.allow_threads to py.detach (pyo3 0.29 API); the module-level doc comment on line 4 still references the old Python::allow_threads name (flagged in prior review).
litellm-rust/crates/python-bridge/src/lib.rs Migrates Python::with_gil to Python::attach in the aocr async helper; usage is correct and consistent with pyo3 0.29.
litellm-rust/crates/ai-gateway/src/python/config.rs Migrates Python::with_gil to Python::attach in the boot-time config loader; record_acquisition is called correctly before attach, matching the Dockerfile python-config path.
pyproject.toml Adds Python 3.14 classifier and tightens requires-python to >=3.10, <3.15, correctly bounding the newly supported version range.
scripts/install.sh Comment updated to reference 3.15+ instead of the old upper bound; no logic change.
scripts/install-cli.sh Comment updated to reference 3.15+ instead of the old upper bound; no logic change.

Reviews (2): Last reviewed commit: "fix(rust): migrate python-config GIL cal..." | Re-trigger Greptile

@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@codspeed-hq

codspeed-hq Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing litellm_fix_python314_pyo3 (8cf53d4) with litellm_internal_staging (0c376d8)1

Open in CodSpeed

Footnotes

  1. No successful run was found on litellm_internal_staging (c0ff81a) during the generation of this report, so 0c376d8 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

Fixed: migrated the python-config feature path in ai-gateway/src/python/config.rs from Python::with_gil to Python::attach, and added a CI clippy step over --features python-config so the Dockerfile build path is now covered

@greptileai

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.

[Bug]: Python 3.14 install fails because litellm-rust uses PyO3 0.23.5

1 participant