v4: Align minimum Python version with ComfyUI (#3490)

This commit is contained in:
Dr.Lt.Data
2026-11-12 01:37:59 +09:00
committed by GitHub
parent 215d7d4cb0
commit dbdb642ed2
8 changed files with 56 additions and 41 deletions
+21 -4
View File
@@ -1,12 +1,14 @@
"""Cross-platform E2E environment setup for ComfyUI + Manager.
Creates an isolated ComfyUI installation with ComfyUI-Manager for E2E testing.
Idempotent: skips setup if marker file and key artifacts already exist.
Idempotent: skips setup if marker, key artifacts, and a supported venv already exist.
uv reads the Manager project's Python requirement when creating a venv.
Input env vars:
E2E_ROOT — target directory (required)
MANAGER_ROOT — manager repo root (default: auto-detected)
COMFYUI_BRANCH — ComfyUI branch to clone (default: master)
UV_PYTHON — optional uv Python request for a new venv
Output (last line of stdout):
E2E_ROOT=/path/to/environment
@@ -46,6 +48,18 @@ def run(cmd: list[str], **kwargs) -> subprocess.CompletedProcess:
return subprocess.run(cmd, check=True, **kwargs)
def check_python_version(python: str) -> None:
try:
version = subprocess.check_output(
[python, "-c", "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')"],
text=True,
).strip()
except (OSError, subprocess.CalledProcessError) as exc:
die(f"Cannot run venv Python: {python}: {exc}. Recreate the E2E environment with Python 3.10+.")
if tuple(map(int, version.split("."))) < (3, 10):
die(f"Python 3.10+ required, found {version} ({python}). Recreate the E2E environment.")
def detect_manager_root() -> Path:
"""Walk up from this script to find pyproject.toml."""
d = Path(__file__).resolve().parent
@@ -69,7 +83,7 @@ def venv_bin(root: Path, name: str) -> str:
return str(root / "venv" / "bin" / name)
def is_already_setup(root: Path, manager_root: Path) -> bool:
def is_already_setup(root: Path) -> bool:
marker = root / ".e2e_setup_complete"
comfyui = root / "comfyui"
venv = root / "venv"
@@ -119,7 +133,9 @@ def main() -> None:
branch = os.environ.get("COMFYUI_BRANCH", "master")
# Idempotency
if is_already_setup(root, manager_root):
if (root / "venv").is_dir():
check_python_version(venv_python(root))
if is_already_setup(root):
log("Environment already set up (marker file exists). Skipping.")
print(f"E2E_ROOT={root}")
return
@@ -138,7 +154,8 @@ def main() -> None:
log("Step 2/7: venv already exists, skipping")
else:
log("Step 2/7: Creating virtual environment...")
run(["uv", "venv", str(venv_dir)])
run(["uv", "venv", "--project", str(manager_root), str(venv_dir)])
check_python_version(venv_python(root))
py = venv_python(root)
+15 -16
View File
@@ -2,13 +2,13 @@
# setup_e2e_env.sh — Automated E2E environment setup for ComfyUI + Manager
#
# Creates an isolated ComfyUI installation with ComfyUI-Manager for E2E testing.
# Idempotent: skips setup if marker file and key artifacts already exist.
# Idempotent: skips setup if marker, key artifacts, and a supported venv already exist.
#
# Input env vars:
# E2E_ROOT — target directory (default: auto-generated via mktemp)
# MANAGER_ROOT — manager repo root (default: auto-detected from script location)
# COMFYUI_BRANCH — ComfyUI branch to clone (default: master)
# PYTHON — Python executable (default: python3)
# UV_PYTHON — optional uv Python request for a new venv
#
# Output (last line of stdout):
# E2E_ROOT=/path/to/environment
@@ -44,29 +44,25 @@ detect_manager_root() {
return 1
}
check_python_version() {
"$1" -c 'import sys
if sys.version_info < (3, 10):
sys.exit(f"Python 3.10+ required, found {sys.version_info.major}.{sys.version_info.minor}")' \
|| die "Cannot use venv Python: $1. Recreate the E2E environment with Python 3.10+."
}
# --- Validate prerequisites ---
validate_prerequisites() {
local py="${PYTHON:-python3}"
local missing=()
command -v git >/dev/null 2>&1 || missing+=("git")
command -v uv >/dev/null 2>&1 || missing+=("uv")
command -v "$py" >/dev/null 2>&1 || missing+=("$py")
if [[ ${#missing[@]} -gt 0 ]]; then
die "Missing prerequisites: ${missing[*]}"
fi
# Verify Python version >= 3.9
local py_version
py_version=$("$py" -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')")
local major minor
major="${py_version%%.*}"
minor="${py_version##*.}"
if [[ "$major" -lt 3 ]] || { [[ "$major" -eq 3 ]] && [[ "$minor" -lt 9 ]]; }; then
die "Python 3.9+ required, found $py_version"
fi
log "Prerequisites OK (python=$py_version, git=$(git --version | awk '{print $3}'), uv=$(uv --version 2>&1 | awk '{print $2}'))"
log "Prerequisites OK (git=$(git --version | awk '{print $3}'), uv=$(uv --version 2>&1 | awk '{print $2}'))"
}
# --- Check idempotency: skip if already set up ---
@@ -151,7 +147,6 @@ log "MANAGER_ROOT=$MANAGER_ROOT"
# Validate prerequisites
validate_prerequisites
PYTHON="${PYTHON:-python3}"
COMFYUI_BRANCH="${COMFYUI_BRANCH:-master}"
# Create or use E2E_ROOT
@@ -166,6 +161,9 @@ else
fi
# Idempotency check
if [[ -d "$E2E_ROOT/venv" ]]; then
check_python_version "$E2E_ROOT/venv/bin/python"
fi
check_already_setup "$E2E_ROOT"
# Cleanup trap: remove E2E_ROOT on failure only if we created it
@@ -191,7 +189,8 @@ log "Step 2/8: Creating virtual environment..."
if [[ -d "$E2E_ROOT/venv" ]]; then
log " venv already exists, skipping"
else
uv venv "$E2E_ROOT/venv"
uv venv --project "$MANAGER_ROOT" "$E2E_ROOT/venv"
check_python_version "$E2E_ROOT/venv/bin/python"
fi
VENV_PY="$E2E_ROOT/venv/bin/python"