diff --git a/scripts/ci/cuda/ci_install_dependency.sh b/scripts/ci/cuda/ci_install_dependency.sh index afd0383bb..ab2614e82 100755 --- a/scripts/ci/cuda/ci_install_dependency.sh +++ b/scripts/ci/cuda/ci_install_dependency.sh @@ -149,7 +149,12 @@ fi # Install protoc bash "${SCRIPT_DIR}/../utils/install_protoc.sh" -mark_step_done "Python package site hygiene & install protoc" +# Install Rust toolchain (needed by crates built via setuptools-rust, e.g. the +# native gRPC extension bundled into the sglang wheel). +bash "${SCRIPT_DIR}/../utils/install_rustup.sh" +export PATH="${CARGO_HOME:-$HOME/.cargo}/bin:${PATH}" + +mark_step_done "Python package site hygiene & install protoc + rust" # ------------------------------------------------------------------------------ # Pip / uv toolchain & stale package cleanup diff --git a/scripts/ci/npu/npu_ci_install_dependency.sh b/scripts/ci/npu/npu_ci_install_dependency.sh index 4accb8e23..e180cf083 100755 --- a/scripts/ci/npu/npu_ci_install_dependency.sh +++ b/scripts/ci/npu/npu_ci_install_dependency.sh @@ -32,6 +32,12 @@ export UV_NO_CACHE=true export UV_SYSTEM_PYTHON=true export UV_INDEX_STRATEGY=unsafe-best-match +# Install Rust toolchain (needed by crates built via setuptools-rust, e.g. the +# native gRPC extension bundled into the sglang wheel). +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +bash "${SCRIPT_DIR}/../utils/install_rustup.sh" +export PATH="${CARGO_HOME:-$HOME/.cargo}/bin:${PATH}" + # Pin wheel to 0.45.1, REF: https://github.com/pypa/wheel/issues/662 ${UV_PIP_INSTALL} wheel==0.45.1 pybind11 pyyaml decorator scipy attrs psutil diff --git a/scripts/ci/utils/install_rustup.sh b/scripts/ci/utils/install_rustup.sh new file mode 100755 index 000000000..2b8d11f2c --- /dev/null +++ b/scripts/ci/utils/install_rustup.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# Ensure a Rust toolchain (rustc/cargo) is installed for crates built from +# source, e.g. the native gRPC extension bundled into the sglang wheel via +# setuptools-rust. Minimum supported version is 1.85 (edition 2024). +set -euxo pipefail + +# Pick up cargo if rustup was installed in a previous CI step. +export PATH="${CARGO_HOME:-$HOME/.cargo}/bin:${PATH}" + +if command -v cargo >/dev/null 2>&1 && command -v rustc >/dev/null 2>&1; then + echo "rust already installed: $(rustc --version), $(cargo --version)" + exit 0 +fi + +echo "rust not found, installing via rustup..." + +# rustup.rs requires curl — make sure it's present. +if ! command -v curl >/dev/null 2>&1; then + if command -v apt-get &> /dev/null; then + apt-get update || true + apt-get install -y --no-install-recommends curl ca-certificates + elif command -v yum &> /dev/null; then + yum install -y curl ca-certificates + else + echo "ERROR: curl is required to install rustup, but no supported package manager was found" + exit 1 + fi +fi + +curl --proto '=https' --tlsv1.2 --retry 3 --retry-delay 2 -sSf https://sh.rustup.rs \ + | sh -s -- -y --no-modify-path + +# Make cargo/rustc visible to the rest of this shell and to subsequent +# GitHub Actions steps in the same job. +export PATH="${CARGO_HOME:-$HOME/.cargo}/bin:${PATH}" +if [ -n "${GITHUB_PATH:-}" ]; then + echo "${CARGO_HOME:-$HOME/.cargo}/bin" >> "${GITHUB_PATH}" +fi + +rustc --version +cargo --version