Build Rust extensions on demand in source checkouts (#34994)

This commit is contained in:
Lianmin Zheng
2026-08-16 14:58:06 -07:00
committed by GitHub
parent 0e231d365a
commit 67e12131df
39 changed files with 880 additions and 109 deletions
+7 -7
View File
@@ -460,7 +460,7 @@ require_prebuilt_rust_exts() {
return
fi
# Exact EXT_SUFFIX rather than a _core*.so glob: no crate sets abi3, so a module
# Exact EXT_SUFFIX rather than an _*.so glob: no crate sets abi3, so a module
# built for another minor version satisfies the glob while the import system
# ignores it, leaving is_rust_server_built() false and the Rust-server tests
# silently skipped. Stages have no setup-python, so the interpreter is whatever
@@ -469,13 +469,13 @@ require_prebuilt_rust_exts() {
local suffix
suffix=$(python3 -c 'import sysconfig; print(sysconfig.get_config_var("EXT_SUFFIX"))')
local missing=()
local pkg
for pkg in server grpc multimodal; do
[ -f "python/sglang/srt/${pkg}/_core${suffix}" ] || missing+=("${pkg}")
local module
for module in server grpc multimodal; do
[ -f "python/sglang/srt/rust_extensions/_${module}${suffix}" ] || missing+=("${module}")
done
if [ ${#missing[@]} -gt 0 ]; then
echo "::warning::no prebuilt _core${suffix} for: ${missing[*]}; building from source"
ls -l python/sglang/srt/*/_core*.so 2>/dev/null || echo "(no extension modules at all)"
echo "::warning::no prebuilt Rust extension ${suffix} for: ${missing[*]}; building from source"
ls -l python/sglang/srt/rust_extensions/_*.so 2>/dev/null || echo "(no extension modules at all)"
export SGLANG_BUILD_RUST_EXTS=
mark_step_done "${FUNCNAME[0]}"
return
@@ -812,7 +812,7 @@ print(f"sglang resolves to {spec.origin}")
# so a .so that cannot load passes find_spec and only fails inside some suite.
import importlib
for mod in ("server", "grpc", "multimodal"):
name = f"sglang.srt.{mod}._core"
name = f"sglang.srt.rust_extensions._{mod}"
try:
importlib.import_module(name)
except Exception as exc: