From 62e4de3c8244b705120331f61c2d312e5887f409 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Tue, 10 Nov 2026 20:07:54 +0000 Subject: [PATCH] chore: move Rust toolchain and Cargo configuration into the workspace --- .github/actions/setup-uv-with-retries/action.yml | 5 +++++ .github/scripts/ci/classify_changes.sh | 4 ++-- .github/scripts/setup_rust_environment.sh | 13 +++++++++++++ .../workflows/test-mcp-dependency-resolution.yml | 2 +- .github/workflows/test-rust-db.yml | 8 ++++---- .github/workflows/test-rust.yml | 12 +++++++----- Makefile | 4 ++++ litellm/deploy/docker/Dockerfile | 3 +++ litellm/packaging/litellm-core/pyproject.toml | 4 ++-- litellm/packaging/litellm-proxy/pyproject.toml | 4 ++-- {.cargo => litellm/rust/.cargo}/config.toml | 0 .../rust/rust-toolchain.toml | 0 pyproject.toml | 8 ++++---- tests/unit/test_ci_path_filter.py | 2 +- 14 files changed, 48 insertions(+), 21 deletions(-) create mode 100644 .github/scripts/setup_rust_environment.sh rename {.cargo => litellm/rust/.cargo}/config.toml (100%) rename rust-toolchain.toml => litellm/rust/rust-toolchain.toml (100%) diff --git a/.github/actions/setup-uv-with-retries/action.yml b/.github/actions/setup-uv-with-retries/action.yml index a99716f5eac..15efaf63c54 100644 --- a/.github/actions/setup-uv-with-retries/action.yml +++ b/.github/actions/setup-uv-with-retries/action.yml @@ -11,6 +11,11 @@ inputs: runs: using: composite steps: + - name: Configure the Rust build environment + shell: bash + working-directory: ${{ github.workspace }} + run: bash .github/scripts/setup_rust_environment.sh + - name: Set up uv (attempt 1) id: attempt-1 continue-on-error: true diff --git a/.github/scripts/ci/classify_changes.sh b/.github/scripts/ci/classify_changes.sh index 4f46be4d952..f78c76bda77 100755 --- a/.github/scripts/ci/classify_changes.sh +++ b/.github/scripts/ci/classify_changes.sh @@ -19,11 +19,11 @@ while IFS= read -r file || [ -n "$file" ]; do esac case "$file" in *.md | *.mdx) : ;; - pyproject.toml | */pyproject.toml | uv.lock | uv.toml | .python-version | rust-toolchain.toml | litellm/rust/* | litellm/__init__.py | litellm/proxy/proxy_server.py | litellm/*mcp* | tests/*mcp* | litellm/integrations/arize/* | tests/base_sdk_tests/* | litellm/scripts/check_mcp_sdk_install.py | .github/workflows/test-mcp-dependency-resolution.yml | .github/actions/detect-changes/* | .github/actions/setup-uv-with-retries/* | .github/actions/cache-cargo-build/* | .github/scripts/detect_changes.sh | .github/scripts/uv_sync_with_retries.sh | .github/scripts/ci/classify_changes.sh | tests/unit/test_ci_path_filter.py | tests/unit/test_detect_changes.py) + pyproject.toml | */pyproject.toml | uv.lock | uv.toml | .python-version | litellm/rust/* | litellm/__init__.py | litellm/proxy/proxy_server.py | litellm/*mcp* | tests/*mcp* | litellm/integrations/arize/* | tests/base_sdk_tests/* | litellm/scripts/check_mcp_sdk_install.py | .github/workflows/test-mcp-dependency-resolution.yml | .github/actions/detect-changes/* | .github/actions/setup-uv-with-retries/* | .github/actions/cache-cargo-build/* | .github/scripts/detect_changes.sh | .github/scripts/uv_sync_with_retries.sh | .github/scripts/ci/classify_changes.sh | tests/unit/test_ci_path_filter.py | tests/unit/test_detect_changes.py) has_mcp_dependencies=true ;; esac case "$file" in - litellm/rust/* | litellm/rust_bridge/* | rust-toolchain.toml | pyproject.toml | uv.lock | tests/windows_tests/* | .github/scripts/ci/* | .github/actions/*) + litellm/rust/* | litellm/rust_bridge/* | pyproject.toml | uv.lock | tests/windows_tests/* | .github/scripts/ci/* | .github/actions/*) has_windows_release=true ;; esac case "$file" in diff --git a/.github/scripts/setup_rust_environment.sh b/.github/scripts/setup_rust_environment.sh new file mode 100644 index 00000000000..ec9228bc1d2 --- /dev/null +++ b/.github/scripts/setup_rust_environment.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +set -euo pipefail + +root=$(git rev-parse --show-toplevel) +toolchain=$(sed -n 's/^[[:space:]]*channel[[:space:]]*=[[:space:]]*"\([^"]*\)".*/\1/p' "$root/litellm/rust/rust-toolchain.toml") +test -n "$toolchain" +rustup toolchain install "$toolchain" --profile minimal --component rustfmt --component clippy --no-self-update +{ + echo "RUSTUP_TOOLCHAIN=$toolchain" + echo "CARGO_NET_RETRY=5" + echo "CARGO_HTTP_MULTIPLEXING=false" + echo "SQLX_OFFLINE=${SQLX_OFFLINE:-true}" +} >> "${GITHUB_ENV:?GITHUB_ENV is required}" diff --git a/.github/workflows/test-mcp-dependency-resolution.yml b/.github/workflows/test-mcp-dependency-resolution.yml index 49bd5719a2b..095c138c4fe 100644 --- a/.github/workflows/test-mcp-dependency-resolution.yml +++ b/.github/workflows/test-mcp-dependency-resolution.yml @@ -10,7 +10,7 @@ on: - "uv.lock" - "uv.toml" - ".python-version" - - "rust-toolchain.toml" + - "litellm/rust/rust-toolchain.toml" - "litellm/rust/**" - "litellm/__init__.py" - "litellm/_version.py" diff --git a/.github/workflows/test-rust-db.yml b/.github/workflows/test-rust-db.yml index 309843a11d5..6d4eba7b25e 100644 --- a/.github/workflows/test-rust-db.yml +++ b/.github/workflows/test-rust-db.yml @@ -9,8 +9,8 @@ on: - "litellm/rust/clippy.toml" - "litellm/proxy-extras/litellm_proxy_extras/migrations/**" - "**/schema.prisma" - - ".cargo/**" - - "rust-toolchain.toml" + - "litellm/rust/.cargo/**" + - "litellm/rust/rust-toolchain.toml" - "pyproject.toml" - "uv.lock" - ".github/actions/setup-uv-with-retries/**" @@ -26,8 +26,8 @@ on: - "litellm/rust/clippy.toml" - "litellm/proxy-extras/litellm_proxy_extras/migrations/**" - "**/schema.prisma" - - ".cargo/**" - - "rust-toolchain.toml" + - "litellm/rust/.cargo/**" + - "litellm/rust/rust-toolchain.toml" - "pyproject.toml" - "uv.lock" - ".github/actions/setup-uv-with-retries/**" diff --git a/.github/workflows/test-rust.yml b/.github/workflows/test-rust.yml index 386685f9c13..74a6957aba4 100644 --- a/.github/workflows/test-rust.yml +++ b/.github/workflows/test-rust.yml @@ -24,10 +24,10 @@ on: - "litellm/llms/base_llm/ocr/**" - "litellm/llms/custom_httpx/llm_http_handler.py" - "Makefile" - - ".cargo/**" + - "litellm/rust/.cargo/**" - "pyproject.toml" - "uv.lock" - - "rust-toolchain.toml" + - "litellm/rust/rust-toolchain.toml" - ".github/actions/setup-uv-with-retries/**" - ".github/scripts/smoke_test_native_wheel.py" - ".github/scripts/verify_linux_native_wheel.py" @@ -59,10 +59,10 @@ on: - "litellm/llms/base_llm/ocr/**" - "litellm/llms/custom_httpx/llm_http_handler.py" - "Makefile" - - ".cargo/**" + - "litellm/rust/.cargo/**" - "pyproject.toml" - "uv.lock" - - "rust-toolchain.toml" + - "litellm/rust/rust-toolchain.toml" - ".github/actions/setup-uv-with-retries/**" - ".github/scripts/smoke_test_native_wheel.py" - ".github/scripts/verify_linux_native_wheel.py" @@ -96,7 +96,9 @@ jobs: with: persist-credentials: false - - run: rustup toolchain install --no-self-update + - name: Configure the Rust build environment + working-directory: . + run: bash .github/scripts/setup_rust_environment.sh - run: cargo fmt --all --check diff --git a/Makefile b/Makefile index 8ce85098dd4..63fab29d9b5 100644 --- a/Makefile +++ b/Makefile @@ -60,6 +60,10 @@ help: @echo "slots (default 2; 0 disables) so parallel sessions don't thrash one machine." UV := uv +export RUSTUP_TOOLCHAIN ?= $(shell sed -n 's/^[[:space:]]*channel[[:space:]]*=[[:space:]]*"\([^"]*\)".*/\1/p' litellm/rust/rust-toolchain.toml) +export CARGO_NET_RETRY ?= 5 +export CARGO_HTTP_MULTIPLEXING ?= false +export SQLX_OFFLINE ?= true UV_RUN := $(UV) run --no-sync BASE_REF ?= export BASE_REF diff --git a/litellm/deploy/docker/Dockerfile b/litellm/deploy/docker/Dockerfile index 0b109b12640..5c48c83c8e3 100644 --- a/litellm/deploy/docker/Dockerfile +++ b/litellm/deploy/docker/Dockerfile @@ -68,6 +68,9 @@ RUN apk add --no-cache \ libsndfile ENV UV_PROJECT_ENVIRONMENT=/app/.venv \ + CARGO_NET_RETRY=5 \ + CARGO_HTTP_MULTIPLEXING=false \ + SQLX_OFFLINE=true \ UV_LINK_MODE=copy \ UV_PYTHON_DOWNLOADS=0 \ PATH="/app/.venv/bin:${PATH}" diff --git a/litellm/packaging/litellm-core/pyproject.toml b/litellm/packaging/litellm-core/pyproject.toml index 121a902a730..2b45c2357e1 100644 --- a/litellm/packaging/litellm-core/pyproject.toml +++ b/litellm/packaging/litellm-core/pyproject.toml @@ -54,8 +54,8 @@ features = ["extension-module"] profile = "release" editable-profile = "dev" include = [ - { path = "rust-toolchain.toml", format = "sdist" }, - { path = ".cargo/config.toml", format = "sdist" }, + { path = "litellm/rust/rust-toolchain.toml", format = "sdist" }, + { path = "litellm/rust/.cargo/config.toml", format = "sdist" }, { path = "model_prices_and_context_window.json", format = "sdist" }, "litellm/router_strategy/complexity_router/artifacts/*.json", "litellm/router_strategy/complexity_router/fuse_presets.json", diff --git a/litellm/packaging/litellm-proxy/pyproject.toml b/litellm/packaging/litellm-proxy/pyproject.toml index 31dde8526bb..4b9de6f848e 100644 --- a/litellm/packaging/litellm-proxy/pyproject.toml +++ b/litellm/packaging/litellm-proxy/pyproject.toml @@ -16,7 +16,7 @@ targets = [{ name = "litellm-gateway", kind = "bin" }] profile = "release" editable-profile = "dev" include = [ - { path = "rust-toolchain.toml", format = "sdist" }, - { path = ".cargo/config.toml", format = "sdist" }, + { path = "litellm/rust/rust-toolchain.toml", format = "sdist" }, + { path = "litellm/rust/.cargo/config.toml", format = "sdist" }, { path = "model_prices_and_context_window.json", format = "sdist" }, ] diff --git a/.cargo/config.toml b/litellm/rust/.cargo/config.toml similarity index 100% rename from .cargo/config.toml rename to litellm/rust/.cargo/config.toml diff --git a/rust-toolchain.toml b/litellm/rust/rust-toolchain.toml similarity index 100% rename from rust-toolchain.toml rename to litellm/rust/rust-toolchain.toml diff --git a/pyproject.toml b/pyproject.toml index faecaaac034..c1e11ddc2df 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -339,8 +339,8 @@ features = ["extension-module"] profile = "release" editable-profile = "dev" include = [ - { path = "rust-toolchain.toml", format = "sdist" }, - { path = ".cargo/config.toml", format = "sdist" }, + { path = "litellm/rust/rust-toolchain.toml", format = "sdist" }, + { path = "litellm/rust/.cargo/config.toml", format = "sdist" }, "litellm/integrations/prometheus_helpers/grafana_dashboards/**", "litellm/proxy/_experimental/out/**", "litellm/router_strategy/complexity_router/artifacts/*.json", @@ -392,8 +392,8 @@ exclude = [ concurrent-builds = 1 cache-keys = [ { file = "pyproject.toml" }, - { file = "rust-toolchain.toml" }, - { file = ".cargo/config.toml" }, + { file = "litellm/rust/rust-toolchain.toml" }, + { file = "litellm/rust/.cargo/config.toml" }, { file = "litellm/rust/Cargo.lock" }, { file = "litellm/rust/Cargo.toml" }, { file = "litellm/rust/crates/**/*" }, diff --git a/tests/unit/test_ci_path_filter.py b/tests/unit/test_ci_path_filter.py index ef4b87adaea..bd90c40524d 100644 --- a/tests/unit/test_ci_path_filter.py +++ b/tests/unit/test_ci_path_filter.py @@ -61,7 +61,7 @@ CI = [".github/workflows/test-unit.yml"] ("mcp-dependencies", DOCS + CLIENT, "skip"), ("windows-release", ["litellm/rust/crates/inference/src/lib.rs"], "run"), ("windows-release", ["litellm/rust_bridge/dispatch.py"], "run"), - ("windows-release", ["rust-toolchain.toml"], "run"), + ("windows-release", ["litellm/rust/rust-toolchain.toml"], "run"), ("windows-release", ["pyproject.toml"], "run"), ("windows-release", ["uv.lock"], "run"), ("windows-release", ["tests/windows_tests/check_windows_wheel_install.py"], "run"),