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
+9 -9
View File
@@ -1,5 +1,5 @@
#!/bin/bash
# Copy the built PyO3 extension modules into rust-ext-staging/<pkg>/ for
# Copy the built PyO3 extension modules into rust-ext-staging/rust_extensions/ for
# upload-artifact. Shared by both jobs of _pr-test-rust-ext-build.yml, so the
# archive layout and the module-count check cannot drift between them.
#
@@ -12,24 +12,24 @@ shopt -s nullglob
# module would silently shift the archive layout.
rm -rf rust-ext-staging
built=()
# Same suffix set across pkgs, or one ABI's Rust-server tests silently skip.
# Same suffix set across modules, or one ABI's Rust-server tests silently skip.
expected_suffixes=""
for pkg in server grpc multimodal; do
found=(python/sglang/srt/"${pkg}"/_core*.so)
mkdir -p rust-ext-staging/rust_extensions
for module in server grpc multimodal; do
found=(python/sglang/srt/rust_extensions/_"${module}"*.so)
if [ ${#found[@]} -eq 0 ]; then
echo "::error::no extension module found for ${pkg}"
echo "::error::no extension module found for ${module}"
exit 1
fi
suffixes=$(printf '%s\n' "${found[@]##*/_core}" | sort)
suffixes=$(printf '%s\n' "${found[@]##*/_${module}}" | sort)
if [ -z "${expected_suffixes}" ]; then
expected_suffixes="${suffixes}"
elif [ "${suffixes}" != "${expected_suffixes}" ]; then
echo "::error::extension modules for ${pkg} do not match server's interpreter set"
echo "::error::extension modules for ${module} do not match server's interpreter set"
printf 'have:\n%s\nwant:\n%s\n' "${suffixes}" "${expected_suffixes}"
exit 1
fi
mkdir -p "rust-ext-staging/${pkg}"
cp "${found[@]}" "rust-ext-staging/${pkg}/"
cp "${found[@]}" rust-ext-staging/rust_extensions/
built+=("${found[@]}")
done
max_allowed="${MAX_GLIBC:-}"