extra_platforms package

Expose package-wide elements.

Submodules

extra_platforms.architecture_data module

Architecture definitions and metadata.

Hint

Architecture’s canonical IDs are inspired by those used in the auditwheel project to encode the manylinux policies.

See also

Architecture variants from Rust’s target-lexicon.

extra_platforms.ci_data module

CI definitions and metadata.

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 evaluate 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.group module

Group a collection of traits. Also referred as families.

extra_platforms.group_data module

Definitions of ready-to-use groups.

This module contains all predefined Group instances and frozenset collections that organize traits into logical categories.

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/starship/starship/blob/master/.github/config-schema.json

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

extra_platforms.shell_data module

Shell definitions and metadata.

extra_platforms.terminal_data module

Terminal definitions and metadata.

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.

extra_platforms.trait module

Trait base class for architectures, platforms, shells, terminals, 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.