Skip to content

fix(gateway): make sgl-model-gateway a cargo workspace so maturin 1.14 accepts the parent README#27997

Merged
hnyls2002 merged 1 commit into
sgl-project:mainfrom
JustinTong0323:fix/gateway-maturin-readme-path
Jun 12, 2026
Merged

fix(gateway): make sgl-model-gateway a cargo workspace so maturin 1.14 accepts the parent README#27997
hnyls2002 merged 1 commit into
sgl-project:mainfrom
JustinTong0323:fix/gateway-maturin-readme-path

Conversation

@JustinTong0323

@JustinTong0323 JustinTong0323 commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

Motivation

The dev docker image build recently started failing on both build-x86 and build-arm64:

💥 maturin failed
  Caused by: `project.readme` path `../../README.md` resolves outside
             allowed metadata root `/build/sgl-model-gateway/bindings/python`

Root cause: maturin 1.14.0 added PyO3/maturin#3182 "Support parent-relative pyproject metadata in sdists", which bounds a parent-relative project.readme to the cargo workspace root (see project_layout.rs: allowed_metadata_root = if pyproject_dir.starts_with(workspace_root) { workspace_root } else { pyproject_dir }). The Dockerfiles install maturin unpinned, so they picked up 1.14.0.

sgl-model-gateway has no [workspace] — the root crate and bindings/python are independent packages — so cargo metadata reports each crate's own directory as its workspace root. bindings/python/pyproject.toml then has readme = "../../README.md", which resolves to sgl-model-gateway/README.md, outside bindings/python/, and maturin rejects it.

Because that pyproject.toml is shared by every maturin build path, this is not limited to the dev image — it also affects docker/gateway.Dockerfile, docker/rocm.Dockerfile, .github/workflows/pr-test-rust.yml, the PyPI release, and sgl-model-gateway/Makefile.

Modification

Declare sgl-model-gateway as the cargo workspace root with bindings/python as a member (the golang bindings and wasm examples stay standalone via exclude):

[workspace]
members = ["bindings/python"]
exclude = ["bindings/golang", "examples"]

Now cargo metadata from bindings/python reports sgl-model-gateway/ as the workspace root, which contains README.md, so the existing readme = "../../README.md" resolves inside the allowed metadata root. This is exactly the layout maturin #3182 is designed for.

  • No change to which README ships on PyPI — the readme field is untouched, still the repo-root gateway README.
  • Version-agnostic — fixes every maturin build path in one place rather than pinning maturin in 6+ scripts.
  • Build profiles (release/ci/dev) already exist at the workspace root, so the now-redundant [profile.ci] in bindings/python/Cargo.toml (byte-identical to the root one) is dropped — cargo ignores profile tables in workspace members anyway.

Why the lib.rs formatting changes?

bindings/python was previously its own standalone crate, so the rustfmt sgl-model-gateway pre-commit hook (cd sgl-model-gateway && cargo +nightly fmt -- --check) never reached bindings/python/src/lib.rs. Making it a workspace member brings it under the gateway's rustfmt.toml (group_imports = "StdExternalCrate", imports_granularity = "Crate") for the first time, which is what the Lint job flagged. The lib.rs change is purely that one-time cargo +nightly fmt normalization (import grouping + chain/struct wrapping) — no logic change.

Checklist

  • Format your code according to the Code Formatting with Pre-Commit.
  • [profile.ci] (used by pr-test-rust.yml --profile ci) is preserved at the workspace root, identical to the dropped member copy.

Testing: https://github.com/sgl-project/sglang/actions/runs/27394688617/job/80959410404


CI States

Latest PR Test (Base): ✅ Run #27395362207
Latest PR Test (Extra): ❌ Run #27395362141

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@github-actions github-actions Bot added dependencies Pull requests that update a dependency file model-gateway labels Jun 12, 2026
@JustinTong0323

Copy link
Copy Markdown
Collaborator Author

/tag-run-ci-label

@JustinTong0323

Copy link
Copy Markdown
Collaborator Author

/tag-and-rerun-ci

@JustinTong0323

Copy link
Copy Markdown
Collaborator Author

Very strange issue...

@JustinTong0323 JustinTong0323 force-pushed the fix/gateway-maturin-readme-path branch from 5fa37be to 43a1ed4 Compare June 12, 2026 04:29
@JustinTong0323 JustinTong0323 changed the title fix(gateway): point python bindings readme to local README (unbreak maturin 1.14 build) fix(gateway): make sgl-model-gateway a cargo workspace so maturin 1.14 accepts the parent README Jun 12, 2026
@JustinTong0323 JustinTong0323 force-pushed the fix/gateway-maturin-readme-path branch from 43a1ed4 to 60ef806 Compare June 12, 2026 04:40
maturin 1.14 (PyO3/maturin#3182, "Support parent-relative pyproject
metadata in sdists") bounds a parent-relative `project.readme` to the
cargo workspace root. sgl-model-gateway has no [workspace], so cargo
metadata reports each crate's own directory as the workspace root and
the python bindings' `readme = "../../README.md"` is rejected:

  `project.readme` path `../../README.md` resolves outside allowed
  metadata root `/build/sgl-model-gateway/bindings/python`

This breaks every `maturin build` run from bindings/python (the dev,
gateway and rocm docker images, pr-test-rust, and the PyPI release).

Declare sgl-model-gateway as the workspace root with bindings/python as
a member; the golang bindings and wasm examples stay standalone via
`exclude`. The workspace root now contains README.md, so the existing
parent-relative readme resolves inside the allowed root with no change
to which README ships on PyPI. Build profiles already live at the
workspace root, so the duplicate [profile.ci] in bindings/python is
dropped (workspace members' profile tables are ignored by cargo).

Joining the workspace also brings bindings/python/src/lib.rs under the
gateway rustfmt config, so apply `cargo +nightly fmt` to it.
@JustinTong0323 JustinTong0323 force-pushed the fix/gateway-maturin-readme-path branch from 60ef806 to a68f5b8 Compare June 12, 2026 04:53

@dougyster dougyster left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hnyls2002 hnyls2002 merged commit 66ab5c9 into sgl-project:main Jun 12, 2026
86 of 92 checks passed
laixinn pushed a commit to laixinn/sglang that referenced this pull request Jun 15, 2026
JustinTong0323 added a commit that referenced this pull request Jun 15, 2026
… a cargo workspace so maturin 1.14 accepts the parent README (#27997) (#28252)

Co-authored-by: Xinyuan Tong <115166877+JustinTong0323@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file model-gateway run-ci

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants