Skip to content

System

system

System prerequisites — Steps 1-2.

Checks and installs external tools required before the Python environment or ComfyUI can be set up:

  • Git: version check against MIN_GIT_VERSION, auto-install on Windows, or OS-specific upgrade instructions.
  • aria2: 3-tier search (system PATH → local scripts/aria2/ → download on Windows / suggest on Linux).

Typical usage::

from src.installer.system import check_prerequisites, ensure_aria2

if not check_prerequisites(log):
    install_git(log)
ensure_aria2(install_path, log)

check_prerequisites(log)

Verify that required external tools are present and up to date.

Checks Git availability and version. If Git is outdated, offers OS-specific update instructions (auto-update on Windows, manual commands on Linux/macOS).

Parameters:

Name Type Description Default
log InstallerLogger

Installer logger for user-facing messages.

required

Returns:

Type Description
bool

True if all prerequisites are met (Git present and

bool

usable). False if Git is missing entirely.

Source code in src/installer/system.py
def check_prerequisites(log: InstallerLogger) -> bool:
    """Verify that required external tools are present and up to date.

    Checks Git availability and version. If Git is outdated, offers
    OS-specific update instructions (auto-update on Windows, manual
    commands on Linux/macOS).

    Args:
        log: Installer logger for user-facing messages.

    Returns:
        ``True`` if all prerequisites are met (Git present and
        usable). ``False`` if Git is missing entirely.
    """
    all_ok = True

    # Check Git
    if check_command_exists("git"):
        git_ver_str = subprocess.run(  # returncode not checked — version is optional info
            ["git", "--version"], capture_output=True, text=True, timeout=10
        ).stdout.strip()
        git_ver = _parse_git_version(git_ver_str)

        if git_ver and git_ver < MIN_GIT_VERSION:
            min_str = ".".join(str(v) for v in MIN_GIT_VERSION)
            log.warning(f"Git {git_ver_str} is outdated (minimum: {min_str}).", level=2)

            if sys.platform == "win32":
                if confirm("Would you like to update Git now?"):
                    # Running the Git installer again updates in-place
                    if install_git(log):
                        log.sub("Git updated successfully.", style="success")
                    else:
                        log.warning("Git update failed. Continuing with current version.", level=2)
                else:
                    log.item("Continuing with current Git version.")
            elif sys.platform == "darwin":
                log.item("Update with: brew upgrade git")
            else:
                log.item("Update with: sudo apt update && sudo apt install git")
        else:
            log.sub(f"Git: {git_ver_str}", style="success")
    else:
        log.warning("Git is not installed.", level=2)
        all_ok = False

    return all_ok

install_git(log, *, git_url='https://huggingface.co/UmeAiRT/ComfyUI-Auto_installer/resolve/main/bin/Git-2.53.0.2-64-bit.exe', git_sha256='')

Download and silently install Git for Windows.

On non-Windows platforms, prints manual installation instructions and returns False immediately.

Parameters:

Name Type Description Default
log InstallerLogger

Installer logger for user-facing messages.

required
git_url str

Download URL for the Git installer. Defaults to the version in dependencies.json.

'https://huggingface.co/UmeAiRT/ComfyUI-Auto_installer/resolve/main/bin/Git-2.53.0.2-64-bit.exe'
git_sha256 str

Expected SHA-256 hex digest for verification.

''

Returns:

Type Description
bool

True if Git was installed successfully, False otherwise.

Source code in src/installer/system.py
def install_git(
    log: InstallerLogger,
    *,
    git_url: str = "https://huggingface.co/UmeAiRT/ComfyUI-Auto_installer/resolve/main/bin/Git-2.53.0.2-64-bit.exe",
    git_sha256: str = "",
) -> bool:
    """Download and silently install Git for Windows.

    On non-Windows platforms, prints manual installation instructions
    and returns ``False`` immediately.

    Args:
        log: Installer logger for user-facing messages.
        git_url: Download URL for the Git installer. Defaults to
            the version in ``dependencies.json``.
        git_sha256: Expected SHA-256 hex digest for verification.

    Returns:
        ``True`` if Git was installed successfully, ``False`` otherwise.
    """
    if sys.platform != "win32":
        log.error("Automatic Git installation is only supported on Windows.")
        log.item("Please install Git manually: sudo apt install git (Linux) or brew install git (macOS)")
        return False

    if not confirm("Git is required. Would you like to install it automatically?"):
        log.error("Installation aborted — Git is mandatory.")
        return False

    log.item("Downloading Git for Windows...")
    git_installer = Path(tempfile.gettempdir()) / "git-installer.exe"

    try:
        download_file(git_url, git_installer, checksum=git_sha256 or None)
        log.sub("Installing Git (accept UAC if prompted)...")

        result = subprocess.run(  # returncode checked below
            [str(git_installer), "/VERYSILENT", "/NORESTART", "/NOCANCEL", "/SP-",
             "/CLOSEAPPLICATIONS", "/RESTARTAPPLICATIONS"],
            timeout=300,
        )

        if result.returncode == 0:
            log.success("Git installed successfully.", level=2)
            # Refresh PATH
            if sys.platform == "win32":
                os.environ["PATH"] = (
                    os.environ.get("PATH", "")
                    + ";"
                    + r"C:\Program Files\Git\cmd"
                )
            return True
        else:
            log.error(f"Git installer failed with code {result.returncode}.")
            return False
    except Exception as e:
        log.error(f"Git installation failed: {e}")
        return False
    finally:
        git_installer.unlink(missing_ok=True)

ensure_aria2(install_path, log, *, aria2_url='', aria2_sha256='')

Ensure the aria2 download accelerator is available.

Uses a 3-tier search strategy:

  1. System PATH (user or package-manager installed).
  2. install_path/scripts/aria2/ (downloaded by a previous run).
  3. Windows: download and extract to scripts/aria2/. Linux/macOS: suggest package manager installation.

If found in tier 2 or 3, the directory is prepended to os.environ["PATH"] so subsequent calls can find aria2c.

Parameters:

Name Type Description Default
install_path Path

Root installation directory.

required
log InstallerLogger

Installer logger for user-facing messages.

required
aria2_url str

Download URL for the aria2 zip archive.

''

Returns:

Type Description
bool

True if aria2 is available after this call.

Source code in src/installer/system.py
def ensure_aria2(install_path: Path, log: InstallerLogger, *, aria2_url: str = "", aria2_sha256: str = "") -> bool:
    """Ensure the aria2 download accelerator is available.

    Uses a 3-tier search strategy:

    1. System ``PATH`` (user or package-manager installed).
    2. ``install_path/scripts/aria2/`` (downloaded by a previous run).
    3. **Windows**: download and extract to ``scripts/aria2/``.
       **Linux/macOS**: suggest package manager installation.

    If found in tier 2 or 3, the directory is prepended to
    ``os.environ["PATH"]`` so subsequent calls can find ``aria2c``.

    Args:
        install_path: Root installation directory.
        log: Installer logger for user-facing messages.
        aria2_url: Download URL for the aria2 zip archive.

    Returns:
        ``True`` if aria2 is available after this call.
    """
    # 1. Check system PATH
    if check_command_exists("aria2c"):
        log.sub("aria2 found in system PATH.", style="success")
        return True

    # 2. Check install_path/scripts/aria2/
    exe_name = "aria2c.exe" if sys.platform == "win32" else "aria2c"
    local_aria2 = install_path / "scripts" / "aria2" / exe_name
    if local_aria2.exists():
        os.environ["PATH"] = str(local_aria2.parent) + os.pathsep + os.environ.get("PATH", "")
        log.sub("aria2 found in scripts/aria2/.", style="success")
        return True

    # 3. Platform-specific: download or suggest
    if sys.platform == "win32":
        kwargs: dict[str, str] = {}
        if aria2_url:
            kwargs["aria2_url"] = aria2_url
        if aria2_sha256:
            kwargs["aria2_sha256"] = aria2_sha256
        return _download_aria2_windows(install_path, log, **kwargs)
    else:
        log.info("aria2 is not installed. Downloads will use standard speed.")
        if sys.platform == "darwin":
            log.item("Install with: brew install aria2")
        else:
            log.item("Install with: sudo apt install aria2  (or your package manager)")
        return False