fix: upgrade custom-node deps each start and shallow-update ComfyUI-Manager

This updates ComfyUI-Manager on container launch using a shallow fetch/reset pattern and cleans untracked files to ensure a fresh working tree, which is the recommended way to refresh depth‑1 clones without full history. It also installs all detected requirements.txt files with pip --upgrade and only-if-needed strategy so direct requirements are upgraded within constraints on each run, while still excluding Manager from wheel-builds to avoid setuptools flat‑layout errors.
This commit is contained in:
clsferguson 2025-09-17 12:30:08 -06:00 committed by GitHub
parent db7f8730db
commit db506ae51c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -19,43 +19,35 @@ if [ "$(id -u)" = "0" ]; then
else else
groupmod -o -g "${PGID}" "${APP_GROUP}" || true groupmod -o -g "${PGID}" "${APP_GROUP}" || true
fi fi
# Map user to PUID # Map user to PUID
usermod -o -u "${PUID}" "${APP_USER}" || true usermod -o -u "${PUID}" "${APP_USER}" || true
# Ensure home and app dir exist and are owned # Ensure home and app dir exist and are owned
mkdir -p "/home/${APP_USER}" mkdir -p "/home/${APP_USER}"
for d in "$BASE_DIR" "/home/$APP_USER"; do for d in "$BASE_DIR" "/home/$APP_USER"; do
[ -e "$d" ] && chown -R "${APP_USER}:${APP_GROUP}" "$d" || true [ -e "$d" ] && chown -R "${APP_USER}:${APP_GROUP}" "$d" || true
done done
# Make Python system install targets writable for the runtime user # Make Python system install targets writable for the runtime user (only under /usr/local)
# Includes: site-packages (purelib/platlib), scripts, headers, data, and data/share(+man1)
# Discards anything not under /usr/local to avoid over-broad changes.
readarray -t PY_PATHS < <(python - <<'PY' readarray -t PY_PATHS < <(python - <<'PY'
import sys, sysconfig, os, datetime import sys, sysconfig, os, datetime
def log(msg): def log(msg):
ts = datetime.datetime.now().strftime("%H:%M:%S") ts = datetime.datetime.now().strftime("%H:%M:%S")
print(f"[bootstrap:python {ts}] {msg}", file=sys.stderr, flush=True) print(f"[bootstrap:python {ts}] {msg}", file=sys.stderr, flush=True)
log("Determining writable Python install targets via sysconfig.get_paths()") log("Determining writable Python install targets via sysconfig.get_paths()")
keys = ("purelib","platlib","scripts","include","platinclude","data") keys = ("purelib","platlib","scripts","include","platinclude","data")
paths = sysconfig.get_paths() paths = sysconfig.get_paths()
for k in keys: for k in keys:
v = paths.get(k) v = paths.get(k)
if v: if v:
print(v) # stdout for the shell to capture print(v)
log(f"emit {k} -> {v}") # stderr for the user to see log(f"emit {k} -> {v}")
d = paths.get("data") d = paths.get("data")
if d: if d:
share = os.path.join(d, "share") share = os.path.join(d, "share")
man1 = os.path.join(share, "man", "man1") man1 = os.path.join(share, "man", "man1")
print(share) # stdout print(share)
print(man1) # stdout print(man1)
log(f"emit wheel data dirs -> {share}, {man1}") # stderr log(f"emit wheel data dirs -> {share}, {man1}")
log("Finished emitting target directories") log("Finished emitting target directories")
PY PY
) )
@ -74,30 +66,37 @@ PY
exec runuser -u "${APP_USER}" -- "$0" "$@" exec runuser -u "${APP_USER}" -- "$0" "$@"
fi fi
# Ensure ComfyUI-Manager exists (bind mounts can hide baked content) # Ensure ComfyUI-Manager exists or update it (shallow)
if [ ! -d "$CUSTOM_NODES_DIR/ComfyUI-Manager" ]; then if [ -d "$CUSTOM_NODES_DIR/ComfyUI-Manager/.git" ]; then
echo "[bootstrap] Updating ComfyUI-Manager in $CUSTOM_NODES_DIR/ComfyUI-Manager"
git -C "$CUSTOM_NODES_DIR/ComfyUI-Manager" fetch --depth 1 origin || true
git -C "$CUSTOM_NODES_DIR/ComfyUI-Manager" reset --hard origin/HEAD || true
git -C "$CUSTOM_NODES_DIR/ComfyUI-Manager" clean -fdx || true
elif [ ! -d "$CUSTOM_NODES_DIR/ComfyUI-Manager" ]; then
echo "[bootstrap] Installing ComfyUI-Manager into $CUSTOM_NODES_DIR/ComfyUI-Manager" echo "[bootstrap] Installing ComfyUI-Manager into $CUSTOM_NODES_DIR/ComfyUI-Manager"
git clone --depth 1 https://github.com/ltdrdata/ComfyUI-Manager.git "$CUSTOM_NODES_DIR/ComfyUI-Manager" || true git clone --depth 1 https://github.com/ltdrdata/ComfyUI-Manager.git "$CUSTOM_NODES_DIR/ComfyUI-Manager" || true
fi fi
# User-site PATHs for --user installs (custom nodes) # User-site PATHs for --user installs (custom nodes)
export PATH="$HOME/.local/bin:$PATH" export PATH="$HOME/.local/bin:$PATH"
pyver="$(python -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')" pyver="$(python -c 'import sys; print(f\"{sys.version_info.major}.{sys.version_info.minor}\")')"
export PYTHONPATH="$HOME/.local/lib/python${pyver}/site-packages:${PYTHONPATH:-}" export PYTHONPATH="$HOME/.local/lib/python${pyver}/site-packages:${PYTHONPATH:-}"
# Auto-install custom node deps # Auto-install custom node deps
if [ "${COMFY_AUTO_INSTALL:-1}" = "1" ]; then if [ "${COMFY_AUTO_INSTALL:-1}" = "1" ]; then
echo "[deps] Scanning custom nodes for requirements..." echo "[deps] Scanning custom nodes for requirements..."
# Install any requirements*.txt found under custom_nodes (upgrade within constraints)
while IFS= read -r -d '' req; do while IFS= read -r -d '' req; do
echo "[deps] pip install --user -r $req" echo "[deps] pip install --user --upgrade -r $req"
pip install --no-cache-dir --user -r "$req" || true pip install --no-cache-dir --user --upgrade --upgrade-strategy only-if-needed -r "$req" || true
done < <(find "$CUSTOM_NODES_DIR" -maxdepth 3 -type f \( -iname 'requirements.txt' -o -iname 'requirements-*.txt' -o -path '*/requirements/*.txt' \) -print0) done < <(find "$CUSTOM_NODES_DIR" -maxdepth 3 -type f \( -iname 'requirements.txt' -o -iname 'requirements-*.txt' -o -path '*/requirements/*.txt' \) -print0)
# For pyproject.toml-based nodes, EXCLUDE ComfyUI-Manager (it's not meant to be wheel-built)
while IFS= read -r -d '' pjt; do while IFS= read -r -d '' pjt; do
d="$(dirname "$pjt")" d="$(dirname "$pjt")"
echo "[deps] pip install --user . in $d" echo "[deps] pip install --user . in $d"
(cd "$d" && pip install --no-cache-dir --user .) || true (cd "$d" && pip install --no-cache-dir --user .) || true
done < <(find "$CUSTOM_NODES_DIR" -maxdepth 2 -type f -iname 'pyproject.toml' -print0) done < <(find "$CUSTOM_NODES_DIR" -maxdepth 2 -type f -iname 'pyproject.toml' -not -path '*/ComfyUI-Manager/*' -print0)
pip check || true pip check || true
fi fi