Skip to content

Configuration

config

Configuration system with Pydantic validation.

Replaces the scattered configuration across dependencies.json, repo-config.json, and hardcoded values in PowerShell scripts. Provides a single, typed, validated configuration model.

ToolConfig

Bases: BaseModel

Configuration for an external tool (e.g. VS Build Tools).

ToolsConfig

Bases: BaseModel

All external tools configuration.

TorchConfig

Bases: BaseModel

PyTorch installation configuration.

WheelConfig

Bases: BaseModel

A pre-built wheel package to install.

Supports version-aware wheels via the versions mapping: each key is a CPython tag (e.g. "cp311", "cp312") and the value is the download URL for that version.

Optionally, checksums maps CPython tags to expected SHA-256 hex digests for supply-chain verification.

Legacy format (flat name + url) is still supported.

resolve(python_version, cuda_tag='')

Pick the wheel matching the running Python and CUDA version.

Resolution order for versioned wheels: 1. {cuda_tag}_{cpython_tag} — exact CUDA + Python match 2. {cpython_tag} — CUDA-agnostic fallback

Parameters:

Name Type Description Default
python_version tuple[int, int]

(major, minor) tuple, e.g. (3, 13).

required
cuda_tag str

CUDA tag, e.g. "cu130" or "cu128".

''

Returns:

Type Description
tuple[str, str, str | None] | None

(name, url, sha256_or_None) tuple, or None if no match.

Source code in src/config.py
def resolve(
    self,
    python_version: tuple[int, int],
    cuda_tag: str = "",
) -> tuple[str, str, str | None] | None:
    """Pick the wheel matching the running Python and CUDA version.

    Resolution order for versioned wheels:
    1. ``{cuda_tag}_{cpython_tag}`` — exact CUDA + Python match
    2. ``{cpython_tag}`` — CUDA-agnostic fallback

    Args:
        python_version: (major, minor) tuple, e.g. (3, 13).
        cuda_tag: CUDA tag, e.g. ``"cu130"`` or ``"cu128"``.

    Returns:
        (name, url, sha256_or_None) tuple, or None if no match.
    """
    cp_tag = f"cp{python_version[0]}{python_version[1]}"

    if self.versions:
        # Try CUDA-specific key first, then cpython-only fallback
        for key in ([f"{cuda_tag}_{cp_tag}", cp_tag] if cuda_tag else [cp_tag]):
            url = self.versions.get(key)
            if url:
                whl_name = url.rsplit("/", 1)[-1].removesuffix(".whl")
                checksum = self.checksums.get(key)
                return whl_name, url, checksum
        return None

    # Legacy: flat name + url (assumed to match current Python)
    if self.name and self.url:
        return self.name, self.url, None
    return None

PipPackages

Bases: BaseModel

All pip package configurations.

supported_cuda_tags property

List supported CUDA tags from the torch configuration.

get_torch(cuda_tag)

Get the TorchConfig for a specific CUDA tag.

Handles both legacy (single TorchConfig) and multi-CUDA (dict) formats.

Parameters:

Name Type Description Default
cuda_tag str

CUDA tag, e.g. "cu130" or "cu128".

required

Returns:

Type Description
TorchConfig | None

Matching TorchConfig, or None if not available.

Source code in src/config.py
def get_torch(self, cuda_tag: str) -> TorchConfig | None:
    """Get the TorchConfig for a specific CUDA tag.

    Handles both legacy (single TorchConfig) and multi-CUDA (dict) formats.

    Args:
        cuda_tag: CUDA tag, e.g. ``"cu130"`` or ``"cu128"``.

    Returns:
        Matching TorchConfig, or ``None`` if not available.
    """
    if isinstance(self.torch, dict):
        return self.torch.get(cuda_tag)
    # Legacy single TorchConfig — return it for any tag
    return self.torch

RepositoryConfig

Bases: BaseModel

A git repository source.

RepositoriesConfig

Bases: BaseModel

All git repositories.

FileEntry

Bases: BaseModel

A file to download with its destination.

FilesConfig

Bases: BaseModel

All downloadable files.

InstallOptions

Bases: BaseModel

Options for uv pip install.

OptimizationPackage

Bases: BaseModel

A single GPU optimization package with platform/GPU filters.

pypi_package can be a plain string (same on all platforms) or a dict mapping platform names (windows, linux, macos) to platform-specific package names.

requires is a list of tags the environment must satisfy for this package to be installed. Supported tags: nvidia, amd, linux, windows, macos.

get_package_name(platform)

Resolve the pip package name for the given platform.

Parameters:

Name Type Description Default
platform str

"windows", "linux", or "macos".

required

Returns:

Type Description
str | None

Package name string, or None if not available on this platform.

Source code in src/config.py
def get_package_name(self, platform: str) -> str | None:
    """Resolve the pip package name for the given platform.

    Args:
        platform: ``"windows"``, ``"linux"``, or ``"macos"``.

    Returns:
        Package name string, or ``None`` if not available on this platform.
    """
    if isinstance(self.pypi_package, str):
        return self.pypi_package
    return self.pypi_package.get(platform)

OptimizationsConfig

Bases: BaseModel

GPU optimization packages configuration.

DependenciesConfig

Bases: BaseModel

Complete dependencies configuration.

Typed replacement for dependencies.json.

InstallerSettings

Bases: BaseModel

User-local installer settings.

Replaces repo-config.json and hardcoded values. This file should NEVER be overwritten by bootstrap/update.

load_dependencies(path)

Load and validate dependencies.json.

Parameters:

Name Type Description Default
path Path

Path to dependencies.json file.

required

Returns:

Type Description
DependenciesConfig

Validated DependenciesConfig object.

Raises:

Type Description
FileNotFoundError

If the file doesn't exist.

ValueError

If the JSON is invalid.

Source code in src/config.py
def load_dependencies(path: Path) -> DependenciesConfig:
    """
    Load and validate dependencies.json.

    Args:
        path: Path to dependencies.json file.

    Returns:
        Validated DependenciesConfig object.

    Raises:
        FileNotFoundError: If the file doesn't exist.
        ValueError: If the JSON is invalid.
    """
    if not path.exists():
        raise FileNotFoundError(f"Dependencies file not found: {path}")

    with open(path, encoding="utf-8") as f:
        data = json.load(f)

    return DependenciesConfig.model_validate(data)

load_settings(path)

Load user-local settings from local-config.json.

If the file doesn't exist, returns defaults.

Parameters:

Name Type Description Default
path Path

Path to local-config.json.

required

Returns:

Type Description
InstallerSettings

InstallerSettings with loaded or default values.

Source code in src/config.py
def load_settings(path: Path) -> InstallerSettings:
    """
    Load user-local settings from local-config.json.

    If the file doesn't exist, returns defaults.

    Args:
        path: Path to local-config.json.

    Returns:
        InstallerSettings with loaded or default values.
    """
    if not path.exists():
        return InstallerSettings()

    with open(path, encoding="utf-8") as f:
        data = json.load(f)

    return InstallerSettings.model_validate(data)

save_settings(settings, path)

Save settings to local-config.json.

Parameters:

Name Type Description Default
settings InstallerSettings

The settings to save.

required
path Path

Destination file path.

required
Source code in src/config.py
def save_settings(settings: InstallerSettings, path: Path) -> None:
    """
    Save settings to local-config.json.

    Args:
        settings: The settings to save.
        path: Destination file path.
    """
    path.parent.mkdir(parents=True, exist_ok=True)

    with open(path, "w", encoding="utf-8") as f:
        json.dump(
            settings.model_dump(mode="json"),
            f,
            indent=2,
            default=str,
        )