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)
Trait usage¶
Current traits¶
You can get all currently detected traits via the current_traits() function.
>>> from extra_platforms import current_traits
>>> current_traits()
{
Architecture(id='aarch64', name='ARM64 (AArch64)'),
Platform(id='macos', name='macOS'),
CI(id='github_ci', name='GitHub Actions runner'),
}
This function returns a set of all predefined traits that match the current system.
Other current traits can be specifically checked via their dedicated current_*() functions:
>>> from extra_platforms import current_architectures, current_platforms, current_ci
>>> current_architectures()
{Architecture(id='aarch64', name='ARM64 (AArch64)')}
>>> current_platforms()
{Platform(id='macos', name='macOS')}
>>> current_ci()
{CI(id='github_ci', name='GitHub Actions runner')}
Predefined traits¶
All traits are available at the root of the extra_platforms package, as an uppercase symbol:
>>> from extra_platforms import X86_64 # import an architecture
>>> X86_64
Architecture(id='x86_64', name='x86-64 (AMD64)')
>>> from extra_platforms import DEBIAN # import a platform
>>> DEBIAN
Platform(id='debian', name='Debian')
>>> from extra_platforms import GITHUB_CI # import a CI system
>>> GITHUB_CI
CI(id='github_ci', name='GitHub Actions runner')
They all inherit from the Trait base class, and share a common interface.
Current property¶
Each trait has a current property that calls the corresponding detection function:
>>> X86_64.current
True
>>> DEBIAN.current
False
>>> GITHUB_CI.current
False
Detection functions¶
Each trait is associated with a detection function, which returns True if the current system matches that trait.
These functions are also exposed at the root of the extra_platforms package:
>>> from extra_platforms import is_x86_64, is_debian, is_github_ci
>>> is_x86_64()
True
>>> is_debian()
False
>>> is_github_ci()
False
Groups¶
Traits are combined into groups for easier detection of related traits.
You can get all groups a trait belongs to via the groups property:
>>> X86_64.groups
frozenset({
Group(id='x86', name='x86 family'),
Group(id='all_architectures', name='All architectures'),
Group(id='arch_64_bit', name='64-bit architectures'),
Group(id='all_traits', name='Any architectures, platforms and CI systems')})
Additional information¶
Each trait provides an info() method that returns a dictionary containing all available metadata about that trait:
>>> from extra_platforms import AARCH64, MACOS
>>> AARCH64.info()
{'id': 'aarch64', 'name': 'ARM64 (AArch64)', 'icon': '📱', 'url': 'https://en.wikipedia.org/wiki/AArch64', 'current': True, 'machine': 'arm64', 'processor': None}
>>> MACOS.info()
{'id': 'macos', 'name': 'macOS', 'icon': '🍎', 'url': 'https://apple.com/macos/', 'current': True, 'distro_id': 'darwin', 'version': '26.2', 'version_parts': {'major': '26', 'minor': '2', 'build_number': None}, 'like': None, 'codename': 'Tahoe'}
The exact structure depends on the trait type.
All traits¶
All recognized traits and their properties:
Icon |
Symbol |
Name |
Detection function |
Type |
|---|---|---|---|---|
📱 |
ARM64 (AArch64) |
Architecture |
||
➿ |
IBM AIX |
Platform |
||
🐧 |
ALT Linux |
Platform |
||
⤻ |
Amazon Linux |
Platform |
||
🤖 |
Android |
Platform |
||
🎗️ |
Arch Linux |
Platform |
||
📱 |
ARM (32-bit) |
Architecture |
||
📱 |
ARMv5TE (little-endian) |
Architecture |
||
📱 |
ARMv6 (little-endian) |
Architecture |
||
📱 |
ARMv7 (little-endian) |
Architecture |
||
📱 |
ARMv8 (32-bit, little-endian) |
Architecture |
||
═ |
Azure Pipelines |
CI |
||
⟲ |
Bamboo |
CI |
||
🪁 |
Buildkite |
CI |
||
⛑️ |
Buildroot |
Platform |
||
⌬ |
CachyOS |
Platform |
||
💠 |
CentOS |
Platform |
||
⪾ |
Circle CI |
CI |
||
≋ |
Cirrus CI |
CI |
||
꩜ |
CloudLinux OS |
Platform |
||
ᚙ |
CodeBuild |
CI |
||
Ͼ |
Cygwin |
Platform |
||
🌀 |
Debian |
Platform |
||
🪰 |
DragonFly BSD |
Platform |
||
🐽 |
Exherbo Linux |
Platform |
||
🎩 |
Fedora |
Platform |
||
😈 |
FreeBSD |
Platform |
||
🗜️ |
Gentoo Linux |
Platform |
||
🐙 |
GitHub Actions runner |
CI |
||
🦊 |
GitLab CI |
CI |
||
🐃 |
Guix System |
Platform |
||
🍂 |
Haiku |
Platform |
||
⥁ |
Heroku CI |
CI |
||
🐃 |
GNU/Hurd |
Platform |
||
𝗶 |
Intel 80386 (i386) |
Architecture |
||
𝗶 |
Intel Pentium (i586) |
Architecture |
||
𝗶 |
Intel Pentium Pro (i686) |
Architecture |
||
🤹 |
IBM PowerKVM |
Platform |
||
🔥 |
illumos |
Platform |
||
🤹 |
KVM for IBM z Systems |
Platform |
||
🌿 |
Linux Mint |
Platform |
||
🐉 |
LoongArch (64-bit) |
Architecture |
||
🍎 |
macOS |
Platform |
||
⍥ |
Mageia |
Platform |
||
💫 |
Mandriva Linux |
Platform |
||
🌘 |
MidnightBSD |
Platform |
||
🔲 |
MIPS (32-bit, big-endian) |
Architecture |
||
🔲 |
MIPS64 (big-endian) |
Architecture |
||
🔲 |
MIPS64 (little-endian) |
Architecture |
||
🔲 |
MIPS (32-bit, little-endian) |
Architecture |
||
🚩 |
NetBSD |
Platform |
||
|
Nobara |
Platform |
||
🐡 |
OpenBSD |
Platform |
||
🦎 |
openSUSE |
Platform |
||
🦴 |
Oracle Linux |
Platform |
||
∥ |
Parallels |
Platform |
||
🍓 |
Pidora |
Platform |
||
⚡ |
PowerPC (32-bit) |
Architecture |
||
⚡ |
PowerPC 64-bit (big-endian) |
Architecture |
||
⚡ |
PowerPC 64-bit (little-endian) |
Architecture |
||
🍓 |
Raspbian |
Platform |
||
🎩 |
RedHat Enterprise Linux |
Platform |
||
Ⅴ |
RISC-V (32-bit) |
Architecture |
||
Ⅴ |
RISC-V (64-bit) |
Architecture |
||
⛰️ |
Rocky Linux |
Platform |
||
🏢 |
IBM z/Architecture (s390x) |
Architecture |
||
⚛️ |
Scientific Linux |
Platform |
||
🚬 |
Slackware |
Platform |
||
🦎 |
SUSE Linux Enterprise Server |
Platform |
||
🌞 |
Solaris |
Platform |
||
☀️ |
SPARC (32-bit) |
Architecture |
||
☀️ |
SPARC (64-bit) |
Architecture |
||
☀️ |
SunOS |
Platform |
||
🏙️ |
TeamCity |
CI |
||
👷 |
Travis CI |
CI |
||
↻ |
openSUSE Tumbleweed |
Platform |
||
🤵 |
Tuxedo OS |
Platform |
||
🎯 |
Ubuntu |
Platform |
||
🌊 |
Ultramarine |
Platform |
||
❓ |
Unknown architecture |
Architecture |
||
❓ |
Unknown CI |
CI |
||
❓ |
Unknown platform |
Platform |
||
🌐 |
WebAssembly (32-bit) |
Architecture |
||
🌐 |
WebAssembly (64-bit) |
Architecture |
||
🪟 |
Windows |
Platform |
||
⊞ |
Windows Subsystem for Linux v1 |
Platform |
||
⊞ |
Windows Subsystem for Linux v2 |
Platform |
||
🖥️ |
x86-64 (AMD64) |
Architecture |
||
Ⓧ |
XenServer |
Platform |
Trait implementation¶
classDiagram
ABC <|-- Trait
Trait <|-- Architecture
Trait <|-- CI
Trait <|-- Platform
_Identifiable <|-- Trait
- class extra_platforms.Trait(id, name, icon='❓', url='', aliases=<factory>)[source]¶
Bases:
_Identifiable,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.
Additionally of the common fields inherited from
_Identifiable, each trait provides:url: A link to official documentation or website for the trait.current: A boolean indicating if the current environment matches this trait.info(): A method returning a dictionary of gathered attributes about the trait.groups: A set ofGroupobjects that include this trait as a member.
-
aliases:
frozenset[str]¶ Alternative IDs for this trait.
Aliases are alternative identifiers that resolve to the same trait. When an alias is used, a warning is emitted to encourage using the canonical ID.
Note
Aliases do not generate their own symbols, detection functions, or pytest decorators. Only the canonical
idproduces these artifacts.
- generate_docstring()[source]¶
Generate comprehensive docstring for this trait instance.
Combines the attribute docstring from the source module with various metadata.
- Return type:
- _abc_impl = <_abc._abc_data object>¶
-
all_group:
ClassVar[str] = 'ALL_TRAITS'¶ The symbol name for the group containing all instances of this type.
-
data_module_id:
ClassVar[str] = 'trait_data'¶ The module name where instances of this type are defined.
- property groups: frozenset¶
Returns the set of groups this trait belongs to.
Uses dynamic import to avoid circular dependency with
group_datamodule.
-
type_id:
ClassVar[str] = 'trait'¶ Machine-readable type identifier used to derive module and symbol names.
-
unknown_symbol:
ClassVar[str] = 'UNKNOWN_TRAIT'¶ The symbol name for the unknown instance of this type.
- 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
Traitobject creation, which happens at module import time.
- class extra_platforms.Platform(id, name, icon='❓', url='', aliases=<factory>)[source]¶
Bases:
TraitA platform can identify multiple distributions or OSes with the same characteristics.
- _abc_impl = <_abc._abc_data object>¶
-
all_group:
ClassVar[str] = 'ALL_PLATFORMS'¶ The symbol name for the group containing all instances of this type.
-
data_module_id:
ClassVar[str] = 'platform_data'¶ The module name where instances of this type are defined.
-
type_id:
ClassVar[str] = 'platform'¶ Machine-readable type identifier used to derive module and symbol names.
- class extra_platforms.Architecture(id, name, icon='❓', url='', aliases=<factory>)[source]¶
Bases:
TraitA CPU architecture identifies a processor instruction set.
- _abc_impl = <_abc._abc_data object>¶
-
all_group:
ClassVar[str] = 'ALL_ARCHITECTURES'¶ The symbol name for the group containing all instances of this type.
-
data_module_id:
ClassVar[str] = 'architecture_data'¶ The module name where instances of this type are defined.
-
type_id:
ClassVar[str] = 'architecture'¶ Machine-readable type identifier used to derive module and symbol names.
- class extra_platforms.CI(id, name, icon='❓', url='', aliases=<factory>)[source]¶
Bases:
TraitA CI/CD environment identifies a continuous integration platform.
- _abc_impl = <_abc._abc_data object>¶
-
data_module_id:
ClassVar[str] = 'ci_data'¶ The module name where instances of this type are defined.
-
type_id:
ClassVar[str] = 'ci'¶ Machine-readable type identifier used to derive module and symbol names.