extra_platforms packageΒΆ

Expose package-wide elements.

class extra_platforms.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]

class extra_platforms.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.

icon: str = 'β™²'ΒΆ

Icon of the CI environment.

info()[source]ΒΆ

Returns all CI attributes we can gather.

Return type:

dict[str, str | bool | None]

extra_platforms.current_architecture()[source]ΒΆ

Returns the Architecture matching the current environment.

Always raises an error if the current environment is not recognized, or if multiple architectures match.

Return type:

Architecture

extra_platforms.current_ci()[source]ΒΆ

Returns the CI system matching the current environment.

Returns None if not running inside a recognized CI system.

Always raises an error if multiple CI systems match.

Return type:

CI | None

extra_platforms.current_os()ΒΆ
Return type:

Platform

extra_platforms.current_platform()[source]ΒΆ

Always returns the best matching platform for the current environment.

If multiple platforms match the current environment, this function will try to select the best, informative one.

Raises an error if we can’t decide on a single, appropriate platform.

Return type:

Platform

extra_platforms.current_platforms()ΒΆ
Return type:

tuple[Platform, ...]

extra_platforms.current_traits()[source]ΒΆ

Returns all traits matching the current environment.

This includes platforms, architectures, and CI systems.

Always raises an error if the current environment is not recognized.

Attention

At this point it is too late to worry about caching. This function has no choice but to evaluate all detection heuristics.

Return type:

set[Trait]

class extra_platforms.Group(id, name, icon='❓', members=<factory>)[source]ΒΆ

Bases: object

A Group identifies a collection of Trait members.

Supports set-like operations (union, intersection, difference, etc.).

add(member)[source]ΒΆ

Return a new Group with the specified trait added.

If the trait is already in the group, returns a copy unchanged.

Return type:

Group

Args:

member: A Trait object or trait ID string to add.

Returns:

A new Group instance with the trait added.

Raises:

ValueError: If the trait ID is not recognized.

clear()[source]ΒΆ

Return a new empty Group with the same metadata.

Return type:

Group

Returns:

A new Group instance with no members but same id, name, and icon.

copy(id=None, name=None, icon=None, members=None)[source]ΒΆ

Return a shallow copy of the group.

Fields can be overridden by passing new values as arguments.

Return type:

Group

difference(*others)[source]ΒΆ

Return a new Group with members in the group that are not in the others.

Caution

The new Group will inherits the metadata of the first one. All other groups’ metadata will be ignored.

Return type:

Group

discard(member)[source]ΒΆ

Return a new Group with the specified trait removed if present.

Unlike remove(), this does not raise an error if the trait is not found.

Return type:

Group

Args:

member: A Trait object or trait ID string to remove.

Returns:

A new Group instance with the trait removed, or a copy if not present.

fullyintersects(other)[source]ΒΆ

Return True if the group has all members in common with other.

Return type:

bool

icon: str = '❓'ΒΆ

Icon of the group.

intersection(*others)[source]ΒΆ

Return a new Group with members common to the group and all others.

Caution

The new Group will inherits the metadata of the first one. All other groups’ metadata will be ignored.

Return type:

Group

isdisjoint(other)[source]ΒΆ

Return True if the group has no members in common with other.

Groups are disjoint if and only if their intersection is an empty set.

other can be an arbitrarily nested Iterable of Group and Trait.

Return type:

bool

issubset(other)[source]ΒΆ

Test whether every member in the group is in other.

Return type:

bool

issuperset(other)[source]ΒΆ

Test whether every member in other is in the group.

Return type:

bool

items()[source]ΒΆ

Iterate over the traits of the group as key-value pairs.

Return type:

Iterator[tuple[str, Trait]]

property member_ids: frozenset[str]ΒΆ

Set of member IDs that belong to this group.

pop(member_id=None)[source]ΒΆ

Remove and return a trait from the group.

Return type:

tuple[Trait, Group]

Args:
member_id: Optional trait ID to remove. If not provided, removes an arbitrary

trait (specifically, the first one in iteration order).

Returns:

A tuple of (removed_trait, new_group).

Raises:

KeyError: If member_id is provided but not found in the group. KeyError: If the group is empty.

remove(member)[source]ΒΆ

Return a new Group with the specified trait removed.

Raises KeyError if the trait is not in the group.

Return type:

Group

Args:

member: A Trait object or trait ID string to remove.

Returns:

A new Group instance with the trait removed.

Raises:

KeyError: If the trait is not in the group.

property short_desc: strΒΆ

Returns the group name with its first letter in lowercase to be used as a short description.

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

symmetric_difference(other)[source]ΒΆ

Return a new Group with members in either the group or other but not both.

Caution

The new Group will inherits the metadata of the first one. All other groups’ metadata will be ignored.

Return type:

Group

union(*others)[source]ΒΆ

Return a new Group with members from the group and all others.

Caution

The new Group will inherits the metadata of the first one. All other groups’ metadata will be ignored.

Return type:

Group

id: strΒΆ

Unique ID of the group.

name: strΒΆ

User-friendly description of a group.

members: Iterable[Trait]ΒΆ

Traits in this group.

Normalized to MappingProxyType[str, Trait] at init, providing O(1) lookup by ID.

extra_platforms.groups_from_ids(*group_ids)[source]ΒΆ

Returns a deduplicated tuple of groups matching the provided IDs.

IDs are case-insensitive.

Order of the returned groups matches the order of the provided IDs.

Tip

If you want to reduce the returned set and removes as much overlaps as possible, you can use the extra_platforms.reduce() function on the results.

Return type:

tuple[Group, ...]

extra_platforms.invalidate_caches()[source]ΒΆ

Invalidate all cached properties.

Inspired by the new platform.invalidate_caches() from Python 3.14, which is also called here when available.

extra_platforms.is_aarch64()[source]ΒΆ

Return True if current architecture is ARM64 (AArch64).

Return type:

bool

extra_platforms.is_aix()[source]ΒΆ

Return True if current platform is AIX.

Return type:

bool

extra_platforms.is_all_architectures()ΒΆ

Returns True if at least one trait is part of the group composed of all architectures, False otherwise.

Return type:

bool

extra_platforms.is_all_ci()ΒΆ

Returns True if at least one trait is part of the group composed of all CI systems, False otherwise.

Return type:

bool

extra_platforms.is_all_platforms()ΒΆ

Returns True if at least one trait is part of the group composed of all platforms, False otherwise.

Return type:

bool

extra_platforms.is_all_traits()ΒΆ

Returns True if at least one trait is part of the group composed of any architectures, platforms and CI systems, False otherwise.

Return type:

bool

extra_platforms.is_altlinux()[source]ΒΆ

Return True if current platform is ALT Linux.

Return type:

bool

extra_platforms.is_amzn()[source]ΒΆ

Return True if current platform is Amazon Linux.

Return type:

bool

extra_platforms.is_android()[source]ΒΆ

Return True if current platform is Android.

Source: https://github.com/kivy/kivy/blob/master/kivy/utils.py#L429

Return type:

bool

extra_platforms.is_any_windows()ΒΆ

Returns True if at least one trait is part of the group composed of any Windows, False otherwise.

Return type:

bool

extra_platforms.is_arch()[source]ΒΆ

Return True if current platform is Arch Linux.

Return type:

bool

extra_platforms.is_arm()[source]ΒΆ

Return True if current architecture is generic ARM (32-bit).

This matches ARM architectures not covered by more specific variants.

Return type:

bool

extra_platforms.is_armv6l()[source]ΒΆ

Return True if current architecture is ARMv6 (little-endian).

Return type:

bool

extra_platforms.is_armv7l()[source]ΒΆ

Return True if current architecture is ARMv7 (little-endian).

Return type:

bool

extra_platforms.is_armv8l()[source]ΒΆ

Return True if current architecture is ARMv8 (32-bit, little-endian).

Return type:

bool

extra_platforms.is_azure_pipelines()[source]ΒΆ

Return True if current platform is Azure Pipelines.

Environment variables reference.

Return type:

bool

extra_platforms.is_bamboo()[source]ΒΆ

Return True if current platform is Bamboo.

Environment variables reference.

Return type:

bool

extra_platforms.is_bsd()ΒΆ

Returns True if at least one trait is part of the group composed of any BSD, False otherwise.

Return type:

bool

extra_platforms.is_bsd_without_macos()ΒΆ

Returns True if at least one trait is part of the group composed of any BSD excluding macOS, False otherwise.

Return type:

bool

extra_platforms.is_buildkite()[source]ΒΆ

Return True if current platform is Buildkite.

Environment variables reference.

Return type:

bool

extra_platforms.is_buildroot()[source]ΒΆ

Return True if current platform is Buildroot.

Return type:

bool

extra_platforms.is_cachyos()[source]ΒΆ

Return True if current platform is CachyOS.

Return type:

bool

extra_platforms.is_centos()[source]ΒΆ

Return True if current platform is CentOS.

Return type:

bool

extra_platforms.is_circle_ci()[source]ΒΆ

Return True if current platform is Circle CI.

Environment variables reference.

Return type:

bool

extra_platforms.is_cirrus_ci()[source]ΒΆ

Return True if current platform is Cirrus CI.

Environment variables reference.

Return type:

bool

extra_platforms.is_cloudlinux()[source]ΒΆ

Return True if current platform is CloudLinux OS.

Return type:

bool

extra_platforms.is_codebuild()[source]ΒΆ

Return True if current platform is CodeBuild.

Environment variables reference.

Return type:

bool

extra_platforms.is_cygwin()[source]ΒΆ

Return True if current platform is Cygwin.

Return type:

bool

extra_platforms.is_debian()[source]ΒΆ

Return True if current platform is Debian.

Return type:

bool

extra_platforms.is_exherbo()[source]ΒΆ

Return True if current platform is Exherbo Linux.

Return type:

bool

extra_platforms.is_fedora()[source]ΒΆ

Return True if current platform is Fedora.

Return type:

bool

extra_platforms.is_freebsd()[source]ΒΆ

Return True if current platform is FreeBSD.

Return type:

bool

extra_platforms.is_gentoo()[source]ΒΆ

Return True if current platform is GenToo Linux.

Return type:

bool

extra_platforms.is_github_ci()[source]ΒΆ

Return True if current platform is GitHub Actions runner.

Environment variables reference.

Return type:

bool

extra_platforms.is_gitlab_ci()[source]ΒΆ

Return True if current platform is GitLab CI.

Environment variables reference.

Return type:

bool

extra_platforms.is_guix()[source]ΒΆ

Return True if current platform is Guix System.

Return type:

bool

extra_platforms.is_heroku_ci()[source]ΒΆ

Return True if current platform is Heroku CI.

Environment variables reference.

Return type:

bool

extra_platforms.is_hurd()[source]ΒΆ

Return True if current platform is GNU/Hurd.

sys.platform can returns GNU or gnu0, see: https://github.com/kdeldycke/extra-platforms/issues/308

Return type:

bool

extra_platforms.is_i386()[source]ΒΆ

Return True if current architecture is Intel 80386 (i386).

Return type:

bool

extra_platforms.is_i586()[source]ΒΆ

Return True if current architecture is Intel Pentium (i586).

Return type:

bool

extra_platforms.is_i686()[source]ΒΆ

Return True if current architecture is Intel Pentium Pro (i686).

Return type:

bool

extra_platforms.is_ibm_powerkvm()[source]ΒΆ

Return True if current platform is IBM PowerKVM.

Return type:

bool

extra_platforms.is_kvmibm()[source]ΒΆ

Return True if current platform is KVM for IBM z Systems.

Return type:

bool

extra_platforms.is_linux()ΒΆ

Returns True if at least one trait is part of the group composed of any Linux distribution, False otherwise.

Return type:

bool

extra_platforms.is_linux_layers()ΒΆ

Returns True if at least one trait is part of the group composed of any Linux compatibility layers, False otherwise.

Return type:

bool

extra_platforms.is_linux_like()ΒΆ

Returns True if at least one trait is part of the group composed of any Linux and compatibility layers, False otherwise.

Return type:

bool

extra_platforms.is_linuxmint()[source]ΒΆ

Return True if current platform is Linux Mint.

Return type:

bool

extra_platforms.is_loongarch64()[source]ΒΆ

Return True if current architecture is LoongArch (64-bit).

Return type:

bool

extra_platforms.is_macos()[source]ΒΆ

Return True if current platform is macOS.

Return type:

bool

extra_platforms.is_mageia()[source]ΒΆ

Return True if current platform is Mageia.

Return type:

bool

extra_platforms.is_mandriva()[source]ΒΆ

Return True if current platform is Mandriva Linux.

Return type:

bool

extra_platforms.is_midnightbsd()[source]ΒΆ

Return True if current platform is MidnightBSD.

Return type:

bool

extra_platforms.is_mips()[source]ΒΆ

Return True if current architecture is MIPS (32-bit, big-endian).

Return type:

bool

extra_platforms.is_mips64()[source]ΒΆ

Return True if current architecture is MIPS64 (big-endian).

Return type:

bool

extra_platforms.is_mips64el()[source]ΒΆ

Return True if current architecture is MIPS64 (little-endian).

Return type:

bool

extra_platforms.is_mipsel()[source]ΒΆ

Return True if current architecture is MIPS (32-bit, little-endian).

Return type:

bool

extra_platforms.is_netbsd()[source]ΒΆ

Return True if current platform is NetBSD.

Return type:

bool

extra_platforms.is_nobara()[source]ΒΆ

Return True if current platform is Nobara Linux.

Return type:

bool

extra_platforms.is_openbsd()[source]ΒΆ

Return True if current platform is OpenBSD.

Return type:

bool

extra_platforms.is_opensuse()[source]ΒΆ

Return True if current platform is openSUSE.

Return type:

bool

extra_platforms.is_oracle()[source]ΒΆ

Return True if current platform is Oracle Linux (and Oracle Enterprise Linux).

Return type:

bool

extra_platforms.is_other_unix()ΒΆ

Returns True if at least one trait is part of the group composed of any other Unix, False otherwise.

Return type:

bool

extra_platforms.is_parallels()[source]ΒΆ

Return True if current platform is Parallels.

Return type:

bool

extra_platforms.is_pidora()[source]ΒΆ

Return True if current platform is Pidora.

Return type:

bool

extra_platforms.is_ppc()[source]ΒΆ

Return True if current architecture is PowerPC (32-bit).

Return type:

bool

extra_platforms.is_ppc64()[source]ΒΆ

Return True if current architecture is PowerPC 64-bit (big-endian).

Return type:

bool

extra_platforms.is_ppc64le()[source]ΒΆ

Return True if current architecture is PowerPC 64-bit (little-endian).

Return type:

bool

extra_platforms.is_raspbian()[source]ΒΆ

Return True if current platform is Raspbian.

Return type:

bool

extra_platforms.is_rhel()[source]ΒΆ

Return True if current platform is RedHat Enterprise Linux.

Return type:

bool

extra_platforms.is_riscv32()[source]ΒΆ

Return True if current architecture is RISC-V (32-bit).

Return type:

bool

extra_platforms.is_riscv64()[source]ΒΆ

Return True if current architecture is RISC-V (64-bit).

Return type:

bool

extra_platforms.is_rocky()[source]ΒΆ

Return True if current platform is Rocky Linux.

Return type:

bool

extra_platforms.is_s390x()[source]ΒΆ

Return True if current architecture is IBM z/Architecture (s390x).

Return type:

bool

extra_platforms.is_scientific()[source]ΒΆ

Return True if current platform is Scientific Linux.

Return type:

bool

extra_platforms.is_slackware()[source]ΒΆ

Return True if current platform is Slackware.

Return type:

bool

extra_platforms.is_sles()[source]ΒΆ

Return True if current platform is SUSE Linux Enterprise Server.

Return type:

bool

extra_platforms.is_solaris()[source]ΒΆ

Return True if current platform is Solaris.

Return type:

bool

extra_platforms.is_sparc()[source]ΒΆ

Return True if current architecture is SPARC (32-bit).

Return type:

bool

extra_platforms.is_sparc64()[source]ΒΆ

Return True if current architecture is SPARC (64-bit).

Return type:

bool

extra_platforms.is_sunos()[source]ΒΆ

Return True if current platform is SunOS.

Return type:

bool

extra_platforms.is_system_v()ΒΆ

Returns True if at least one trait is part of the group composed of aT&T System Five, False otherwise.

Return type:

bool

extra_platforms.is_teamcity()[source]ΒΆ

Return True if current platform is TeamCity.

Environment variables reference.

Return type:

bool

extra_platforms.is_travis_ci()[source]ΒΆ

Return True if current platform is Travis CI.

Environment variables reference.

Return type:

bool

extra_platforms.is_tumbleweed()[source]ΒΆ

Return True if current platform is openSUSE Tumbleweed.

Return type:

bool

extra_platforms.is_tuxedo()[source]ΒΆ

Return True if current platform is Tuxedo OS.

Return type:

bool

extra_platforms.is_ubuntu()[source]ΒΆ

Return True if current platform is Ubuntu.

Return type:

bool

extra_platforms.is_ultramarine()[source]ΒΆ

Return True if current platform is Ultramarine.

Return type:

bool

extra_platforms.is_unix()ΒΆ

Returns True if at least one trait is part of the group composed of any Unix, False otherwise.

Return type:

bool

extra_platforms.is_unix_layers()ΒΆ

Returns True if at least one trait is part of the group composed of any Unix compatibility layers, False otherwise.

Return type:

bool

extra_platforms.is_unix_without_macos()ΒΆ

Returns True if at least one trait is part of the group composed of any Unix excluding macOS, False otherwise.

Return type:

bool

extra_platforms.is_unknown_architecture()[source]ΒΆ

Return True if current architecture is unknown.

Return type:

bool

extra_platforms.is_unknown_ci()[source]ΒΆ

Return True if current platform is an unknown CI.

Some CI systems relies on generic environment variables to identify themselves:

  • CI

  • BUILD_ID

Return type:

bool

extra_platforms.is_unknown_linux()[source]ΒΆ

Return True if current platform is an unknown Linux.

Return type:

bool

extra_platforms.is_wasm32()[source]ΒΆ

Return True if current architecture is WebAssembly (32-bit).

Note

WebAssembly detection is based on Emscripten’s platform identifier.

Return type:

bool

extra_platforms.is_wasm64()[source]ΒΆ

Return True if current architecture is WebAssembly (64-bit).

Note

WebAssembly 64-bit (memory64) is still experimental.

Return type:

bool

extra_platforms.is_windows()[source]ΒΆ

Return True if current platform is Windows.

Return type:

bool

extra_platforms.is_wsl1()[source]ΒΆ

Return True if current platform is running over Windows Subsystem for Linux v1.

Caution

The only difference between WSL1 and WSL2 is the case of the kernel release version:

  • WSL 1:

    $ uname -r
    4.4.0-22572-Microsoft
    
  • WSL 2:

    $ uname -r
    5.10.102.1-microsoft-standard-WSL2
    
Return type:

bool

extra_platforms.is_wsl2()[source]ΒΆ

Return True if current platform is running over Windows Subsystem for Linux v2.

Return type:

bool

extra_platforms.is_x86_64()[source]ΒΆ

Return True if current architecture is x86-64 (AMD64).

Note

Windows returns AMD64 in uppercase, so we normalize to lowercase.

Return type:

bool

extra_platforms.is_xenserver()[source]ΒΆ

Return True if current platform is XenServer.

Return type:

bool

class extra_platforms.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]]

extra_platforms.platforms_from_ids(*trait_and_group_ids)ΒΆ

Returns a deduplicated tuple of traits matching the provided IDs.

IDs are case-insensitive, and can refer to any traits or groups. Matching groups will be expanded to the traits they contain.

Order of the returned traits matches the order of the provided IDs.

Tip

If you want to reduce the returned set and removes as much overlaps as possible, you can use the extra_platforms.reduce() function on the results.

Return type:

tuple[Trait, ...]

extra_platforms.reduce(items, target_pool=None)[source]ΒΆ

Reduce a collection of traits to a minimal set.

Returns a deduplicated set of Group and Trait that covers the same exact traits as the original input, but group as much traits as possible, to reduce the number of items.

Only the groups defined in the target_pool are considered for the reduction. If no reference pool is provided, use all known groups.

Hint

Maybe this could be solved with some Euler diagram algorithms, like those implemented in eule.

This is being discussed upstream at trouchet/eule#120.

Todo

Should we rename or alias this method to collapse()? Cannot decide if it is more descriptive or not…

Return type:

frozenset[Group | Trait]

class extra_platforms.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

property current: boolΒΆ

Returns whether the current environment matches this trait.

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

icon: str = '❓'ΒΆ

Icon of the trait.

abstractmethod info()[source]ΒΆ

Returns all trait attributes that can be gathered.

Subclasses should override this to include trait-specific information.

Return type:

dict

property short_desc: strΒΆ

Returns a short description of the trait.

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

url: str = ''ΒΆ

URL to the trait’s official website or documentation.

id: strΒΆ

Unique ID of the trait.

name: strΒΆ

User-friendly name of the trait.

extra_platforms.traits_from_ids(*trait_and_group_ids)[source]ΒΆ

Returns a deduplicated tuple of traits matching the provided IDs.

IDs are case-insensitive, and can refer to any traits or groups. Matching groups will be expanded to the traits they contain.

Order of the returned traits matches the order of the provided IDs.

Tip

If you want to reduce the returned set and removes as much overlaps as possible, you can use the extra_platforms.reduce() function on the results.

Return type:

tuple[Trait, ...]

SubmodulesΒΆ

extra_platforms.detection moduleΒΆ

Heuristics to detect all traits of the current environment.

This collection of heuristics is designed as a set of separate function with minimal logic and dependencies. They’re the building blocks to detect the current platform, and are the first functions called when trying to detect the current environment.

All these heuristics can be hard-cached as the underlying system is not changing between code execution. They are still allowed to depends on each others, as long as you’re careful of not implementing circular dependencies.

Warning

Even if highly unlikely, it is possible to have multiple platforms detected for the same environment.

Typical example is Ubuntu WSL, which will make both the is_wsl2() and is_ubuntu() functions return True at the same time.

That’s because of the environment metadata, where:

$ uname -a
Linux 5.15.167.4-microsoft-standard-WSL2

$ cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04.5 LTS"

That way we have the possibility elsewhere in extra-platforms to either decide if we only allow one, and only one, heuristic to match the current system, or allow for considering multiple systems at the same time.

Detection of Linux distribution rely on distro to gather as much details as possible. And also because it is the recommended replacement for Python’s original platform.linux_distribution function (which was removed in Python 3.8).

For all other traits, we either rely on:

See also

Other source of inspiration for platform detection:

extra_platforms.detection.is_aarch64()[source]ΒΆ

Return True if current architecture is ARM64 (AArch64).

Return type:

bool

extra_platforms.detection.is_arm()[source]ΒΆ

Return True if current architecture is generic ARM (32-bit).

This matches ARM architectures not covered by more specific variants.

Return type:

bool

extra_platforms.detection.is_armv6l()[source]ΒΆ

Return True if current architecture is ARMv6 (little-endian).

Return type:

bool

extra_platforms.detection.is_armv7l()[source]ΒΆ

Return True if current architecture is ARMv7 (little-endian).

Return type:

bool

extra_platforms.detection.is_armv8l()[source]ΒΆ

Return True if current architecture is ARMv8 (32-bit, little-endian).

Return type:

bool

extra_platforms.detection.is_i386()[source]ΒΆ

Return True if current architecture is Intel 80386 (i386).

Return type:

bool

extra_platforms.detection.is_i586()[source]ΒΆ

Return True if current architecture is Intel Pentium (i586).

Return type:

bool

extra_platforms.detection.is_i686()[source]ΒΆ

Return True if current architecture is Intel Pentium Pro (i686).

Return type:

bool

extra_platforms.detection.is_x86_64()[source]ΒΆ

Return True if current architecture is x86-64 (AMD64).

Note

Windows returns AMD64 in uppercase, so we normalize to lowercase.

Return type:

bool

extra_platforms.detection.is_mips()[source]ΒΆ

Return True if current architecture is MIPS (32-bit, big-endian).

Return type:

bool

extra_platforms.detection.is_mipsel()[source]ΒΆ

Return True if current architecture is MIPS (32-bit, little-endian).

Return type:

bool

extra_platforms.detection.is_mips64()[source]ΒΆ

Return True if current architecture is MIPS64 (big-endian).

Return type:

bool

extra_platforms.detection.is_mips64el()[source]ΒΆ

Return True if current architecture is MIPS64 (little-endian).

Return type:

bool

extra_platforms.detection.is_ppc()[source]ΒΆ

Return True if current architecture is PowerPC (32-bit).

Return type:

bool

extra_platforms.detection.is_ppc64()[source]ΒΆ

Return True if current architecture is PowerPC 64-bit (big-endian).

Return type:

bool

extra_platforms.detection.is_ppc64le()[source]ΒΆ

Return True if current architecture is PowerPC 64-bit (little-endian).

Return type:

bool

extra_platforms.detection.is_riscv32()[source]ΒΆ

Return True if current architecture is RISC-V (32-bit).

Return type:

bool

extra_platforms.detection.is_riscv64()[source]ΒΆ

Return True if current architecture is RISC-V (64-bit).

Return type:

bool

extra_platforms.detection.is_sparc()[source]ΒΆ

Return True if current architecture is SPARC (32-bit).

Return type:

bool

extra_platforms.detection.is_sparc64()[source]ΒΆ

Return True if current architecture is SPARC (64-bit).

Return type:

bool

extra_platforms.detection.is_s390x()[source]ΒΆ

Return True if current architecture is IBM z/Architecture (s390x).

Return type:

bool

extra_platforms.detection.is_loongarch64()[source]ΒΆ

Return True if current architecture is LoongArch (64-bit).

Return type:

bool

extra_platforms.detection.is_wasm32()[source]ΒΆ

Return True if current architecture is WebAssembly (32-bit).

Note

WebAssembly detection is based on Emscripten’s platform identifier.

Return type:

bool

extra_platforms.detection.is_wasm64()[source]ΒΆ

Return True if current architecture is WebAssembly (64-bit).

Note

WebAssembly 64-bit (memory64) is still experimental.

Return type:

bool

extra_platforms.detection.is_unknown_architecture()[source]ΒΆ

Return True if current architecture is unknown.

Return type:

bool

extra_platforms.detection.is_aix()[source]ΒΆ

Return True if current platform is AIX.

Return type:

bool

extra_platforms.detection.is_altlinux()[source]ΒΆ

Return True if current platform is ALT Linux.

Return type:

bool

extra_platforms.detection.is_amzn()[source]ΒΆ

Return True if current platform is Amazon Linux.

Return type:

bool

extra_platforms.detection.is_android()[source]ΒΆ

Return True if current platform is Android.

Source: https://github.com/kivy/kivy/blob/master/kivy/utils.py#L429

Return type:

bool

extra_platforms.detection.is_arch()[source]ΒΆ

Return True if current platform is Arch Linux.

Return type:

bool

extra_platforms.detection.is_buildroot()[source]ΒΆ

Return True if current platform is Buildroot.

Return type:

bool

extra_platforms.detection.is_cachyos()[source]ΒΆ

Return True if current platform is CachyOS.

Return type:

bool

extra_platforms.detection.is_centos()[source]ΒΆ

Return True if current platform is CentOS.

Return type:

bool

extra_platforms.detection.is_cloudlinux()[source]ΒΆ

Return True if current platform is CloudLinux OS.

Return type:

bool

extra_platforms.detection.is_cygwin()[source]ΒΆ

Return True if current platform is Cygwin.

Return type:

bool

extra_platforms.detection.is_debian()[source]ΒΆ

Return True if current platform is Debian.

Return type:

bool

extra_platforms.detection.is_exherbo()[source]ΒΆ

Return True if current platform is Exherbo Linux.

Return type:

bool

extra_platforms.detection.is_fedora()[source]ΒΆ

Return True if current platform is Fedora.

Return type:

bool

extra_platforms.detection.is_freebsd()[source]ΒΆ

Return True if current platform is FreeBSD.

Return type:

bool

extra_platforms.detection.is_gentoo()[source]ΒΆ

Return True if current platform is GenToo Linux.

Return type:

bool

extra_platforms.detection.is_guix()[source]ΒΆ

Return True if current platform is Guix System.

Return type:

bool

extra_platforms.detection.is_hurd()[source]ΒΆ

Return True if current platform is GNU/Hurd.

sys.platform can returns GNU or gnu0, see: https://github.com/kdeldycke/extra-platforms/issues/308

Return type:

bool

extra_platforms.detection.is_ibm_powerkvm()[source]ΒΆ

Return True if current platform is IBM PowerKVM.

Return type:

bool

extra_platforms.detection.is_kvmibm()[source]ΒΆ

Return True if current platform is KVM for IBM z Systems.

Return type:

bool

extra_platforms.detection.is_linuxmint()[source]ΒΆ

Return True if current platform is Linux Mint.

Return type:

bool

extra_platforms.detection.is_macos()[source]ΒΆ

Return True if current platform is macOS.

Return type:

bool

extra_platforms.detection.is_mageia()[source]ΒΆ

Return True if current platform is Mageia.

Return type:

bool

extra_platforms.detection.is_mandriva()[source]ΒΆ

Return True if current platform is Mandriva Linux.

Return type:

bool

extra_platforms.detection.is_midnightbsd()[source]ΒΆ

Return True if current platform is MidnightBSD.

Return type:

bool

extra_platforms.detection.is_netbsd()[source]ΒΆ

Return True if current platform is NetBSD.

Return type:

bool

extra_platforms.detection.is_nobara()[source]ΒΆ

Return True if current platform is Nobara Linux.

Return type:

bool

extra_platforms.detection.is_openbsd()[source]ΒΆ

Return True if current platform is OpenBSD.

Return type:

bool

extra_platforms.detection.is_opensuse()[source]ΒΆ

Return True if current platform is openSUSE.

Return type:

bool

extra_platforms.detection.is_oracle()[source]ΒΆ

Return True if current platform is Oracle Linux (and Oracle Enterprise Linux).

Return type:

bool

extra_platforms.detection.is_parallels()[source]ΒΆ

Return True if current platform is Parallels.

Return type:

bool

extra_platforms.detection.is_pidora()[source]ΒΆ

Return True if current platform is Pidora.

Return type:

bool

extra_platforms.detection.is_raspbian()[source]ΒΆ

Return True if current platform is Raspbian.

Return type:

bool

extra_platforms.detection.is_rhel()[source]ΒΆ

Return True if current platform is RedHat Enterprise Linux.

Return type:

bool

extra_platforms.detection.is_rocky()[source]ΒΆ

Return True if current platform is Rocky Linux.

Return type:

bool

extra_platforms.detection.is_scientific()[source]ΒΆ

Return True if current platform is Scientific Linux.

Return type:

bool

extra_platforms.detection.is_slackware()[source]ΒΆ

Return True if current platform is Slackware.

Return type:

bool

extra_platforms.detection.is_sles()[source]ΒΆ

Return True if current platform is SUSE Linux Enterprise Server.

Return type:

bool

extra_platforms.detection.is_solaris()[source]ΒΆ

Return True if current platform is Solaris.

Return type:

bool

extra_platforms.detection.is_sunos()[source]ΒΆ

Return True if current platform is SunOS.

Return type:

bool

extra_platforms.detection.is_tumbleweed()[source]ΒΆ

Return True if current platform is openSUSE Tumbleweed.

Return type:

bool

extra_platforms.detection.is_tuxedo()[source]ΒΆ

Return True if current platform is Tuxedo OS.

Return type:

bool

extra_platforms.detection.is_ubuntu()[source]ΒΆ

Return True if current platform is Ubuntu.

Return type:

bool

extra_platforms.detection.is_ultramarine()[source]ΒΆ

Return True if current platform is Ultramarine.

Return type:

bool

extra_platforms.detection.is_unknown_linux()[source]ΒΆ

Return True if current platform is an unknown Linux.

Return type:

bool

extra_platforms.detection.is_windows()[source]ΒΆ

Return True if current platform is Windows.

Return type:

bool

extra_platforms.detection.is_wsl1()[source]ΒΆ

Return True if current platform is running over Windows Subsystem for Linux v1.

Caution

The only difference between WSL1 and WSL2 is the case of the kernel release version:

  • WSL 1:

    $ uname -r
    4.4.0-22572-Microsoft
    
  • WSL 2:

    $ uname -r
    5.10.102.1-microsoft-standard-WSL2
    
Return type:

bool

extra_platforms.detection.is_wsl2()[source]ΒΆ

Return True if current platform is running over Windows Subsystem for Linux v2.

Return type:

bool

extra_platforms.detection.is_xenserver()[source]ΒΆ

Return True if current platform is XenServer.

Return type:

bool

extra_platforms.detection.is_azure_pipelines()[source]ΒΆ

Return True if current platform is Azure Pipelines.

Environment variables reference.

Return type:

bool

extra_platforms.detection.is_bamboo()[source]ΒΆ

Return True if current platform is Bamboo.

Environment variables reference.

Return type:

bool

extra_platforms.detection.is_buildkite()[source]ΒΆ

Return True if current platform is Buildkite.

Environment variables reference.

Return type:

bool

extra_platforms.detection.is_circle_ci()[source]ΒΆ

Return True if current platform is Circle CI.

Environment variables reference.

Return type:

bool

extra_platforms.detection.is_cirrus_ci()[source]ΒΆ

Return True if current platform is Cirrus CI.

Environment variables reference.

Return type:

bool

extra_platforms.detection.is_codebuild()[source]ΒΆ

Return True if current platform is CodeBuild.

Environment variables reference.

Return type:

bool

extra_platforms.detection.is_github_ci()[source]ΒΆ

Return True if current platform is GitHub Actions runner.

Environment variables reference.

Return type:

bool

extra_platforms.detection.is_gitlab_ci()[source]ΒΆ

Return True if current platform is GitLab CI.

Environment variables reference.

Return type:

bool

extra_platforms.detection.is_heroku_ci()[source]ΒΆ

Return True if current platform is Heroku CI.

Environment variables reference.

Return type:

bool

extra_platforms.detection.is_teamcity()[source]ΒΆ

Return True if current platform is TeamCity.

Environment variables reference.

Return type:

bool

extra_platforms.detection.is_travis_ci()[source]ΒΆ

Return True if current platform is Travis CI.

Environment variables reference.

Return type:

bool

extra_platforms.detection.is_unknown_ci()[source]ΒΆ

Return True if current platform is an unknown CI.

Some CI systems relies on generic environment variables to identify themselves:

  • CI

  • BUILD_ID

Return type:

bool

extra_platforms.group moduleΒΆ

Group a collection of traits. Also referred as families.

class extra_platforms.group.Group(id, name, icon='❓', members=<factory>)[source]ΒΆ

Bases: object

A Group identifies a collection of Trait members.

Supports set-like operations (union, intersection, difference, etc.).

id: strΒΆ

Unique ID of the group.

name: strΒΆ

User-friendly description of a group.

icon: str = '❓'ΒΆ

Icon of the group.

members: Iterable[Trait]ΒΆ

Traits in this group.

Normalized to MappingProxyType[str, Trait] at init, providing O(1) lookup by ID.

property member_ids: frozenset[str]ΒΆ

Set of member IDs that belong to this group.

property short_desc: strΒΆ

Returns the group name with its first letter in lowercase to be used as a short description.

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

items()[source]ΒΆ

Iterate over the traits of the group as key-value pairs.

Return type:

Iterator[tuple[str, Trait]]

isdisjoint(other)[source]ΒΆ

Return True if the group has no members in common with other.

Groups are disjoint if and only if their intersection is an empty set.

other can be an arbitrarily nested Iterable of Group and Trait.

Return type:

bool

fullyintersects(other)[source]ΒΆ

Return True if the group has all members in common with other.

Return type:

bool

issubset(other)[source]ΒΆ

Test whether every member in the group is in other.

Return type:

bool

issuperset(other)[source]ΒΆ

Test whether every member in other is in the group.

Return type:

bool

union(*others)[source]ΒΆ

Return a new Group with members from the group and all others.

Caution

The new Group will inherits the metadata of the first one. All other groups’ metadata will be ignored.

Return type:

Group

intersection(*others)[source]ΒΆ

Return a new Group with members common to the group and all others.

Caution

The new Group will inherits the metadata of the first one. All other groups’ metadata will be ignored.

Return type:

Group

difference(*others)[source]ΒΆ

Return a new Group with members in the group that are not in the others.

Caution

The new Group will inherits the metadata of the first one. All other groups’ metadata will be ignored.

Return type:

Group

symmetric_difference(other)[source]ΒΆ

Return a new Group with members in either the group or other but not both.

Caution

The new Group will inherits the metadata of the first one. All other groups’ metadata will be ignored.

Return type:

Group

copy(id=None, name=None, icon=None, members=None)[source]ΒΆ

Return a shallow copy of the group.

Fields can be overridden by passing new values as arguments.

Return type:

Group

add(member)[source]ΒΆ

Return a new Group with the specified trait added.

If the trait is already in the group, returns a copy unchanged.

Return type:

Group

Args:

member: A Trait object or trait ID string to add.

Returns:

A new Group instance with the trait added.

Raises:

ValueError: If the trait ID is not recognized.

remove(member)[source]ΒΆ

Return a new Group with the specified trait removed.

Raises KeyError if the trait is not in the group.

Return type:

Group

Args:

member: A Trait object or trait ID string to remove.

Returns:

A new Group instance with the trait removed.

Raises:

KeyError: If the trait is not in the group.

discard(member)[source]ΒΆ

Return a new Group with the specified trait removed if present.

Unlike remove(), this does not raise an error if the trait is not found.

Return type:

Group

Args:

member: A Trait object or trait ID string to remove.

Returns:

A new Group instance with the trait removed, or a copy if not present.

pop(member_id=None)[source]ΒΆ

Remove and return a trait from the group.

Return type:

tuple[Trait, Group]

Args:
member_id: Optional trait ID to remove. If not provided, removes an arbitrary

trait (specifically, the first one in iteration order).

Returns:

A tuple of (removed_trait, new_group).

Raises:

KeyError: If member_id is provided but not found in the group. KeyError: If the group is empty.

clear()[source]ΒΆ

Return a new empty Group with the same metadata.

Return type:

Group

Returns:

A new Group instance with no members but same id, name, and icon.

extra_platforms.group_data moduleΒΆ

Definitions of ready-to-use groups.

extra_platforms.group_data.ALL_ARCHITECTURES: Group = Group(id='all_architectures', name='All architectures')ΒΆ

All supported architectures.

extra_platforms.group_data.ALL_CI = Group(id='all_ci', name='All CI systems')ΒΆ

All Continuous Integration systems.

extra_platforms.group_data.ALL_TRAITS = Group(id='all_traits', name='Any architectures, platforms and CI systems')ΒΆ

All supported architectures, platforms and CI systems.

extra_platforms.group_data.ANY_WINDOWS = Group(id='any_windows', name='Any Windows')ΒΆ

All Windows operating systems.

extra_platforms.group_data.UNIX = Group(id='unix', name='Any Unix')ΒΆ

All Unix-like operating systems and compatibility layers.

extra_platforms.group_data.UNIX_WITHOUT_MACOS = Group(id='unix_without_macos', name='Any Unix excluding macOS')ΒΆ

