fix(packaging): keep gateway sdist includes in the manifest and fail when its rust path moves

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Yujong Lee 2026-11-03 06:28:19 +09:00
parent 89f6ab22a1
commit fb3b66877d
3 changed files with 28 additions and 11 deletions

View file

@ -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" },
]

View file

@ -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)

View file

@ -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")