TraitsΒΆ

All aspects of a system are represented as traits.

There are three main types of traits:

  • Architectures: CPU architectures (e.g., x86_64, ARM64)

  • Platforms: Operating systems (e.g., Windows, macOS, Ubuntu)

  • CI systems: Continuous Integration environments (e.g., GitHub Actions, Travis CI)

extra_platforms.trait APIΒΆ

        classDiagram
  ABC <|-- Trait
  Trait <|-- Architecture
  Trait <|-- CI
  Trait <|-- Platform
    

Trait base class for architectures, platforms, CI systems, and more.

A trait represents a distinguishing characteristic of a runtime environment. Each trait has a unique ID, a human-readable name, an icon, and the ability to detect if it matches the current environment.

Data associated with traits can be aggressively cached and frozen, as they’re only computed based on environment-dependent values.

class extra_platforms.trait.Trait(id, name, icon='❓', url='')[source]ΒΆ

Bases: ABC

Base class for system traits like platforms and architectures.

A trait is a distinguishing characteristic of the runtime environment that can be detected and identified. Examples include:

  • Operating systems (macOS, Linux, Windows)

  • CPU architectures (x86_64, ARM64)

  • CI/CD environments (GitHub Actions, GitLab CI)

Each trait has:

  • A unique ID for programmatic use

  • A human-readable name

  • An icon for visual representation

  • A URL to official documentation

  • A current property that detects if this trait matches the runtime

id: strΒΆ

Unique ID of the trait.

name: strΒΆ

User-friendly name of the trait.

icon: str = '❓'ΒΆ

Icon of the trait.

url: str = ''ΒΆ

URL to the trait’s official website or documentation.

detection_func_id: strΒΆ

ID of the detection function for this trait.

The detection function is expected to be named is_<id>() and located at the root of the extra_platforms module.

property short_desc: strΒΆ

Returns a short description of the trait.

Mainly used to produce docstrings for functions dynamically generated for each group.

property current: boolΒΆ

Returns whether the current environment matches this trait.

The detection function is dynamically looked up based on the trait ID, and is expected to be found at the root of the extra_platforms module.

Raises NotImplementedError if a detection function cannot be found.

Hint

This is a property to avoid calling all detection heuristics on Trait objects creation, which happens at module import time.

abstractmethod info()[source]ΒΆ

Returns all trait attributes that can be gathered.

Subclasses should override this to include trait-specific information.

Return type:

dict

class extra_platforms.trait.Architecture(id, name, icon='β–£', url='')[source]ΒΆ

Bases: Trait

A CPU architecture identifies a processor instruction set.

It has a unique ID, a human-readable name, and boolean to flag current architecture.

icon: str = 'β–£'ΒΆ

Icon of the architecture.

info()[source]ΒΆ

Returns all architecture attributes we can gather.

Return type:

dict[str, str | bool | None]

id: strΒΆ

Unique ID of the trait.

name: strΒΆ

User-friendly name of the trait.

detection_func_id: strΒΆ

ID of the detection function for this trait.

The detection function is expected to be named is_<id>() and located at the root of the extra_platforms module.

class extra_platforms.trait.Platform(id, name, icon='❓', url='')[source]ΒΆ

Bases: Trait

A platform can identify multiple distributions or OSes with the same characteristics.

It has a unique ID, a human-readable name, and boolean to flag current platform.

icon: str = '❓'ΒΆ

Icon of the platform.

info()[source]ΒΆ

Returns all platform attributes we can gather.

Return type:

dict[str, str | bool | None | dict[str, str | None]]

id: strΒΆ

Unique ID of the trait.

name: strΒΆ

User-friendly name of the trait.

detection_func_id: strΒΆ

ID of the detection function for this trait.

The detection function is expected to be named is_<id>() and located at the root of the extra_platforms module.

class extra_platforms.trait.CI(id, name, icon='β™²', url='')[source]ΒΆ

Bases: Trait

A CI/CD environment identifies a continuous integration platform.

It has a unique ID, a human-readable name, and boolean to flag current CI.

id: strΒΆ

Unique ID of the trait.

name: strΒΆ

User-friendly name of the trait.

detection_func_id: strΒΆ

ID of the detection function for this trait.

The detection function is expected to be named is_<id>() and located at the root of the extra_platforms module.

icon: str = 'β™²'ΒΆ

Icon of the CI environment.

info()[source]ΒΆ

Returns all CI attributes we can gather.

Return type:

dict[str, str | bool | None]