From fb3b66877dc63f0a720a00256bfe619cb71d4caf Mon Sep 17 00:00:00 2001 From: Yujong Lee Date: Tue, 3 Nov 2026 06:28:19 +0900 Subject: [PATCH] fix(packaging): keep gateway sdist includes in the manifest and fail when its rust path moves Co-Authored-By: Claude Opus 5.5 --- packaging/litellm-gateway/pyproject.toml | 5 +++++ scripts/build_core_distribution.py | 16 +++++----------- tests/base_sdk_tests/test_core_distribution.py | 18 ++++++++++++++++++ 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/packaging/litellm-gateway/pyproject.toml b/packaging/litellm-gateway/pyproject.toml index e14b5847f79..1bacea4cff0 100644 --- a/packaging/litellm-gateway/pyproject.toml +++ b/packaging/litellm-gateway/pyproject.toml @@ -15,3 +15,8 @@ bindings = "bin" 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 = "model_prices_and_context_window.json", format = "sdist" }, +] diff --git a/scripts/build_core_distribution.py b/scripts/build_core_distribution.py index ee50422f6db..30573471f5f 100644 --- a/scripts/build_core_distribution.py +++ b/scripts/build_core_distribution.py @@ -19,6 +19,8 @@ SOURCES: Final = ( "LICENSE", ) +IN_TREE_RUST_PATH: Final = "../../litellm-rust/" + class BuildOptions(argparse.Namespace): package: str @@ -69,17 +71,9 @@ def stage_core_distribution(source: Path, destination: Path, *, package: str = " else: shutil.copy2(path, destination / name) template: Final = (source / "packaging" / package / "pyproject.toml").read_text() - metadata: Final = ( - template.replace("../../litellm-rust/", "litellm-rust/") - + "\ninclude = [\n" - + ",\n".join( - f' {{ path = "{name}", format = "sdist" }}' - for name in ("rust-toolchain.toml", ".cargo/config.toml", "model_prices_and_context_window.json") - ) - + "\n]\n" - if package == "litellm-gateway" - else template - ) + if package == "litellm-gateway" and IN_TREE_RUST_PATH not in template: + raise SystemExit(f"packaging/{package}/pyproject.toml no longer points at {IN_TREE_RUST_PATH}") + metadata: Final = template.replace(IN_TREE_RUST_PATH, "litellm-rust/") (destination / "pyproject.toml").write_text(metadata) subprocess.run(["uv", "version", version, "--frozen"], cwd=destination, check=True) diff --git a/tests/base_sdk_tests/test_core_distribution.py b/tests/base_sdk_tests/test_core_distribution.py index ce7f3d2bf15..305ee14053a 100644 --- a/tests/base_sdk_tests/test_core_distribution.py +++ b/tests/base_sdk_tests/test_core_distribution.py @@ -77,6 +77,24 @@ def test_staging_stamps_release_version_without_modifying_sources( assert all((stage / name).read_bytes() == (source / name).read_bytes() for name in expected) +def test_gateway_staging_refuses_manifest_without_in_tree_rust_path(tmp_path: Path, source_repository: Path) -> None: + from scripts.build_core_distribution import SOURCES, stage_core_distribution + + source: Final = source_repository + for name in SOURCES: + (source / name).write_text(f"shared {name}") + (source / "pyproject.toml").write_text('[project]\nname = "litellm"\nversion = "9.8.7"\n') + manifest: Final = source / "packaging" / "litellm-gateway" / "pyproject.toml" + manifest.parent.mkdir(parents=True) + manifest.write_text( + (ROOT / "packaging" / "litellm-gateway" / "pyproject.toml") + .read_text() + .replace("../../litellm-rust/", "../../rust/") + ) + with pytest.raises(SystemExit, match="no longer points at"): + stage_core_distribution(source, tmp_path / "stage", package="litellm-gateway") + + @pytest.fixture(scope="module") def distribution_directory() -> Path: directory: Final = os.environ.get("CORE_DISTRIBUTION_DIR")