All Unix platforms, without macOS.

This is useful to avoid macOS-specific workarounds on Unix platforms.

extra_platforms.group_data.BSD = Group(id='bsd', name='Any BSD')ΒΆ

All BSD platforms.

Note

Are considered of this family (according Wikipedia):

  • 386BSD (FreeBSD, NetBSD, OpenBSD, DragonFly BSD)

  • NeXTSTEP

  • Darwin (macOS, iOS, audioOS, iPadOS, tvOS, watchOS, bridgeOS)

  • SunOS

  • Ultrix

extra_platforms.group_data.BSD_WITHOUT_MACOS = Group(id='bsd_without_macos', name='Any BSD excluding macOS')ΒΆ

All BSD platforms, without macOS.

This is useful to avoid macOS-specific workarounds on BSD platforms.

extra_platforms.group_data.LINUX = Group(id='linux', name='Any Linux distribution')ΒΆ

All distributions based on a Linux kernel.

Note

Are considered of this family (according Wikipedia):

  • Android

  • ChromeOS

  • any other distribution

extra_platforms.group_data.LINUX_LAYERS = Group(id='linux_layers', name='Any Linux compatibility layers')ΒΆ

Interfaces that allows Linux binaries to run on a different host system.

Note

Are considered of this family (according Wikipedia):

  • Windows Subsystem for Linux

extra_platforms.group_data.LINUX_LIKE = Group(id='linux_like', name='Any Linux and compatibility layers')ΒΆ

Sum of all Linux distributions and Linux compatibility layers.

extra_platforms.group_data.SYSTEM_V = Group(id='system_v', name='AT&T System Five')ΒΆ

All Unix platforms derived from AT&T System Five.

Note

Are considered of this family (according Wikipedia):

  • A/UX

  • AIX

  • HP-UX

  • IRIX

  • OpenServer

  • Solaris

  • OpenSolaris

  • Illumos

  • Tru64

  • UNIX

  • UnixWare

extra_platforms.group_data.UNIX_LAYERS = Group(id='unix_layers', name='Any Unix compatibility layers')ΒΆ

Interfaces that allows Unix binaries to run on a different host system.

Note

Are considered of this family (according Wikipedia):

  • Cygwin

  • Darling

  • Eunice

  • GNV

  • Interix

  • MachTen

  • Microsoft POSIX subsystem

  • MKS Toolkit

  • PASE

  • P.I.P.S.

  • PWS/VSE-AF

  • UNIX System Services

  • UserLAnd Technologies

  • Windows Services for UNIX

extra_platforms.group_data.OTHER_UNIX = Group(id='other_unix', name='Any other Unix')ΒΆ

All other Unix platforms.

Note

Are considered of this family (according Wikipedia):

  • Coherent

  • GNU/Hurd

  • HarmonyOS

  • LiteOS

  • LynxOS

  • Minix

  • MOS

  • OSF/1

  • QNX

  • BlackBerry 10

  • Research Unix

  • SerenityOS

extra_platforms.group_data.ALL_ARCHITECTURE_GROUPS: frozenset[Group] = frozenset({Group(id='all_architectures', name='All architectures')})ΒΆ

All groups whose members are architectures.

extra_platforms.group_data.ALL_PLATFORM_GROUPS: frozenset[Group] = frozenset({Group(id='linux', name='Any Linux distribution'), Group(id='linux_layers', name='Any Linux compatibility layers'), Group(id='linux_like', name='Any Linux and compatibility layers'), Group(id='unix_layers', name='Any Unix compatibility layers'), Group(id='system_v', name='AT&T System Five'), Group(id='other_unix', name='Any other Unix'), Group(id='bsd_without_macos', name='Any BSD excluding macOS'), Group(id='unix_without_macos', name='Any Unix excluding macOS'), Group(id='bsd', name='Any BSD'), Group(id='unix', name='Any Unix'), Group(id='any_windows', name='Any Windows'), Group(id='all_platforms', name='All platforms')})ΒΆ

All groups whose members are platforms.

extra_platforms.group_data.ALL_CI_GROUPS: frozenset[Group] = frozenset({Group(id='all_ci', name='All CI systems')})ΒΆ

All groups whose members are CI systems.

extra_platforms.group_data.NON_OVERLAPPING_GROUPS: frozenset[Group] = frozenset({Group(id='linux', name='Any Linux distribution'), Group(id='linux_layers', name='Any Linux compatibility layers'), Group(id='all_ci', name='All CI systems'), Group(id='unix_layers', name='Any Unix compatibility layers'), Group(id='system_v', name='AT&T System Five'), Group(id='bsd', name='Any BSD'), Group(id='all_architectures', name='All architectures'), Group(id='any_windows', name='Any Windows'), Group(id='other_unix', name='Any other Unix')})ΒΆ

Non-overlapping groups.

extra_platforms.group_data.EXTRA_GROUPS: frozenset[Group] = frozenset({Group(id='linux_like', name='Any Linux and compatibility layers'), Group(id='bsd_without_macos', name='Any BSD excluding macOS'), Group(id='unix_without_macos', name='Any Unix excluding macOS'), Group(id='unix', name='Any Unix'), Group(id='all_platforms', name='All platforms'), Group(id='all_traits', name='Any architectures, platforms and CI systems')})ΒΆ

Overlapping groups, defined for convenience.

extra_platforms.group_data.ALL_GROUPS: frozenset[Group] = frozenset({Group(id='linux', name='Any Linux distribution'), Group(id='linux_layers', name='Any Linux compatibility layers'), Group(id='linux_like', name='Any Linux and compatibility layers'), Group(id='unix_layers', name='Any Unix compatibility layers'), Group(id='system_v', name='AT&T System Five'), Group(id='other_unix', name='Any other Unix'), Group(id='bsd_without_macos', name='Any BSD excluding macOS'), Group(id='unix_without_macos', name='Any Unix excluding macOS'), Group(id='unix', name='Any Unix'), Group(id='all_ci', name='All CI systems'), Group(id='bsd', name='Any BSD'), Group(id='any_windows', name='Any Windows'), Group(id='all_platforms', name='All platforms'), Group(id='all_architectures', name='All architectures'), Group(id='all_traits', name='Any architectures, platforms and CI systems')})ΒΆ

All groups.

extra_platforms.operations moduleΒΆ

Operations on a mix of Groups and Platforms.

extra_platforms.operations.ALL_TRAIT_IDS: frozenset[str] = frozenset({'aarch64', 'aix', 'altlinux', 'amzn', 'android', 'arch', 'arm', 'armv6l', 'armv7l', 'armv8l', 'azure_pipelines', 'bamboo', 'buildkite', 'buildroot', 'cachyos', 'centos', 'circle_ci', 'cirrus_ci', 'cloudlinux', 'codebuild', 'cygwin', 'debian', 'exherbo', 'fedora', 'freebsd', 'gentoo', 'github_ci', 'gitlab_ci', 'guix', 'heroku_ci', 'hurd', 'i386', 'i586', 'i686', 'ibm_powerkvm', 'kvmibm', 'linuxmint', 'loongarch64', 'macos', 'mageia', 'mandriva', 'midnightbsd', 'mips', 'mips64', 'mips64el', 'mipsel', 'netbsd', 'nobara', 'openbsd', 'opensuse', 'oracle', 'parallels', 'pidora', 'ppc', 'ppc64', 'ppc64le', 'raspbian', 'rhel', 'riscv32', 'riscv64', 'rocky', 's390x', 'scientific', 'slackware', 'sles', 'solaris', 'sparc', 'sparc64', 'sunos', 'teamcity', 'travis_ci', 'tumbleweed', 'tuxedo', 'ubuntu', 'ultramarine', 'unknown_architecture', 'unknown_ci', 'unknown_linux', 'wasm32', 'wasm64', 'windows', 'wsl1', 'wsl2', 'x86_64', 'xenserver'})ΒΆ

Set of all recognized traits IDs.

extra_platforms.operations.ALL_GROUP_IDS: frozenset[str] = frozenset({'all_architectures', 'all_ci', 'all_platforms', 'all_traits', 'any_windows', 'bsd', 'bsd_without_macos', 'linux', 'linux_layers', 'linux_like', 'other_unix', 'system_v', 'unix', 'unix_layers', 'unix_without_macos'})ΒΆ

Set of all recognized group IDs.

extra_platforms.operations.ALL_IDS: frozenset[str] = frozenset({'aarch64', 'aix', 'all_architectures', 'all_ci', 'all_platforms', 'all_traits', 'altlinux', 'amzn', 'android', 'any_windows', 'arch', 'arm', 'armv6l', 'armv7l', 'armv8l', 'azure_pipelines', 'bamboo', 'bsd', 'bsd_without_macos', 'buildkite', 'buildroot', 'cachyos', 'centos', 'circle_ci', 'cirrus_ci', 'cloudlinux', 'codebuild', 'cygwin', 'debian', 'exherbo', 'fedora', 'freebsd', 'gentoo', 'github_ci', 'gitlab_ci', 'guix', 'heroku_ci', 'hurd', 'i386', 'i586', 'i686', 'ibm_powerkvm', 'kvmibm', 'linux', 'linux_layers', 'linux_like', 'linuxmint', 'loongarch64', 'macos', 'mageia', 'mandriva', 'midnightbsd', 'mips', 'mips64', 'mips64el', 'mipsel', 'netbsd', 'nobara', 'openbsd', 'opensuse', 'oracle', 'other_unix', 'parallels', 'pidora', 'ppc', 'ppc64', 'ppc64le', 'raspbian', 'rhel', 'riscv32', 'riscv64', 'rocky', 's390x', 'scientific', 'slackware', 'sles', 'solaris', 'sparc', 'sparc64', 'sunos', 'system_v', 'teamcity', 'travis_ci', 'tumbleweed', 'tuxedo', 'ubuntu', 'ultramarine', 'unix', 'unix_layers', 'unix_without_macos', 'unknown_architecture', 'unknown_ci', 'unknown_linux', 'wasm32', 'wasm64', 'windows', 'wsl1', 'wsl2', 'x86_64', 'xenserver'})ΒΆ

Set of all recognized traits and group IDs.

extra_platforms.operations.traits_from_ids(*trait_and_group_ids)[source]ΒΆ

Returns a deduplicated tuple of traits matching the provided IDs.

IDs are case-insensitive, and can refer to any traits or groups. Matching groups will be expanded to the traits they contain.

Order of the returned traits matches the order of the provided IDs.

Tip

If you want to reduce the returned set and removes as much overlaps as possible, you can use the extra_platforms.reduce() function on the results.

Return type:

tuple[Trait, ...]

extra_platforms.operations.groups_from_ids(*group_ids)[source]ΒΆ

Returns a deduplicated tuple of groups matching the provided IDs.

IDs are case-insensitive.

Order of the returned groups matches the order of the provided IDs.

Tip

If you want to reduce the returned set and removes as much overlaps as possible, you can use the extra_platforms.reduce() function on the results.

Return type:

tuple[Group, ...]

extra_platforms.operations.reduce(items, target_pool=None)[source]ΒΆ

Reduce a collection of traits to a minimal set.

Returns a deduplicated set of Group and Trait that covers the same exact traits as the original input, but group as much traits as possible, to reduce the number of items.

Only the groups defined in the target_pool are considered for the reduction. If no reference pool is provided, use all known groups.

Hint

Maybe this could be solved with some Euler diagram algorithms, like those implemented in eule.

This is being discussed upstream at trouchet/eule#120.

Todo

Should we rename or alias this method to collapse()? Cannot decide if it is more descriptive or not…

Return type:

frozenset[Group | Trait]

extra_platforms.platform moduleΒΆ

Platforms, also known as Operating Systems.

class extra_platforms.platform.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.

extra_platforms.platform_data moduleΒΆ

Platform definitions and metadata.

Note

Default icons are inspired from Starship project: - https://starship.rs/config/#os - https://github.com/davidkna/starship/blob/e9faf17/.github/config-schema.json#L1221-L1269

Some icons, especially Linux distributions, have their own dedicated codepoints in NerdFonts.

extra_platforms.platform_data.NOBARA = Platform(id='nobara', name='Nobara')ΒΆ

Note

Instead of using a loose Unicode icon for the Nobara OS, or just not adding any, we are using a NerdFont icon instead: οŽ€ (i.e. nf-linux-nobara / f380).

The side-effect of using a NerdFont character is it will only display correctly when using a supported font. Otherwise, it will appear as an unknown or invisible character depending on the fonts.

Todo

In the future, we may want to have two icons for each platform, one that is Unicode-based, the other that is NerdFont-based.

extra_platforms.pytest moduleΒΆ

Pytest decorators to skip tests depending on the platform they’re run on.

Generates a pair of ready-to-use @skip_<id> and @unless_<id> decorators for each platform and group.

class extra_platforms.pytest.DeferredCondition(condition, invert=False)[source]ΒΆ

Bases: object

Defer the evaluation of a condition.

This allow a callable returning a boolean to be evaluated only when the boolean value is requested.

Pytest’s marks can have a condition attached to them. Which is practical for implementing our own ready-to-use @skip and @unless decorators.

The problem is: this condition is evaluated at import time. Which leads to all our platform detection heuristics to be called when we generates our custom decorators below.

This issue is being discussed upstream at: