From 8fde524cda550cfe8b597bcd10595db636cae94c Mon Sep 17 00:00:00 2001 From: Sean <02white.silver@gmail.com> Date: Sun, 24 May 2026 23:32:30 +0000 Subject: [PATCH] fix(install_deps): compute SCRIPT_DIR once and pass --no-build-isolation to batchgen install install_batchgen_kernels and install_batchgen each recomputed SCRIPT_DIR via $(dirname "${BASH_SOURCE[0]}") after earlier install_* functions had cd'd into /tmp/batchgen_deps/DeepGEMM. With BASH_SOURCE[0] holding the relative path ./scripts/install_deps.sh, dirname returned ./scripts and the cd failed (line 217: cd: ./scripts: No such file or directory). Hoist SCRIPT_DIR/BATCHGEN_DIR to a single absolute-path computation at the top of the script so subsequent cd's don't invalidate them. Also add --no-build-isolation to install_batchgen -- its setup.py imports torch at module load (same constraint as batchgen_kernels), so the default isolated build env raises ModuleNotFoundError: No module named 'torch'. --- scripts/install_deps.sh | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/scripts/install_deps.sh b/scripts/install_deps.sh index 20076bac9..0deb1bf21 100755 --- a/scripts/install_deps.sh +++ b/scripts/install_deps.sh @@ -26,6 +26,11 @@ DEEPGEMM_VERSION="v2.1.1.post3" # Installation directory (defaults to temp, can be overridden) INSTALL_DIR="${BATCHGEN_INSTALL_DIR:-/tmp/batchgen_deps}" +# Absolute paths to this script and the BatchGen repo root. Computed once at +# entry so they stay valid even after install_* functions cd elsewhere. +SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" +BATCHGEN_DIR="$(dirname -- "$SCRIPT_DIR")" + print_step() { echo -e "${BLUE}==>${NC} $1" } @@ -214,9 +219,6 @@ install_deepgemm() { install_batchgen_kernels() { print_step "Installing batchgen_kernels (AOT-compiled CUDA kernel extensions)..." - SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" - BATCHGEN_DIR="$(dirname "$SCRIPT_DIR")" - if [[ -f "$BATCHGEN_DIR/batchgen_kernels/setup.py" ]]; then cd "$BATCHGEN_DIR/batchgen_kernels" pip install . --no-build-isolation @@ -229,13 +231,9 @@ install_batchgen_kernels() { install_batchgen() { print_step "Installing BatchGen..." - # Find BatchGen directory (script is in scripts/, BatchGen is parent) - SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" - BATCHGEN_DIR="$(dirname "$SCRIPT_DIR")" - if [[ -f "$BATCHGEN_DIR/setup.py" ]]; then cd "$BATCHGEN_DIR" - pip install . + pip install . --no-build-isolation print_success "BatchGen installed" else print_error "Could not find BatchGen setup.py at $BATCHGEN_DIR"