feat: package Rust OCR bridge in LiteLLM wheel - #31267
Conversation
|
|
1ffe1d8 to
d0b3c8f
Compare
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This comment has been minimized.
This comment has been minimized.
|
Requesting fresh bot review on latest head Greptile findings have been addressed:
Veria status on latest head: passing, @greptile-apps please re-review the latest head. |
|
@greptile review |
c67e1d0 to
2ae93b1
Compare
70842d8 to
ad4dff1
Compare
|
CI is green on final head |
BerriAI#31267 switched the build backend to maturin to bundle the Rust OCR bridge into the litellm wheel. On the release runner, maturin builds with `--compatibility off` and emits a `cp312-cp312-linux_x86_64` wheel. PyPI only accepts `manylinux*` Linux wheels, so the upload is rejected with `400 Bad Request - unsupported platform tag 'linux_x86_64'`, which blocked the 1.91.0.dev2 publish. Revert `[build-system]` to the pure-Python `uv_build` backend and restore `[tool.uv.build-backend]` so the release once again produces a universal `litellm-<ver>-py3-none-any.whl` that installs on every OS / arch / Python. The Rust bridge stays optional: `litellm/rust_bridge/loader.py` already falls back gracefully when `_native` is absent (`try/except ImportError`), so runtime behavior is unchanged - the native module is simply not bundled. Rust acceleration can ship as a separate platform-specific package later.
What changed
Packages the existing Rust OCR bridge inside the default
litellmpip wheel instead of creating a separate Rust wheel package.uv_buildtomaturinso the PyO3 crate can be built aslitellm.rust_bridge._native.uv buildstill works as the build frontend; the previousuv_buildsource excludes were ported to[tool.maturin].exclude.litellm/proxy/enterprisewith both the bare directory and recursive/**pattern.Related install-report issue: #31261
Why this shape
We looked at the Pydantic/Polars packaging pattern: ship the native Rust extension inside the default Python package, with
maturin/PyO3 building platform wheels. That avoids a second LiteLLM package for users while still letting us split the bridge later if needed because Python calls it throughlitellm.rust_bridge.Validation
uv lockuv build --sdist --wheellitellm/rust_bridge/_native...solitellm/rust_bridge/loader.pylitellm/proxy/enterpriseuv run black litellm/rust_bridge litellm/ocr/rust_bridge.py tests/test_litellm/ocr/test_rust_bridge.pyuv run ruff check litellm/rust_bridge litellm/ocr/rust_bridge.py tests/test_litellm/ocr/test_rust_bridge.pyuv run pytest tests/test_litellm/ocr/test_rust_bridge.py -q(19 passed)(cd litellm-rust && cargo fmt --check && cargo clippy --workspace --all-targets --locked -- -D warnings && cargo test --workspace --locked)using_litellm_on_windowspassed after adding Rust to that Windows build jobReview status
litellm/proxy/enterprise/**exclude and missing negative-cache in the native loader; both are fixed in the latest commit and covered by artifact inspection/tests.No security issues found.