Skip to content

system_info

appimage_updater.core.system_info

System information detection for architecture and platform compatibility.

This module provides comprehensive system detection including architecture, platform, and supported package formats to enable intelligent asset filtering and compatibility scoring.

SystemDetector()

Detects system information for compatibility checking.

Source code in src/appimage_updater/core/system_info.py
def __init__(self) -> None:
    """Initialize system detector."""
    self._system_info: SystemInfo | None = None

get_system_info()

Get cached system information.

Source code in src/appimage_updater/core/system_info.py
def get_system_info(self) -> SystemInfo:
    """Get cached system information."""
    if self._system_info is None:
        self._system_info = self._detect_system_info()
    return self._system_info

SystemInfo(platform, architecture, architecture_aliases, machine, supported_formats, distribution=None, distribution_family=None) dataclass

Comprehensive system information.

architecture instance-attribute

architecture_aliases instance-attribute

distribution = None class-attribute instance-attribute

distribution_family = None class-attribute instance-attribute

machine instance-attribute

platform instance-attribute

supported_formats instance-attribute

get_system_info()

Get system information (cached).

Source code in src/appimage_updater/core/system_info.py
def get_system_info() -> SystemInfo:
    """Get system information (cached)."""
    return _system_detector.get_system_info()

is_compatible_architecture(asset_arch, system_arch=None)

Check if an asset architecture is compatible with the system.

Parameters:

Name Type Description Default
asset_arch str

Architecture found in asset filename

required
system_arch str | None

System architecture (uses detected if None)

None

Returns:

Name Type Description
bool

Tuple of (is_compatible, compatibility_score)

Score float

100=exact, 80=compatible, 0=incompatible

Source code in src/appimage_updater/core/system_info.py
def is_compatible_architecture(asset_arch: str, system_arch: str | None = None) -> tuple[bool, float]:
    """Check if an asset architecture is compatible with the system.

    Args:
        asset_arch: Architecture found in asset filename
        system_arch: System architecture (uses detected if None)

    Returns:
        Tuple of (is_compatible, compatibility_score)
        Score: 100=exact, 80=compatible, 0=incompatible
    """
    if system_arch is None:
        system_info = get_system_info()
        system_arch = system_info.architecture
        arch_aliases = system_info.architecture_aliases
    else:
        # Create temporary aliases for provided system_arch
        arch_mapping = {
            "x86_64": {"x86_64", "amd64", "x64"},
            "arm64": {"arm64", "aarch64"},
            "armv7": {"armv7", "armv7l", "armhf"},
            "i686": {"i386", "i686", "x86"},
        }
        arch_aliases = arch_mapping.get(system_arch, {system_arch})

    asset_arch_lower = asset_arch.lower()

    # Exact match
    if asset_arch_lower == system_arch.lower():
        return True, 100.0

    # Alias match
    if asset_arch_lower in {alias.lower() for alias in arch_aliases}:
        return True, 80.0

    # No match
    return False, 0.0

is_compatible_platform(asset_platform, system_platform=None)

Check if an asset platform is compatible with the system.

Parameters:

Name Type Description Default
asset_platform str

Platform found in asset filename

required
system_platform str | None

System platform (uses detected if None)

None

Returns:

Name Type Description
bool

Tuple of (is_compatible, compatibility_score)

Score float

100=exact, 0=incompatible

Source code in src/appimage_updater/core/system_info.py
def is_compatible_platform(asset_platform: str, system_platform: str | None = None) -> tuple[bool, float]:
    """Check if an asset platform is compatible with the system.

    Args:
        asset_platform: Platform found in asset filename
        system_platform: System platform (uses detected if None)

    Returns:
        Tuple of (is_compatible, compatibility_score)
        Score: 100=exact, 0=incompatible
    """
    if system_platform is None:
        system_info = get_system_info()
        system_platform = system_info.platform

    # Platform compatibility is strict - no cross-platform support
    is_compatible = asset_platform.lower() == system_platform.lower()
    return is_compatible, (100.0 if is_compatible else 0.0)

is_supported_format(file_extension, system_platform=None)

Check if a file format is supported on the system.

Parameters:

Name Type Description Default
file_extension str

File extension (e.g., '.deb', '.AppImage')

required
system_platform str | None

System platform (uses detected if None)

None

Returns:

Name Type Description
bool

Tuple of (is_supported, preference_score)

Score float

100=preferred, 80=supported, 0=unsupported

Source code in src/appimage_updater/core/system_info.py
def is_supported_format(file_extension: str, system_platform: str | None = None) -> tuple[bool, float]:
    """Check if a file format is supported on the system.

    Args:
        file_extension: File extension (e.g., '.deb', '.AppImage')
        system_platform: System platform (uses detected if None)

    Returns:
        Tuple of (is_supported, preference_score)
        Score: 100=preferred, 80=supported, 0=unsupported
    """
    if system_platform is None:
        system_info = get_system_info()
        supported_formats = system_info.supported_formats
        platform_name = system_info.platform
    else:
        # Create temporary supported formats for provided platform
        detector: SystemDetector = SystemDetector()
        supported_formats = detector._detect_supported_formats(system_platform)
        platform_name = system_platform

    # Case-insensitive format checking
    file_extension_lower = file_extension.lower()
    supported_formats_lower = {fmt.lower() for fmt in supported_formats}

    if file_extension_lower not in supported_formats_lower:
        return False, 0.0

    # Format preferences by platform (case-insensitive keys)
    preferences = {
        "linux": {
            ".appimage": 70.0,  # Preferred for AppImage Updater (reduced to balance with distribution)
            ".deb": 65.0,  # Native package format for Debian-based
            ".rpm": 65.0,  # Native package format for RPM-based
            ".tar.gz": 50.0,  # Generic archive
            ".tar.xz": 50.0,  # Generic archive
            ".zip": 45.0,  # Generic archive
        },
        "darwin": {
            ".dmg": 70.0,  # Preferred macOS format
            ".pkg": 65.0,  # Native installer
            ".zip": 50.0,  # Archive format
            ".tar.gz": 45.0,  # Archive format
        },
        "win32": {
            ".exe": 70.0,  # Preferred Windows format
            ".msi": 65.0,  # Windows installer
            ".zip": 50.0,  # Archive format
        },
    }

    platform_prefs = preferences.get(platform_name, {})
    score = platform_prefs.get(file_extension_lower, 50.0)  # Default supported score

    return True, score