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:
ABCBase 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
currentproperty that detects if this trait matches the runtime
-
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 theextra_platformsmodule.
- 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_platformsmodule.Raises
NotImplementedErrorif a detection function cannot be found.Hint
This is a property to avoid calling all detection heuristics on
Traitobjects creation, which happens at module import time.
- class extra_platforms.trait.Architecture(id, name, icon='β£', url='')[source]ΒΆ
Bases:
TraitA CPU architecture identifies a processor instruction set.
It has a unique ID, a human-readable name, and boolean to flag current architecture.
- class extra_platforms.trait.Platform(id, name, icon='β', url='')[source]ΒΆ
Bases:
TraitA 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.
- class extra_platforms.trait.CI(id, name, icon='β²', url='')[source]ΒΆ
Bases:
TraitA CI/CD environment identifies a continuous integration platform.
It has a unique ID, a human-readable name, and boolean to flag current CI.