extra_platforms packageΒΆ
Expose package-wide elements.
- class extra_platforms.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.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.
- extra_platforms.current_architecture()[source]ΒΆ
Returns the
Architecturematching the current environment.Always raises an error if the current environment is not recognized, or if multiple architectures match.
- Return type:
- extra_platforms.current_ci()[source]ΒΆ
Returns the
CIsystem matching the current environment.Returns
Noneif not running inside a recognized CI system.Always raises an error if multiple CI systems match.
- 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:
- 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.
- class extra_platforms.Group(id, name, icon='β', members=<factory>)[source]ΒΆ
Bases:
objectA
Groupidentifies a collection ofTraitmembers.Supports set-like operations (union, intersection, difference, etc.).
- add(member)[source]ΒΆ
Return a new
Groupwith the specified trait added.If the trait is already in the group, returns a copy unchanged.
- Return type:
- Args:
member: A
Traitobject or trait ID string to add.- Returns:
A new
Groupinstance with the trait added.- Raises:
ValueError: If the trait ID is not recognized.
- clear()[source]ΒΆ
Return a new empty
Groupwith the same metadata.- Return type:
- Returns:
A new
Groupinstance 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:
- difference(*others)[source]ΒΆ
Return a new
Groupwith members in the group that are not in the others.Caution
The new
Groupwill inherits the metadata of the first one. All other groupsβ metadata will be ignored.- Return type:
- discard(member)[source]ΒΆ
Return a new
Groupwith the specified trait removed if present.Unlike
remove(), this does not raise an error if the trait is not found.- Return type:
- Args:
member: A
Traitobject or trait ID string to remove.- Returns:
A new
Groupinstance 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:
- intersection(*others)[source]ΒΆ
Return a new
Groupwith members common to the group and all others.Caution
The new
Groupwill inherits the metadata of the first one. All other groupsβ metadata will be ignored.- Return type:
- 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.
othercan be an arbitrarily nestedIterableofGroupandTrait.- Return type:
- pop(member_id=None)[source]ΒΆ
Remove and return a trait from the 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_idis provided but not found in the group. KeyError: If the group is empty.
- remove(member)[source]ΒΆ
Return a new
Groupwith the specified trait removed.Raises
KeyErrorif the trait is not in the group.- Return type:
- Args:
member: A
Traitobject or trait ID string to remove.- Returns:
A new
Groupinstance 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
Groupwith members in either the group or other but not both.Caution
The new
Groupwill inherits the metadata of the first one. All other groupsβ metadata will be ignored.- Return type:
- 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.
- 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
Trueif current architecture is ARM64 (AArch64).- Return type:
- extra_platforms.is_all_architectures()ΒΆ
Returns
Trueif at least one trait is part of the group composed of all architectures,Falseotherwise.- Return type:
- extra_platforms.is_all_ci()ΒΆ
Returns
Trueif at least one trait is part of the group composed of all CI systems,Falseotherwise.- Return type:
- extra_platforms.is_all_platforms()ΒΆ
Returns
Trueif at least one trait is part of the group composed of all platforms,Falseotherwise.- Return type:
- extra_platforms.is_all_traits()ΒΆ
Returns
Trueif at least one trait is part of the group composed of any architectures, platforms and CI systems,Falseotherwise.- Return type:
- extra_platforms.is_android()[source]ΒΆ
Return
Trueif current platform is Android.Source: https://github.com/kivy/kivy/blob/master/kivy/utils.py#L429
- Return type:
- extra_platforms.is_any_windows()ΒΆ
Returns
Trueif at least one trait is part of the group composed of any Windows,Falseotherwise.- Return type:
- extra_platforms.is_arm()[source]ΒΆ
Return
Trueif current architecture is generic ARM (32-bit).This matches ARM architectures not covered by more specific variants.
- Return type:
- extra_platforms.is_armv6l()[source]ΒΆ
Return
Trueif current architecture is ARMv6 (little-endian).- Return type:
- extra_platforms.is_armv7l()[source]ΒΆ
Return
Trueif current architecture is ARMv7 (little-endian).- Return type:
- extra_platforms.is_armv8l()[source]ΒΆ
Return
Trueif current architecture is ARMv8 (32-bit, little-endian).- Return type:
- extra_platforms.is_azure_pipelines()[source]ΒΆ
Return
Trueif current platform is Azure Pipelines.Environment variables reference.
- Return type:
- extra_platforms.is_bamboo()[source]ΒΆ
Return
Trueif current platform is Bamboo.Environment variables reference.
- Return type:
- extra_platforms.is_bsd()ΒΆ
Returns
Trueif at least one trait is part of the group composed of any BSD,Falseotherwise.- Return type:
- extra_platforms.is_bsd_without_macos()ΒΆ
Returns
Trueif at least one trait is part of the group composed of any BSD excluding macOS,Falseotherwise.- Return type:
- extra_platforms.is_buildkite()[source]ΒΆ
Return
Trueif current platform is Buildkite.Environment variables reference.
- Return type:
- extra_platforms.is_circle_ci()[source]ΒΆ
Return
Trueif current platform is Circle CI.Environment variables reference.
- Return type:
- extra_platforms.is_cirrus_ci()[source]ΒΆ
Return
Trueif current platform is Cirrus CI.Environment variables reference.
- Return type:
- extra_platforms.is_cloudlinux()[source]ΒΆ
Return
Trueif current platform is CloudLinux OS.- Return type:
- extra_platforms.is_codebuild()[source]ΒΆ
Return
Trueif current platform is CodeBuild.Environment variables reference.
- Return type:
- extra_platforms.is_exherbo()[source]ΒΆ
Return
Trueif current platform is Exherbo Linux.- Return type:
- extra_platforms.is_github_ci()[source]ΒΆ
Return
Trueif current platform is GitHub Actions runner.Environment variables reference.
- Return type:
- extra_platforms.is_gitlab_ci()[source]ΒΆ
Return
Trueif current platform is GitLab CI.Environment variables reference.
- Return type:
- extra_platforms.is_heroku_ci()[source]ΒΆ
Return
Trueif current platform is Heroku CI.Environment variables reference.
- Return type:
- extra_platforms.is_hurd()[source]ΒΆ
Return
Trueif current platform is GNU/Hurd.sys.platformcan returnsGNUorgnu0, see: https://github.com/kdeldycke/extra-platforms/issues/308- Return type:
- extra_platforms.is_i386()[source]ΒΆ
Return
Trueif current architecture is Intel 80386 (i386).- Return type:
- extra_platforms.is_i586()[source]ΒΆ
Return
Trueif current architecture is Intel Pentium (i586).- Return type:
- extra_platforms.is_i686()[source]ΒΆ
Return
Trueif current architecture is Intel Pentium Pro (i686).- Return type:
- extra_platforms.is_ibm_powerkvm()[source]ΒΆ
Return
Trueif current platform is IBM PowerKVM.- Return type:
- extra_platforms.is_kvmibm()[source]ΒΆ
Return
Trueif current platform is KVM for IBM z Systems.- Return type:
- extra_platforms.is_linux()ΒΆ
Returns
Trueif at least one trait is part of the group composed of any Linux distribution,Falseotherwise.- Return type:
- extra_platforms.is_linux_layers()ΒΆ
Returns
Trueif at least one trait is part of the group composed of any Linux compatibility layers,Falseotherwise.- Return type:
- extra_platforms.is_linux_like()ΒΆ
Returns
Trueif at least one trait is part of the group composed of any Linux and compatibility layers,Falseotherwise.- Return type:
- extra_platforms.is_linuxmint()[source]ΒΆ
Return
Trueif current platform is Linux Mint.- Return type:
- extra_platforms.is_loongarch64()[source]ΒΆ
Return
Trueif current architecture is LoongArch (64-bit).- Return type:
- extra_platforms.is_mandriva()[source]ΒΆ
Return
Trueif current platform is Mandriva Linux.- Return type:
- extra_platforms.is_midnightbsd()[source]ΒΆ
Return
Trueif current platform is MidnightBSD.- Return type:
- extra_platforms.is_mips()[source]ΒΆ
Return
Trueif current architecture is MIPS (32-bit, big-endian).- Return type:
- extra_platforms.is_mips64()[source]ΒΆ
Return
Trueif current architecture is MIPS64 (big-endian).- Return type:
- extra_platforms.is_mips64el()[source]ΒΆ
Return
Trueif current architecture is MIPS64 (little-endian).- Return type:
- extra_platforms.is_mipsel()[source]ΒΆ
Return
Trueif current architecture is MIPS (32-bit, little-endian).- Return type:
- extra_platforms.is_oracle()[source]ΒΆ
Return
Trueif current platform is Oracle Linux (and Oracle Enterprise Linux).- Return type:
- extra_platforms.is_other_unix()ΒΆ
Returns
Trueif at least one trait is part of the group composed of any other Unix,Falseotherwise.- Return type:
- extra_platforms.is_ppc()[source]ΒΆ
Return
Trueif current architecture is PowerPC (32-bit).- Return type:
- extra_platforms.is_ppc64()[source]ΒΆ
Return
Trueif current architecture is PowerPC 64-bit (big-endian).- Return type:
- extra_platforms.is_ppc64le()[source]ΒΆ
Return
Trueif current architecture is PowerPC 64-bit (little-endian).- Return type:
- extra_platforms.is_rhel()[source]ΒΆ
Return
Trueif current platform is RedHat Enterprise Linux.- Return type:
- extra_platforms.is_riscv32()[source]ΒΆ
Return
Trueif current architecture is RISC-V (32-bit).- Return type:
- extra_platforms.is_riscv64()[source]ΒΆ
Return
Trueif current architecture is RISC-V (64-bit).- Return type:
- extra_platforms.is_s390x()[source]ΒΆ
Return
Trueif current architecture is IBM z/Architecture (s390x).- Return type:
- extra_platforms.is_scientific()[source]ΒΆ
Return
Trueif current platform is Scientific Linux.- Return type:
- extra_platforms.is_sles()[source]ΒΆ
Return
Trueif current platform is SUSE Linux Enterprise Server.- Return type:
- extra_platforms.is_sparc()[source]ΒΆ
Return
Trueif current architecture is SPARC (32-bit).- Return type:
- extra_platforms.is_sparc64()[source]ΒΆ
Return
Trueif current architecture is SPARC (64-bit).- Return type:
- extra_platforms.is_system_v()ΒΆ
Returns
Trueif at least one trait is part of the group composed of aT&T System Five,Falseotherwise.- Return type:
- extra_platforms.is_teamcity()[source]ΒΆ
Return
Trueif current platform is TeamCity.Environment variables reference.
- Return type:
- extra_platforms.is_travis_ci()[source]ΒΆ
Return
Trueif current platform is Travis CI.Environment variables reference.
- Return type:
- extra_platforms.is_tumbleweed()[source]ΒΆ
Return
Trueif current platform is openSUSE Tumbleweed.- Return type:
- extra_platforms.is_ultramarine()[source]ΒΆ
Return
Trueif current platform is Ultramarine.- Return type:
- extra_platforms.is_unix()ΒΆ
Returns
Trueif at least one trait is part of the group composed of any Unix,Falseotherwise.- Return type:
- extra_platforms.is_unix_layers()ΒΆ
Returns
Trueif at least one trait is part of the group composed of any Unix compatibility layers,Falseotherwise.- Return type:
- extra_platforms.is_unix_without_macos()ΒΆ
Returns
Trueif at least one trait is part of the group composed of any Unix excluding macOS,Falseotherwise.- Return type:
- extra_platforms.is_unknown_architecture()[source]ΒΆ
Return
Trueif current architecture is unknown.- Return type:
- extra_platforms.is_unknown_ci()[source]ΒΆ
Return
Trueif current platform is an unknown CI.Some CI systems relies on generic environment variables to identify themselves:
CIBUILD_ID
- Return type:
- extra_platforms.is_unknown_linux()[source]ΒΆ
Return
Trueif current platform is an unknown Linux.- Return type:
- extra_platforms.is_wasm32()[source]ΒΆ
Return
Trueif current architecture is WebAssembly (32-bit).Note
WebAssembly detection is based on Emscriptenβs platform identifier.
- Return type:
- extra_platforms.is_wasm64()[source]ΒΆ
Return
Trueif current architecture is WebAssembly (64-bit).Note
WebAssembly 64-bit (memory64) is still experimental.
- Return type:
- extra_platforms.is_wsl1()[source]ΒΆ
Return
Trueif 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:
- extra_platforms.is_wsl2()[source]ΒΆ
Return
Trueif current platform is running over Windows Subsystem for Linux v2.- Return type:
- extra_platforms.is_x86_64()[source]ΒΆ
Return
Trueif current architecture is x86-64 (AMD64).Note
Windows returns
AMD64in uppercase, so we normalize to lowercase.- Return type:
- class extra_platforms.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.
- 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.
- extra_platforms.reduce(items, target_pool=None)[source]ΒΆ
Reduce a collection of traits to a minimal set.
Returns a deduplicated set of
GroupandTraitthat 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_poolare 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β¦
- class extra_platforms.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
- property current: boolΒΆ
Returns whether the current environment matches this trait.
This is a property to avoid calling all detection heuristics on
Traitobjects 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:
- 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.
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:
environment variables
- extra_platforms.detection.is_aarch64()[source]ΒΆ
Return
Trueif current architecture is ARM64 (AArch64).- Return type:
- extra_platforms.detection.is_arm()[source]ΒΆ
Return
Trueif current architecture is generic ARM (32-bit).This matches ARM architectures not covered by more specific variants.
- Return type:
- extra_platforms.detection.is_armv6l()[source]ΒΆ
Return
Trueif current architecture is ARMv6 (little-endian).- Return type:
- extra_platforms.detection.is_armv7l()[source]ΒΆ
Return
Trueif current architecture is ARMv7 (little-endian).- Return type:
- extra_platforms.detection.is_armv8l()[source]ΒΆ
Return
Trueif current architecture is ARMv8 (32-bit, little-endian).- Return type:
- extra_platforms.detection.is_i386()[source]ΒΆ
Return
Trueif current architecture is Intel 80386 (i386).- Return type:
- extra_platforms.detection.is_i586()[source]ΒΆ
Return
Trueif current architecture is Intel Pentium (i586).- Return type:
- extra_platforms.detection.is_i686()[source]ΒΆ
Return
Trueif current architecture is Intel Pentium Pro (i686).- Return type:
- extra_platforms.detection.is_x86_64()[source]ΒΆ
Return
Trueif current architecture is x86-64 (AMD64).Note
Windows returns
AMD64in uppercase, so we normalize to lowercase.- Return type:
- extra_platforms.detection.is_mips()[source]ΒΆ
Return
Trueif current architecture is MIPS (32-bit, big-endian).- Return type:
- extra_platforms.detection.is_mipsel()[source]ΒΆ
Return
Trueif current architecture is MIPS (32-bit, little-endian).- Return type:
- extra_platforms.detection.is_mips64()[source]ΒΆ
Return
Trueif current architecture is MIPS64 (big-endian).- Return type:
- extra_platforms.detection.is_mips64el()[source]ΒΆ
Return
Trueif current architecture is MIPS64 (little-endian).- Return type:
- extra_platforms.detection.is_ppc()[source]ΒΆ
Return
Trueif current architecture is PowerPC (32-bit).- Return type:
- extra_platforms.detection.is_ppc64()[source]ΒΆ
Return
Trueif current architecture is PowerPC 64-bit (big-endian).- Return type:
- extra_platforms.detection.is_ppc64le()[source]ΒΆ
Return
Trueif current architecture is PowerPC 64-bit (little-endian).- Return type:
- extra_platforms.detection.is_riscv32()[source]ΒΆ
Return
Trueif current architecture is RISC-V (32-bit).- Return type:
- extra_platforms.detection.is_riscv64()[source]ΒΆ
Return
Trueif current architecture is RISC-V (64-bit).- Return type:
- extra_platforms.detection.is_sparc()[source]ΒΆ
Return
Trueif current architecture is SPARC (32-bit).- Return type:
- extra_platforms.detection.is_sparc64()[source]ΒΆ
Return
Trueif current architecture is SPARC (64-bit).- Return type:
- extra_platforms.detection.is_s390x()[source]ΒΆ
Return
Trueif current architecture is IBM z/Architecture (s390x).- Return type:
- extra_platforms.detection.is_loongarch64()[source]ΒΆ
Return
Trueif current architecture is LoongArch (64-bit).- Return type:
- extra_platforms.detection.is_wasm32()[source]ΒΆ
Return
Trueif current architecture is WebAssembly (32-bit).Note
WebAssembly detection is based on Emscriptenβs platform identifier.
- Return type:
- extra_platforms.detection.is_wasm64()[source]ΒΆ
Return
Trueif current architecture is WebAssembly (64-bit).Note
WebAssembly 64-bit (memory64) is still experimental.
- Return type:
- extra_platforms.detection.is_unknown_architecture()[source]ΒΆ
Return
Trueif current architecture is unknown.- Return type:
- extra_platforms.detection.is_altlinux()[source]ΒΆ
Return
Trueif current platform is ALT Linux.- Return type:
- extra_platforms.detection.is_amzn()[source]ΒΆ
Return
Trueif current platform is Amazon Linux.- Return type:
- extra_platforms.detection.is_android()[source]ΒΆ
Return
Trueif current platform is Android.Source: https://github.com/kivy/kivy/blob/master/kivy/utils.py#L429
- Return type:
- extra_platforms.detection.is_arch()[source]ΒΆ
Return
Trueif current platform is Arch Linux.- Return type:
- extra_platforms.detection.is_buildroot()[source]ΒΆ
Return
Trueif current platform is Buildroot.- Return type:
- extra_platforms.detection.is_cachyos()[source]ΒΆ
Return
Trueif current platform is CachyOS.- Return type:
- extra_platforms.detection.is_centos()[source]ΒΆ
Return
Trueif current platform is CentOS.- Return type:
- extra_platforms.detection.is_cloudlinux()[source]ΒΆ
Return
Trueif current platform is CloudLinux OS.- Return type:
- extra_platforms.detection.is_cygwin()[source]ΒΆ
Return
Trueif current platform is Cygwin.- Return type:
- extra_platforms.detection.is_debian()[source]ΒΆ
Return
Trueif current platform is Debian.- Return type:
- extra_platforms.detection.is_exherbo()[source]ΒΆ
Return
Trueif current platform is Exherbo Linux.- Return type:
- extra_platforms.detection.is_fedora()[source]ΒΆ
Return
Trueif current platform is Fedora.- Return type:
- extra_platforms.detection.is_freebsd()[source]ΒΆ
Return
Trueif current platform is FreeBSD.- Return type:
- extra_platforms.detection.is_gentoo()[source]ΒΆ
Return
Trueif current platform is GenToo Linux.- Return type:
- extra_platforms.detection.is_guix()[source]ΒΆ
Return
Trueif current platform is Guix System.- Return type:
- extra_platforms.detection.is_hurd()[source]ΒΆ
Return
Trueif current platform is GNU/Hurd.sys.platformcan returnsGNUorgnu0, see: https://github.com/kdeldycke/extra-platforms/issues/308- Return type:
- extra_platforms.detection.is_ibm_powerkvm()[source]ΒΆ
Return
Trueif current platform is IBM PowerKVM.- Return type:
- extra_platforms.detection.is_kvmibm()[source]ΒΆ
Return
Trueif current platform is KVM for IBM z Systems.- Return type:
- extra_platforms.detection.is_linuxmint()[source]ΒΆ
Return
Trueif current platform is Linux Mint.- Return type:
- extra_platforms.detection.is_macos()[source]ΒΆ
Return
Trueif current platform is macOS.- Return type:
- extra_platforms.detection.is_mageia()[source]ΒΆ
Return
Trueif current platform is Mageia.- Return type:
- extra_platforms.detection.is_mandriva()[source]ΒΆ
Return
Trueif current platform is Mandriva Linux.- Return type:
- extra_platforms.detection.is_midnightbsd()[source]ΒΆ
Return
Trueif current platform is MidnightBSD.- Return type:
- extra_platforms.detection.is_netbsd()[source]ΒΆ
Return
Trueif current platform is NetBSD.- Return type:
- extra_platforms.detection.is_nobara()[source]ΒΆ
Return
Trueif current platform is Nobara Linux.- Return type:
- extra_platforms.detection.is_openbsd()[source]ΒΆ
Return
Trueif current platform is OpenBSD.- Return type:
- extra_platforms.detection.is_opensuse()[source]ΒΆ
Return
Trueif current platform is openSUSE.- Return type:
- extra_platforms.detection.is_oracle()[source]ΒΆ
Return
Trueif current platform is Oracle Linux (and Oracle Enterprise Linux).- Return type:
- extra_platforms.detection.is_parallels()[source]ΒΆ
Return
Trueif current platform is Parallels.- Return type:
- extra_platforms.detection.is_pidora()[source]ΒΆ
Return
Trueif current platform is Pidora.- Return type:
- extra_platforms.detection.is_raspbian()[source]ΒΆ
Return
Trueif current platform is Raspbian.- Return type:
- extra_platforms.detection.is_rhel()[source]ΒΆ
Return
Trueif current platform is RedHat Enterprise Linux.- Return type:
- extra_platforms.detection.is_rocky()[source]ΒΆ
Return
Trueif current platform is Rocky Linux.- Return type:
- extra_platforms.detection.is_scientific()[source]ΒΆ
Return
Trueif current platform is Scientific Linux.- Return type:
- extra_platforms.detection.is_slackware()[source]ΒΆ
Return
Trueif current platform is Slackware.- Return type:
- extra_platforms.detection.is_sles()[source]ΒΆ
Return
Trueif current platform is SUSE Linux Enterprise Server.- Return type:
- extra_platforms.detection.is_solaris()[source]ΒΆ
Return
Trueif current platform is Solaris.- Return type:
- extra_platforms.detection.is_sunos()[source]ΒΆ
Return
Trueif current platform is SunOS.- Return type:
- extra_platforms.detection.is_tumbleweed()[source]ΒΆ
Return
Trueif current platform is openSUSE Tumbleweed.- Return type:
- extra_platforms.detection.is_tuxedo()[source]ΒΆ
Return
Trueif current platform is Tuxedo OS.- Return type:
- extra_platforms.detection.is_ubuntu()[source]ΒΆ
Return
Trueif current platform is Ubuntu.- Return type:
- extra_platforms.detection.is_ultramarine()[source]ΒΆ
Return
Trueif current platform is Ultramarine.- Return type:
- extra_platforms.detection.is_unknown_linux()[source]ΒΆ
Return
Trueif current platform is an unknown Linux.- Return type:
- extra_platforms.detection.is_windows()[source]ΒΆ
Return
Trueif current platform is Windows.- Return type:
- extra_platforms.detection.is_wsl1()[source]ΒΆ
Return
Trueif 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:
- extra_platforms.detection.is_wsl2()[source]ΒΆ
Return
Trueif current platform is running over Windows Subsystem for Linux v2.- Return type:
- extra_platforms.detection.is_xenserver()[source]ΒΆ
Return
Trueif current platform is XenServer.- Return type:
- extra_platforms.detection.is_azure_pipelines()[source]ΒΆ
Return
Trueif current platform is Azure Pipelines.Environment variables reference.
- Return type:
- extra_platforms.detection.is_bamboo()[source]ΒΆ
Return
Trueif current platform is Bamboo.Environment variables reference.
- Return type:
- extra_platforms.detection.is_buildkite()[source]ΒΆ
Return
Trueif current platform is Buildkite.Environment variables reference.
- Return type:
- extra_platforms.detection.is_circle_ci()[source]ΒΆ
Return
Trueif current platform is Circle CI.Environment variables reference.
- Return type:
- extra_platforms.detection.is_cirrus_ci()[source]ΒΆ
Return
Trueif current platform is Cirrus CI.Environment variables reference.
- Return type:
- extra_platforms.detection.is_codebuild()[source]ΒΆ
Return
Trueif current platform is CodeBuild.Environment variables reference.
- Return type:
- extra_platforms.detection.is_github_ci()[source]ΒΆ
Return
Trueif current platform is GitHub Actions runner.Environment variables reference.
- Return type:
- extra_platforms.detection.is_gitlab_ci()[source]ΒΆ
Return
Trueif current platform is GitLab CI.Environment variables reference.
- Return type:
- extra_platforms.detection.is_heroku_ci()[source]ΒΆ
Return
Trueif current platform is Heroku CI.Environment variables reference.
- Return type:
- extra_platforms.detection.is_teamcity()[source]ΒΆ
Return
Trueif current platform is TeamCity.Environment variables reference.
- Return type:
- extra_platforms.detection.is_travis_ci()[source]ΒΆ
Return
Trueif current platform is Travis CI.Environment variables reference.
- Return type:
- extra_platforms.detection.is_unknown_ci()[source]ΒΆ
Return
Trueif current platform is an unknown CI.Some CI systems relies on generic environment variables to identify themselves:
CIBUILD_ID
- Return type:
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:
objectA
Groupidentifies a collection ofTraitmembers.Supports set-like operations (union, intersection, difference, etc.).
-
members:
Iterable[Trait]ΒΆ Traits in this group.
Normalized to
MappingProxyType[str, Trait]at init, providing O(1) lookup by ID.
- 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.
- 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.
othercan be an arbitrarily nestedIterableofGroupandTrait.- Return type:
- fullyintersects(other)[source]ΒΆ
Return True if the group has all members in common with
other.- Return type:
- union(*others)[source]ΒΆ
Return a new
Groupwith members from the group and all others.Caution
The new
Groupwill inherits the metadata of the first one. All other groupsβ metadata will be ignored.- Return type:
- intersection(*others)[source]ΒΆ
Return a new
Groupwith members common to the group and all others.Caution
The new
Groupwill inherits the metadata of the first one. All other groupsβ metadata will be ignored.- Return type:
- difference(*others)[source]ΒΆ
Return a new
Groupwith members in the group that are not in the others.Caution
The new
Groupwill inherits the metadata of the first one. All other groupsβ metadata will be ignored.- Return type:
- symmetric_difference(other)[source]ΒΆ
Return a new
Groupwith members in either the group or other but not both.Caution
The new
Groupwill inherits the metadata of the first one. All other groupsβ metadata will be ignored.- Return type:
- 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:
- add(member)[source]ΒΆ
Return a new
Groupwith the specified trait added.If the trait is already in the group, returns a copy unchanged.
- Return type:
- Args:
member: A
Traitobject or trait ID string to add.- Returns:
A new
Groupinstance with the trait added.- Raises:
ValueError: If the trait ID is not recognized.
- remove(member)[source]ΒΆ
Return a new
Groupwith the specified trait removed.Raises
KeyErrorif the trait is not in the group.- Return type:
- Args:
member: A
Traitobject or trait ID string to remove.- Returns:
A new
Groupinstance with the trait removed.- Raises:
KeyError: If the trait is not in the group.
- discard(member)[source]ΒΆ
Return a new
Groupwith the specified trait removed if present.Unlike
remove(), this does not raise an error if the trait is not found.- Return type:
- Args:
member: A
Traitobject or trait ID string to remove.- Returns:
A new
Groupinstance with the trait removed, or a copy if not present.
- pop(member_id=None)[source]ΒΆ
Remove and return a trait from the 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_idis provided but not found in the group. KeyError: If the group is empty.
-
members:
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.
Note
- 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.
- 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.
- 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.
- 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.
- extra_platforms.operations.reduce(items, target_pool=None)[source]ΒΆ
Reduce a collection of traits to a minimal set.
Returns a deduplicated set of
GroupandTraitthat 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_poolare 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β¦
extra_platforms.platform moduleΒΆ
Platforms, also known as Operating Systems.
- class extra_platforms.platform.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.
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:
objectDefer 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
@skipand@unlessdecorators.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: