Groups¶
Group usage¶
A Group is a collection of Trait instances (platforms, architectures, or CI systems). Groups support membership testing, iteration, and set-like operations.
Membership testing¶
Check whether the current environment matches any member of a group:
>>> from extra_platforms import is_linux
>>> is_linux()
True
Test if a specific trait belongs to a group. You can you both Trait instances and their string IDs:
>>> from extra_platforms import LINUX, UBUNTU, MACOS
>>> UBUNTU in LINUX
True
>>> MACOS in LINUX
False
>>> "ubuntu" in LINUX
True
Iteration¶
Groups are iterable and sized:
>>> from extra_platforms import BSD
>>> len(BSD)
7
>>> for platform in BSD:
... print(platform.id)
dragonfly_bsd
freebsd
macos
midnightbsd
netbsd
openbsd
sunos
Set operations¶
Groups support standard set operations, returning new Group instances:
>>> from extra_platforms import BSD, BSD_WITHOUT_MACOS, LINUX, MACOS
>>> only_macos = BSD.difference(BSD_WITHOUT_MACOS)
>>> only_macos.member_ids
frozenset({'macos'})
>>> combined = BSD.union(LINUX)
>>> MACOS in combined
True
Set operations also have operator overloads for more concise syntax:
>>> from extra_platforms import BSD, BSD_WITHOUT_MACOS, LINUX, MACOS
>>> only_macos = BSD - BSD_WITHOUT_MACOS
>>> only_macos.member_ids
frozenset({'macos'})
>>> combined = BSD | LINUX
>>> MACOS in combined
True
Available operations: union() (|), intersection() (&), difference() (-), symmetric_difference() (^), issubset(), issuperset(), and isdisjoint().
Mutating-style operations¶
Groups are immutable (frozen dataclasses), but provide methods that return new instances:
>>> from extra_platforms import BSD, AIX
>>> extended = BSD.add(AIX)
>>> AIX in extended
True
>>> AIX in BSD
False
>>> shrunk = BSD.remove("macos")
>>> "macos" in shrunk
False
Creating custom groups¶
Build new groups from scratch or by combining existing ones:
>>> from extra_platforms import Group, UBUNTU, DEBIAN, MACOS
>>> my_targets = Group("my_targets", "My Targets", "🎯", (UBUNTU, DEBIAN, MACOS))
>>> len(my_targets)
3
Hint
You can check my other Meta Package Manager project for a real life example, where I use Group to manage families of target platforms for software packaging.
Reducing traits to groups¶
The reduce() function finds the minimal set of groups and traits that covers a given collection:
>>> from extra_platforms import reduce, FREEBSD, NETBSD, OPENBSD, MACOS
>>> reduce([FREEBSD, NETBSD, OPENBSD, MACOS])
frozenset({BSD})
All groups¶
All recognized groups and their properties:
Icon |
Symbol |
Description |
||
|---|---|---|---|---|
🏛️ |
All architectures |
|||
📱 |
ARM architectures |
⬥ |
||
♺ |
CI systems |
⬥ |
||
🔲 |
MIPS architectures |
⬥ |
||
⚙️ |
All platforms |
|||
☀️ |
SPARC architectures |
⬥ |
||
⁕ |
All architectures, platforms and CI systems |
|||
🪟 |
All Windows |
⬥ |
||
³² |
32-bit architectures |
|||
⁶⁴ |
64-bit architectures |
|||
⬆️ |
Big-endian architectures |
|||
🅱️+ |
All BSD |
⬥ |
||
🅱️ |
All BSD excluding macOS |
|||
🏢 |
IBM mainframe |
⬥ |
||
🐧 |
Linux distributions |
⬥ |
||
≚ |
Linux compatibility layers |
⬥ |
||
🐧+ |
All Linux & compatibility layers |
|||
⬇️ |
Little-endian architectures |
|||
🐉 |
LoongArch |
⬥ |
||
🅟 |
Other POSIX-compliant platforms |
⬥ |
||
⚡ |
PowerPC family |
⬥ |
||
Ⅴ |
RISC-V family |
⬥ |
||
𝐕 |
AT&T System Five |
⬥ |
||
⨷ |
All Unix |
|||
≛ |
Unix compatibility layers |
⬥ |
||
⨂ |
All Unix excluding macOS |
|||
❓ |
Unknown |
⬥ |
||
🌐 |
WebAssembly |
⬥ |
||
𝘅 |
x86 family |
⬥ |
Hint
Canonical groups are non-overlapping groups that together cover all recognized traits. They are marked with a ⬥ icon in the table above.
Other groups are provided for convenience, but overlap with each other or with canonical groups.
Predefined groups¶
- extra_platforms.ALL_ARCHITECTURES = Group(id='all_architectures', name='All architectures')¶
All recognized architectures.
Caution
This group does not contain the
UNKNOWN_ARCHITECTUREtrait.ID:
all_architecturesName: All architectures
Icon: 🏛️
Canonical:
FalseDetection function:
is_any_architecture()Pytest decorators:
@skip_all_architectures/@unless_any_architectureMembers (25
Architecture):AARCH64,ARM,ARMV5TEL,ARMV6L,ARMV7L,ARMV8L,I386,I586,I686,LOONGARCH64,MIPS,MIPS64,MIPS64EL,MIPSEL,PPC,PPC64,PPC64LE,RISCV32,RISCV64,S390X,SPARC,SPARC64,WASM32,WASM64,X86_64
- extra_platforms.ALL_ARM = Group(id='all_arm', name='ARM architectures')¶
All ARM-based architectures.
ID:
all_armName: ARM architectures
Icon: 📱
Canonical:
True⬥Detection function:
is_any_arm()Pytest decorators:
@skip_all_arm/@unless_any_armMembers (6
Architecture):AARCH64,ARM,ARMV5TEL,ARMV6L,ARMV7L,ARMV8L
- extra_platforms.ALL_CI = Group(id='all_ci', name='CI systems')¶
All recognized Continuous Integration systems.
Caution
This group does not contain the
UNKNOWN_CItrait.See also
ID:
all_ciName: CI systems
Icon: ♺
Canonical:
True⬥Detection function:
is_any_ci()Pytest decorators:
@skip_all_ci/@unless_any_ciMembers (11
CI):AZURE_PIPELINES,BAMBOO,BUILDKITE,CIRCLE_CI,CIRRUS_CI,CODEBUILD,GITHUB_CI,GITLAB_CI,HEROKU_CI,TEAMCITY,TRAVIS_CI
- extra_platforms.ALL_MIPS = Group(id='all_mips', name='MIPS architectures')¶
All MIPS-based architectures.
ID:
all_mipsName: MIPS architectures
Icon: 🔲
Canonical:
True⬥Detection function:
is_any_mips()Pytest decorators:
@skip_all_mips/@unless_any_mipsMembers (4
Architecture):MIPS,MIPS64,MIPS64EL,MIPSEL
- extra_platforms.ALL_PLATFORMS = Group(id='all_platforms', name='All platforms')¶
All recognized platforms.
Caution
This group does not contain the
UNKNOWN_PLATFORMtrait.ID:
all_platformsName: All platforms
Icon: ⚙️
Canonical:
FalseDetection function:
is_any_platform()Pytest decorators:
@skip_all_platforms/@unless_any_platformMembers (50
Platform):AIX,ALTLINUX,AMZN,ANDROID,ARCH,BUILDROOT,CACHYOS,CENTOS,CLOUDLINUX,CYGWIN,DEBIAN,DRAGONFLY_BSD,EXHERBO,FEDORA,FREEBSD,GENTOO,GUIX,HAIKU,HURD,IBM_POWERKVM,ILLUMOS,KVMIBM,LINUXMINT,MACOS,MAGEIA,MANDRIVA,MIDNIGHTBSD,NETBSD,NOBARA,OPENBSD,OPENSUSE,ORACLE,PARALLELS,PIDORA,RASPBIAN,RHEL,ROCKY,SCIENTIFIC,SLACKWARE,SLES,SOLARIS,SUNOS,TUMBLEWEED,TUXEDO,UBUNTU,ULTRAMARINE,WINDOWS,WSL1,WSL2,XENSERVER
- extra_platforms.ALL_SPARC = Group(id='all_sparc', name='SPARC architectures')¶
All SPARC-based architectures.
ID:
all_sparcName: SPARC architectures
Icon: ☀️
Canonical:
True⬥Detection function:
is_any_sparc()Pytest decorators:
@skip_all_sparc/@unless_any_sparcMembers (2
Architecture):SPARC,SPARC64
- extra_platforms.ALL_TRAITS = Group(id='all_traits', name='All architectures, platforms and CI systems')¶
All predefined architectures, platforms and CI systems.
Hint
This group includes all
UNKNOWN_*traits.ID:
all_traitsName: All architectures, platforms and CI systems
Icon: ⁕
Canonical:
FalseDetection function:
is_any_trait()Pytest decorators:
@skip_all_traits/@unless_any_traitMembers (26
Architecture, 12CI, 51Platform):AARCH64,AIX,ALTLINUX,AMZN,ANDROID,ARCH,ARM,ARMV5TEL,ARMV6L,ARMV7L,ARMV8L,AZURE_PIPELINES,BAMBOO,BUILDKITE,BUILDROOT,CACHYOS,CENTOS,CIRCLE_CI,CIRRUS_CI,CLOUDLINUX,CODEBUILD,CYGWIN,DEBIAN,DRAGONFLY_BSD,EXHERBO,FEDORA,FREEBSD,GENTOO,GITHUB_CI,GITLAB_CI,GUIX,HAIKU,HEROKU_CI,HURD,I386,I586,I686,IBM_POWERKVM,ILLUMOS,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_PLATFORM,WASM32,WASM64,WINDOWS,WSL1,WSL2,X86_64,XENSERVER
- extra_platforms.ALL_WINDOWS = Group(id='all_windows', name='All Windows')¶
All Windows operating systems.
ID:
all_windowsName: All Windows
Icon: 🪟
Canonical:
True⬥Detection function:
is_any_windows()Pytest decorators:
@skip_all_windows/@unless_any_windows
- extra_platforms.ARCH_32_BIT = Group(id='arch_32_bit', name='32-bit architectures')¶
All 32-bit architectures.
ID:
arch_32_bitName: 32-bit architectures
Icon: ³²
Canonical:
FalseDetection function:
is_arch_32_bit()Pytest decorators:
@skip_arch_32_bit/@unless_arch_32_bitMembers (14
Architecture):ARM,ARMV5TEL,ARMV6L,ARMV7L,ARMV8L,I386,I586,I686,MIPS,MIPSEL,PPC,RISCV32,SPARC,WASM32
- extra_platforms.ARCH_64_BIT = Group(id='arch_64_bit', name='64-bit architectures')¶
All 64-bit architectures.
ID:
arch_64_bitName: 64-bit architectures
Icon: ⁶⁴
Canonical:
FalseDetection function:
is_arch_64_bit()Pytest decorators:
@skip_arch_64_bit/@unless_arch_64_bitMembers (11
Architecture):AARCH64,LOONGARCH64,MIPS64,MIPS64EL,PPC64,PPC64LE,RISCV64,S390X,SPARC64,WASM64,X86_64
- extra_platforms.BIG_ENDIAN = Group(id='big_endian', name='Big-endian architectures')¶
All big-endian architectures.
ID:
big_endianName: Big-endian architectures
Icon: ⬆️
Canonical:
FalseDetection function:
is_big_endian()Pytest decorators:
@skip_big_endian/@unless_big_endianMembers (7
Architecture):MIPS,MIPS64,PPC,PPC64,S390X,SPARC,SPARC64
- extra_platforms.BSD = Group(id='bsd', name='All 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
ID:
bsdName: All BSD
Icon: 🅱️+
Canonical:
True⬥Detection function:
is_bsd()Pytest decorators:
@skip_bsd/@unless_bsdMembers (7
Platform):DRAGONFLY_BSD,FREEBSD,MACOS,MIDNIGHTBSD,NETBSD,OPENBSD,SUNOS
- extra_platforms.BSD_WITHOUT_MACOS = Group(id='bsd_without_macos', name='All BSD excluding macOS')¶
All BSD platforms, without macOS.
This is useful to avoid macOS-specific workarounds on BSD platforms.
ID:
bsd_without_macosName: All BSD excluding macOS
Icon: 🅱️
Canonical:
FalseDetection function:
is_bsd_not_macos()Pytest decorators:
@skip_bsd_not_macos/@unless_bsd_not_macosMembers (6
Platform):DRAGONFLY_BSD,FREEBSD,MIDNIGHTBSD,NETBSD,OPENBSD,SUNOS
- extra_platforms.IBM_MAINFRAME = Group(id='ibm_mainframe', name='IBM mainframe')¶
IBM mainframe architectures.
ID:
ibm_mainframeName: IBM mainframe
Icon: 🏢
Canonical:
True⬥Detection function:
is_ibm_mainframe()Pytest decorators:
@skip_ibm_mainframe/@unless_ibm_mainframeMembers (1
Architecture):S390X
- extra_platforms.LINUX = Group(id='linux', name='Linux distributions')¶
All distributions based on a Linux kernel.
ID:
linuxName: Linux distributions
Icon: 🐧
Canonical:
True⬥Detection function:
is_linux()Pytest decorators:
@skip_linux/@unless_linuxMembers (34
Platform):ALTLINUX,AMZN,ANDROID,ARCH,BUILDROOT,CACHYOS,CENTOS,CLOUDLINUX,DEBIAN,EXHERBO,FEDORA,GENTOO,GUIX,IBM_POWERKVM,KVMIBM,LINUXMINT,MAGEIA,MANDRIVA,NOBARA,OPENSUSE,ORACLE,PARALLELS,PIDORA,RASPBIAN,RHEL,ROCKY,SCIENTIFIC,SLACKWARE,SLES,TUMBLEWEED,TUXEDO,UBUNTU,ULTRAMARINE,XENSERVER
- extra_platforms.LINUX_LAYERS = Group(id='linux_layers', name='Linux compatibility layers')¶
Interfaces that allows Linux binaries to run on a different host system.
ID:
linux_layersName: Linux compatibility layers
Icon: ≚
Canonical:
True⬥Detection function:
is_linux_layers()Pytest decorators:
@skip_linux_layers/@unless_linux_layers
- extra_platforms.LINUX_LIKE = Group(id='linux_like', name='All Linux & compatibility layers')¶
Sum of all Linux distributions and Linux compatibility layers.
ID:
linux_likeName: All Linux & compatibility layers
Icon: 🐧+
Canonical:
FalseDetection function:
is_linux_like()Pytest decorators:
@skip_linux_like/@unless_linux_likeMembers (36
Platform):ALTLINUX,AMZN,ANDROID,ARCH,BUILDROOT,CACHYOS,CENTOS,CLOUDLINUX,DEBIAN,EXHERBO,FEDORA,GENTOO,GUIX,IBM_POWERKVM,KVMIBM,LINUXMINT,MAGEIA,MANDRIVA,NOBARA,OPENSUSE,ORACLE,PARALLELS,PIDORA,RASPBIAN,RHEL,ROCKY,SCIENTIFIC,SLACKWARE,SLES,TUMBLEWEED,TUXEDO,UBUNTU,ULTRAMARINE,WSL1,WSL2,XENSERVER
- extra_platforms.LITTLE_ENDIAN = Group(id='little_endian', name='Little-endian architectures')¶
All little-endian architectures.
ID:
little_endianName: Little-endian architectures
Icon: ⬇️
Canonical:
FalseDetection function:
is_little_endian()Pytest decorators:
@skip_little_endian/@unless_little_endianMembers (18
Architecture):AARCH64,ARM,ARMV5TEL,ARMV6L,ARMV7L,ARMV8L,I386,I586,I686,LOONGARCH64,MIPS64EL,MIPSEL,PPC64LE,RISCV32,RISCV64,WASM32,WASM64,X86_64
- extra_platforms.LOONGARCH = Group(id='loongarch', name='LoongArch')¶
LoongArch architecture.
ID:
loongarchName: LoongArch
Icon: 🐉
Canonical:
True⬥Detection function:
is_loongarch()Pytest decorators:
@skip_loongarch/@unless_loongarchMembers (1
Architecture):LOONGARCH64
- extra_platforms.OTHER_POSIX = Group(id='other_posix', name='Other POSIX-compliant platforms')¶
All other UNIX-like or POSIX-compliant 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
ID:
other_posixName: Other POSIX-compliant platforms
Icon: 🅟
Canonical:
True⬥Detection function:
is_other_posix()Pytest decorators:
@skip_other_posix/@unless_other_posix
- extra_platforms.POWERPC = Group(id='powerpc', name='PowerPC family')¶
All PowerPC-based architectures.
ID:
powerpcName: PowerPC family
Icon: ⚡
Canonical:
True⬥Detection function:
is_powerpc()Pytest decorators:
@skip_powerpc/@unless_powerpcMembers (3
Architecture):PPC,PPC64,PPC64LE
- extra_platforms.RISCV = Group(id='riscv', name='RISC-V family')¶
All RISC-V-based architectures.
ID:
riscvName: RISC-V family
Icon: Ⅴ
Canonical:
True⬥Detection function:
is_riscv()Pytest decorators:
@skip_riscv/@unless_riscvMembers (2
Architecture):RISCV32,RISCV64
- extra_platforms.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
ID:
system_vName: AT&T System Five
Icon: 𝐕
Canonical:
True⬥Detection function:
is_system_v()Pytest decorators:
@skip_system_v/@unless_system_v
- extra_platforms.UNIX = Group(id='unix', name='All Unix')¶
All Unix-like operating systems and compatibility layers.
ID:
unixName: All Unix
Icon: ⨷
Canonical:
FalseDetection function:
is_unix()Pytest decorators:
@skip_unix/@unless_unixMembers (49
Platform):AIX,ALTLINUX,AMZN,ANDROID,ARCH,BUILDROOT,CACHYOS,CENTOS,CLOUDLINUX,CYGWIN,DEBIAN,DRAGONFLY_BSD,EXHERBO,FEDORA,FREEBSD,GENTOO,GUIX,HAIKU,HURD,IBM_POWERKVM,ILLUMOS,KVMIBM,LINUXMINT,MACOS,MAGEIA,MANDRIVA,MIDNIGHTBSD,NETBSD,NOBARA,OPENBSD,OPENSUSE,ORACLE,PARALLELS,PIDORA,RASPBIAN,RHEL,ROCKY,SCIENTIFIC,SLACKWARE,SLES,SOLARIS,SUNOS,TUMBLEWEED,TUXEDO,UBUNTU,ULTRAMARINE,WSL1,WSL2,XENSERVER
- extra_platforms.UNIX_LAYERS = Group(id='unix_layers', name='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
ID:
unix_layersName: Unix compatibility layers
Icon: ≛
Canonical:
True⬥Detection function:
is_unix_layers()Pytest decorators:
@skip_unix_layers/@unless_unix_layers
- extra_platforms.UNIX_WITHOUT_MACOS = Group(id='unix_without_macos', name='All Unix excluding macOS')¶
All Unix platforms, without macOS.
This is useful to avoid macOS-specific workarounds on Unix platforms.
ID:
unix_without_macosName: All Unix excluding macOS
Icon: ⨂
Canonical:
FalseDetection function:
is_unix_not_macos()Pytest decorators:
@skip_unix_not_macos/@unless_unix_not_macosMembers (48
Platform):AIX,ALTLINUX,AMZN,ANDROID,ARCH,BUILDROOT,CACHYOS,CENTOS,CLOUDLINUX,CYGWIN,DEBIAN,DRAGONFLY_BSD,EXHERBO,FEDORA,FREEBSD,GENTOO,GUIX,HAIKU,HURD,IBM_POWERKVM,ILLUMOS,KVMIBM,LINUXMINT,MAGEIA,MANDRIVA,MIDNIGHTBSD,NETBSD,NOBARA,OPENBSD,OPENSUSE,ORACLE,PARALLELS,PIDORA,RASPBIAN,RHEL,ROCKY,SCIENTIFIC,SLACKWARE,SLES,SOLARIS,SUNOS,TUMBLEWEED,TUXEDO,UBUNTU,ULTRAMARINE,WSL1,WSL2,XENSERVER
- extra_platforms.UNKNOWN = Group(id='unknown', name='Unknown')¶
Unknown or unrecognized traits.
ID:
unknownName: Unknown
Icon: ❓
Canonical:
True⬥Detection function:
is_unknown()Pytest decorators:
@skip_unknown/@unless_unknownMembers (1
Architecture, 1CI, 1Platform):UNKNOWN_ARCHITECTURE,UNKNOWN_CI,UNKNOWN_PLATFORM
- extra_platforms.WEBASSEMBLY = Group(id='webassembly', name='WebAssembly')¶
WebAssembly architectures.
ID:
webassemblyName: WebAssembly
Icon: 🌐
Canonical:
True⬥Detection function:
is_webassembly()Pytest decorators:
@skip_webassembly/@unless_webassemblyMembers (2
Architecture):WASM32,WASM64
- extra_platforms.X86 = Group(id='x86', name='x86 family')¶
All x86-based architectures (Intel-compatible).
ID:
x86Name: x86 family
Icon: 𝘅
Canonical:
True⬥Detection function:
is_x86()Pytest decorators:
@skip_x86/@unless_x86Members (4
Architecture):I386,I586,I686,X86_64
Group collections¶
- extra_platforms.group_data.ALL_ARCHITECTURE_GROUPS: frozenset[Group] = frozenset({Group(id='big_endian', name='Big-endian architectures'), Group(id='arch_32_bit', name='32-bit architectures'), Group(id='ibm_mainframe', name='IBM mainframe'), Group(id='webassembly', name='WebAssembly'), Group(id='arch_64_bit', name='64-bit architectures'), Group(id='x86', name='x86 family'), Group(id='all_arm', name='ARM architectures'), Group(id='all_sparc', name='SPARC architectures'), Group(id='powerpc', name='PowerPC family'), Group(id='riscv', name='RISC-V family'), Group(id='loongarch', name='LoongArch'), Group(id='all_mips', name='MIPS architectures'), Group(id='little_endian', name='Little-endian architectures'), Group(id='all_architectures', name='All architectures')})¶
All groups whose members are
Architecture.
- extra_platforms.group_data.ALL_CI_GROUPS: frozenset[Group] = frozenset({Group(id='all_ci', name='CI systems')})¶
All groups whose members are
CI.Note
Not that useful as there is only one CI group, but provided for symmetry with
ALL_ARCHITECTURE_GROUPSandALL_PLATFORM_GROUPS.
- extra_platforms.group_data.ALL_GROUPS: frozenset[Group] = frozenset({Group(id='arch_32_bit', name='32-bit architectures'), Group(id='other_posix', name='Other POSIX-compliant platforms'), Group(id='ibm_mainframe', name='IBM mainframe'), Group(id='arch_64_bit', name='64-bit architectures'), Group(id='unix', name='All Unix'), Group(id='x86', name='x86 family'), Group(id='unix_without_macos', name='All Unix excluding macOS'), Group(id='unknown', name='Unknown'), Group(id='all_windows', name='All Windows'), Group(id='linux', name='Linux distributions'), Group(id='all_platforms', name='All platforms'), Group(id='all_mips', name='MIPS architectures'), Group(id='big_endian', name='Big-endian architectures'), Group(id='webassembly', name='WebAssembly'), Group(id='all_arm', name='ARM architectures'), Group(id='all_sparc', name='SPARC architectures'), Group(id='powerpc', name='PowerPC family'), Group(id='riscv', name='RISC-V family'), Group(id='loongarch', name='LoongArch'), Group(id='all_architectures', name='All architectures'), Group(id='all_ci', name='CI systems'), Group(id='unix_layers', name='Unix compatibility layers'), Group(id='linux_layers', name='Linux compatibility layers'), Group(id='linux_like', name='All Linux & compatibility layers'), Group(id='bsd_without_macos', name='All BSD excluding macOS'), Group(id='bsd', name='All BSD'), Group(id='system_v', name='AT&T System Five'), Group(id='little_endian', name='Little-endian architectures'), Group(id='all_traits', name='All architectures, platforms and CI systems')})¶
All predefined groups.
- extra_platforms.group_data.ALL_PLATFORM_GROUPS: frozenset[Group] = frozenset({Group(id='other_posix', name='Other POSIX-compliant platforms'), Group(id='system_v', name='AT&T System Five'), Group(id='linux_like', name='All Linux & compatibility layers'), Group(id='unix_layers', name='Unix compatibility layers'), Group(id='linux_layers', name='Linux compatibility layers'), Group(id='linux', name='Linux distributions'), Group(id='bsd_without_macos', name='All BSD excluding macOS'), Group(id='unix_without_macos', name='All Unix excluding macOS'), Group(id='bsd', name='All BSD'), Group(id='unix', name='All Unix'), Group(id='all_windows', name='All Windows'), Group(id='all_platforms', name='All platforms')})¶
All groups whose members are
Platform.
- extra_platforms.group_data.EXTRA_GROUPS: frozenset[Group] = frozenset({Group(id='big_endian', name='Big-endian architectures'), Group(id='arch_32_bit', name='32-bit architectures'), Group(id='arch_64_bit', name='64-bit architectures'), Group(id='linux_like', name='All Linux & compatibility layers'), Group(id='bsd_without_macos', name='All BSD excluding macOS'), Group(id='unix_without_macos', name='All Unix excluding macOS'), Group(id='unix', name='All Unix'), Group(id='all_platforms', name='All platforms'), Group(id='little_endian', name='Little-endian architectures'), Group(id='all_architectures', name='All architectures'), Group(id='all_traits', name='All architectures, platforms and CI systems')})¶
Overlapping groups, defined for convenience.
Hint
None of these groups are marked as
canonical.
- extra_platforms.group_data.NON_OVERLAPPING_GROUPS: frozenset[Group] = frozenset({Group(id='other_posix', name='Other POSIX-compliant platforms'), Group(id='ibm_mainframe', name='IBM mainframe'), Group(id='webassembly', name='WebAssembly'), Group(id='all_ci', name='CI systems'), Group(id='x86', name='x86 family'), Group(id='all_arm', name='ARM architectures'), Group(id='system_v', name='AT&T System Five'), Group(id='unix_layers', name='Unix compatibility layers'), Group(id='all_sparc', name='SPARC architectures'), Group(id='powerpc', name='PowerPC family'), Group(id='riscv', name='RISC-V family'), Group(id='all_windows', name='All Windows'), Group(id='linux', name='Linux distributions'), Group(id='loongarch', name='LoongArch'), Group(id='linux_layers', name='Linux compatibility layers'), Group(id='bsd', name='All BSD'), Group(id='unknown', name='Unknown'), Group(id='all_mips', name='MIPS architectures')})¶
Non-overlapping groups.
Hint
These groups together cover all
Architecture,Platform, andCItraits, including traits from theUNKNOWNgroup.All groups in this collection are marked as
canonical.
ID collections¶
- extra_platforms.group_data.ALL_GROUP_IDS: frozenset[str] = frozenset({'all_architectures', 'all_arm', 'all_ci', 'all_mips', 'all_platforms', 'all_sparc', 'all_traits', 'all_windows', 'arch_32_bit', 'arch_64_bit', 'big_endian', 'bsd', 'bsd_without_macos', 'ibm_mainframe', 'linux', 'linux_layers', 'linux_like', 'little_endian', 'loongarch', 'other_posix', 'powerpc', 'riscv', 'system_v', 'unix', 'unix_layers', 'unix_without_macos', 'webassembly', 'x86'})¶
A
frozensetof all recognized group IDs.Attention
This collection does not contain the
UNKNOWNgroup.
- extra_platforms.group_data.ALL_IDS: frozenset[str] = frozenset({'aarch64', 'aix', 'all_architectures', 'all_arm', 'all_ci', 'all_mips', 'all_platforms', 'all_sparc', 'all_traits', 'all_windows', 'altlinux', 'amzn', 'android', 'arch', 'arch_32_bit', 'arch_64_bit', 'arm', 'armv5tel', 'armv6l', 'armv7l', 'armv8l', 'azure_pipelines', 'bamboo', 'big_endian', 'bsd', 'bsd_without_macos', 'buildkite', 'buildroot', 'cachyos', 'centos', 'circle_ci', 'cirrus_ci', 'cloudlinux', 'codebuild', 'cygwin', 'debian', 'dragonfly_bsd', 'exherbo', 'fedora', 'freebsd', 'gentoo', 'github_ci', 'gitlab_ci', 'guix', 'haiku', 'heroku_ci', 'hurd', 'i386', 'i586', 'i686', 'ibm_mainframe', 'ibm_powerkvm', 'illumos', 'kvmibm', 'linux', 'linux_layers', 'linux_like', 'linuxmint', 'little_endian', 'loongarch', 'loongarch64', 'macos', 'mageia', 'mandriva', 'midnightbsd', 'mips', 'mips64', 'mips64el', 'mipsel', 'netbsd', 'nobara', 'openbsd', 'opensuse', 'oracle', 'other_posix', 'parallels', 'pidora', 'powerpc', 'ppc', 'ppc64', 'ppc64le', 'raspbian', 'rhel', 'riscv', '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', 'wasm32', 'wasm64', 'webassembly', 'windows', 'wsl1', 'wsl2', 'x86', 'x86_64', 'xenserver'})¶
A
frozensetof all recognized traits and group IDs.Attention
This collection does not contain all the
UNKNOWN_*traits and theUNKNOWNgroup.
- extra_platforms.group_data.ALL_TRAIT_IDS: frozenset[str] = frozenset({'aarch64', 'aix', 'altlinux', 'amzn', 'android', 'arch', 'arm', 'armv5tel', 'armv6l', 'armv7l', 'armv8l', 'azure_pipelines', 'bamboo', 'buildkite', 'buildroot', 'cachyos', 'centos', 'circle_ci', 'cirrus_ci', 'cloudlinux', 'codebuild', 'cygwin', 'debian', 'dragonfly_bsd', 'exherbo', 'fedora', 'freebsd', 'gentoo', 'github_ci', 'gitlab_ci', 'guix', 'haiku', 'heroku_ci', 'hurd', 'i386', 'i586', 'i686', 'ibm_powerkvm', 'illumos', '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', 'wasm32', 'wasm64', 'windows', 'wsl1', 'wsl2', 'x86_64', 'xenserver'})¶
A
frozensetof all recognized traits IDs.Attention
This collection does not contain all the
UNKNOWN_*traits.
Trait and group operations¶
- extra_platforms.extract_members(*other)[source]¶
Returns all traits found in
other.othercan be an arbitrarily nestedIterableofGroup,Trait, or their IDs.Nonevalues and empty iterables are silently ignored.Caution
Can returns duplicates.
- extra_platforms.traits_from_ids(*trait_and_group_ids)[source]¶
Returns a deduplicated
tupleof traits matching the provided IDs.IDs are case-insensitive, and can refer to any traits or groups. Matching groups will be expanded to the
Traitinstances they contain.Aliases are automatically resolved to their canonical IDs, with a warning emitted to encourage using the canonical ID directly.
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
reduce()function on the results.
- extra_platforms.groups_from_ids(*group_ids)[source]¶
Returns a deduplicated
tupleof groups matching the provided IDs.IDs are case-insensitive.
Order of the returned
Groupinstances 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
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.Note
The algorithm is a variant of the Set Cover Problem, which is NP-hard. This implementation uses a greedy approximation that iteratively selects the largest group fitting the remaining uncovered traits.
Todo
Should we rename or alias this method to
collapse()? Cannot decide if it is more descriptive or not…
Group implementation¶
- class extra_platforms.Group(id, name, icon='❓', members=<factory>)[source]¶
Bases:
_IdentifiableA
Groupidentifies a collection ofTraitmembers.Additionally of the common fields inherited from
_Identifiable, each group provides:members: An iterable ofTraitinstances that belong to this group.member_ids: Afrozensetof member IDs for quick lookup.canonical: Aboolindicating if the group is canonical (non-overlapping).various
set-like operations (union, intersection, difference, etc.).
- members: Iterable[Trait]¶
Traits in this group.
Normalized to
MappingProxyTypeat init, providing O(1) lookup by ID.
- property _members: MappingProxyType¶
Typed access to members as
MappingProxyType.Warning
The
membersfield is typed asIterableto accept any iterable at construction time. After__post_init__, it is always aMappingProxyType. This property provides acast()to that type, avoiding# type: ignorecomments throughout the class.
- __post_init__()[source]¶
Normalize members to a sorted, deduplicated mapping.
Hint
Docstring generation is deferred to avoid circular imports during module initialization. See _docstrings._initialize_all_docstrings().
- generate_docstring()[source]¶
Generate comprehensive docstring for this group instance.
Combines the attribute docstring from the source module with various metadata.
- Return type:
- property canonical: bool¶
Returns
Trueif the group is canonical (non-overlapping),Falseotherwise.A canonical group is one that does not share any members with other canonical groups. All canonical groups are non-overlapping.
Non-canonical groups are provided for convenience, but overlap with each other or with canonical groups.
Hint
Canonical groups are denoted with a ⬥ symbol in the documentation and tables.
- isdisjoint(other)[source]¶
Return
Trueif the group has no members in common withother.Groups are disjoint if and only if their intersection is an empty
set.othercan be an arbitrarily nestedIterableofGroupandTrait.- Return type:
- fullyintersects(other)[source]¶
Return
Trueif the group has all members in common withother.- Return type:
- __lt__(other)[source]¶
Test whether every member in the group is in other, but not all.
- Return type:
- __gt__(other)[source]¶
Test whether every member in other is in the group, but not all.
- 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:
- __or__(*others)¶
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:
- __ior__(*others)¶
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:
- __and__(*others)¶
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:
- __iand__(*others)¶
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:
- __sub__(*others)¶
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:
- __isub__(*others)¶
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:
- __xor__(other)¶
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:
- __ixor__(other)¶
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:
- remove(member)[source]¶
Return a new
Groupwith the specified trait removed.Raises
KeyErrorif the trait is not in the group.- 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:
- 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.
- __annotations__ = {'members': 'Iterable[Trait]'}¶
- __dataclass_fields__ = {'all_group': Field(name='all_group',type='ClassVar[str]',default='',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=<dataclasses._MISSING_TYPE object>,_field_type=_FIELD_CLASSVAR), 'data_module_id': Field(name='data_module_id',type='ClassVar[str]',default='',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=<dataclasses._MISSING_TYPE object>,_field_type=_FIELD_CLASSVAR), 'detection_func_id': Field(name='detection_func_id',type='str',default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=False,repr=False,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'doc_page': Field(name='doc_page',type='ClassVar[str]',default='',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=<dataclasses._MISSING_TYPE object>,_field_type=_FIELD_CLASSVAR), 'icon': Field(name='icon',type='str',default='❓',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=False,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'id': Field(name='id',type='str',default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'members': Field(name='members',type='Iterable[Trait]',default=<dataclasses._MISSING_TYPE object>,default_factory=<class 'tuple'>,init=True,repr=False,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'name': Field(name='name',type='str',default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'skip_decorator_id': Field(name='skip_decorator_id',type='str',default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=False,repr=False,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'symbol_id': Field(name='symbol_id',type='str',default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=False,repr=False,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'type_id': Field(name='type_id',type='ClassVar[str]',default='',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=<dataclasses._MISSING_TYPE object>,_field_type=_FIELD_CLASSVAR), 'type_name': Field(name='type_name',type='ClassVar[str]',default='',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=<dataclasses._MISSING_TYPE object>,_field_type=_FIELD_CLASSVAR), 'unknown_symbol': Field(name='unknown_symbol',type='ClassVar[str]',default='',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=<dataclasses._MISSING_TYPE object>,_field_type=_FIELD_CLASSVAR), 'unless_decorator_id': Field(name='unless_decorator_id',type='str',default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=False,repr=False,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD)}¶
- __dataclass_params__ = _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False,frozen=True,match_args=True,kw_only=False,slots=False,weakref_slot=False)¶
- __delattr__(name)¶
Implement delattr(self, name).
- __eq__(other)¶
Return self==value.
- __init__(id, name, icon='❓', members=<factory>)¶
- __match_args__ = ('id', 'name', 'icon', 'members')¶
- __module__ = 'extra_platforms.group'¶
- __repr__()¶
Return repr(self).
- __setattr__(name, value)¶
Implement setattr(self, name, value).
- all_group: ClassVar[str] = 'ALL_GROUPS'¶
The symbol name for the group containing all instances of this type.
- data_module_id: ClassVar[str] = 'group_data'¶
The module name where instances of this type are defined.
classDiagram
_Identifiable <|-- Group
Group a collection of traits. Also referred as families.
Definitions of ready-to-use groups.
This module contains all predefined Group instances and
frozenset collections that organize traits into logical categories.