fix(start-macos): skip pip install when requirements.txt is unchanged (#2503)

Hash requirements.txt on each launch and skip pip install if the hash
matches the last recorded value. Cuts 10-20s from warm starts with no
change to what gets installed.

The hash file lives in venv/.requirements_hash (already gitignored).
Deleting venv/ or changing requirements.txt triggers a full reinstall.
This commit is contained in:
Ali Arfa
2026-06-05 12:59:56 +05:00
committed by GitHub
parent 3ef73013eb
commit 04df7255fb

View File

@@ -134,10 +134,17 @@ if [ ! -d venv ]; then
"$PY" -m venv venv
fi
VENV_PY="./venv/bin/python3"
REQ_HASH="$(md5 -q requirements.txt 2>/dev/null || md5sum requirements.txt | cut -d' ' -f1)"
REQ_HASH_FILE="venv/.requirements_hash"
if [ ! -f "$REQ_HASH_FILE" ] || [ "$REQ_HASH" != "$(cat "$REQ_HASH_FILE" 2>/dev/null)" ]; then
echo "▶ Installing Python packages (first run downloads a few — can take a few minutes)…"
"$VENV_PY" -m pip install --quiet --upgrade pip
# Not --quiet: this is the slow step, so show progress (and any real errors).
"$VENV_PY" -m pip install -r requirements.txt
echo "$REQ_HASH" > "$REQ_HASH_FILE"
else
echo "▶ Python packages up to date — skipping install"
fi
# chromadb-client (HTTP-only) conflicts with the full chromadb package. If
# it got installed (e.g., from an older requirements-optional.txt), remove