Platforms

Each platform represents an operating system or OS-like environment, and is associated with:

  • a unique platform ID

  • a human-readable name

  • an icon (emoji / unicode character)

  • a detection function

  • various metadata in its info() method

Platform usage

Each platform is materialized by a Platform object, from which you can access various metadata:

>>> from extra_platforms import DEBIAN
>>> DEBIAN
Platform(id='debian', name='Debian')
>>> DEBIAN.id
'debian'
>>> DEBIAN.current
False
>>> DEBIAN.info()
{'id': 'debian', 'name': 'Debian', 'icon': '🌀', 'url': 'https://debian.org', 'current': False, 'distro_id': None, 'version': None, 'version_parts': {'major': None, 'minor': None, 'build_number': None}, 'like': None, 'codename': None}

To check if the current platform matches a specific platform, use the corresponding detection function:

>>> from extra_platforms import is_macos
>>> is_macos()
True

The current platform can be obtained via the current_platform() function:

>>> from extra_platforms import current_platform
>>> current_platform()
Platform(id='macos', name='macOS')

Compatibility layers can match at once

Most Linux distributions are identified by the ID field of their os-release file, while other systems are recognized through dedicated markers like sys.platform values, environment variables or vendor files.

A compatibility layer is detected alongside the system it hosts, so two platform detection functions can legitimately return True at the same time: inside WSL, both is_wsl2() (or is_wsl1()) and the hosted distribution’s function like is_ubuntu() match; inside ChromeOS’s Crostini container, both is_chromeos() and is_debian() do.

current_platform() narrows the matches down to the most informative one by dropping the layers (WSL1, WSL2, CHROMEOS) in favor of the hosted distribution. current_traits() keeps every match.

GENERIC_LINUX plays the opposite role: it is not an extra match but a fallback, only firing when the kernel is Linux and the distribution cannot be identified (like minimal containers or build chroots shipping no os-release file). current_platform() still returns it in that situation, while logging a warning inviting you to report the unrecognized distribution.

Recognized platforms

Independent derivative distributions each get a dedicated platform, even when they build on a parent distribution: Ubuntu, Kali Linux, Linux Mint, Raspbian and PikaOS are all Debian derivatives, but each is managed by its own organization. Release channels, variants and flavors of a single distribution, managed by the same organization as the parent, are folded into the parent’s platform: every openSUSE channel (Tumbleweed, Leap, Slowroll, MicroOS, …) is detected as OPENSUSE, while the raw channel ID remains available through info().

Icon

Symbol

Name

Detection function

AIX

IBM AIX

is_aix()

🏔️

ALPINE

Alpine Linux

is_alpine()

Δ

ALTLINUX

ALT Linux

is_altlinux()

AMZN

Amazon Linux

is_amzn()

🤖

ANDROID

Android

is_android()

🎗️

ARCH

Arch Linux

is_arch()

⛑️

BUILDROOT

Buildroot

is_buildroot()

CACHYOS

CachyOS

is_cachyos()

💠

CENTOS

CentOS

is_centos()

🧿

CHROMEOS

ChromeOS

is_chromeos()

✳️

CLEARLINUX

Clear Linux OS

is_clearlinux()

CLOUDLINUX

CloudLinux OS

is_cloudlinux()

Ͼ

CYGWIN

Cygwin

is_cygwin()

🌀

DEBIAN

Debian

is_debian()

🪰

DRAGONFLY_BSD

DragonFly BSD

is_dragonfly_bsd()

🐽

EXHERBO

Exherbo Linux

is_exherbo()

🎩

FEDORA

Fedora

is_fedora()

😈

FREEBSD

FreeBSD

is_freebsd()

🥚

GENERIC_LINUX

Generic Linux

is_generic_linux()

🗜️

GENTOO

Gentoo Linux

is_gentoo()

🐃

GUIX

Guix System

is_guix()

🍂

HAIKU

Haiku

is_haiku()

🦬

HURD

GNU/Hurd

is_hurd()

🤹

IBM_POWERKVM

IBM PowerKVM

is_ibm_powerkvm()

🔥

ILLUMOS

illumos

is_illumos()

🔱

KALI

Kali Linux

is_kali()

🤹

KVMIBM

KVM for IBM z Systems

is_kvmibm()

🌿

LINUXMINT

Linux Mint

is_linuxmint()

🍎

MACOS

macOS

is_macos()

MAGEIA

Mageia

is_mageia()

💫

MANDRIVA

Mandriva Linux

is_mandriva()

MANJARO

Manjaro Linux

is_manjaro()

🌘

MIDNIGHTBSD

MidnightBSD

is_midnightbsd()

🚩

NETBSD

NetBSD

is_netbsd()

❄️

NIXOS

NixOS

is_nixos()

NOBARA

Nobara

is_nobara()

🐡

OPENBSD

OpenBSD

is_openbsd()

🦎

OPENSUSE

openSUSE

is_opensuse()

📶

OPENWRT

OpenWrt

is_openwrt()

🦴

ORACLE

Oracle Linux

is_oracle()

🟦

OS400

IBM i

is_os400()

PARALLELS

Parallels

is_parallels()

🍓

PIDORA

Pidora

is_pidora()

🐹

PIKAOS

PikaOS

is_pikaos()

🍓

RASPBIAN

Raspbian

is_raspbian()

🎩

RHEL

RedHat Enterprise Linux

is_rhel()

⛰️

ROCKY

Rocky Linux

is_rocky()

⚛️

SCIENTIFIC

Scientific Linux

is_scientific()

🚬

SLACKWARE

Slackware

is_slackware()

🦎

SLES

SUSE Linux Enterprise Server

is_sles()

🕷️

SLITAZ

SliTaz GNU/Linux

is_slitaz()

🌞

SOLARIS

Solaris

is_solaris()

🧙

SOURCEMAGE

Source Mage GNU/Linux

is_sourcemage()

🌅

SUNOS

SunOS

is_sunos()

🤵

TUXEDO

Tuxedo OS

is_tuxedo()

🎯

UBUNTU

Ubuntu

is_ubuntu()

🌊

ULTRAMARINE

Ultramarine

is_ultramarine()

VOID

Void Linux

is_void()

🪟

WINDOWS

Windows

is_windows()

WSL1

Windows Subsystem for Linux v1

is_wsl1()

WSL2

Windows Subsystem for Linux v2

is_wsl2()

XENSERVER

XenServer

is_xenserver()

Hint

The UNKNOWN_PLATFORM trait represents an unrecognized platform. It is not included in the ALL_PLATFORMS group, and will be returned by current_platform() if the current platform is not recognized.

Groups of platforms

All platform groups

Icon

Symbol

Description

Detection

Canonical

⚙️

ALL_PLATFORMS

All platforms

is_any_platform()

🪟

ALL_WINDOWS

All Windows

is_any_windows()

BSD

All BSD

is_bsd()

🅱️

BSD_WITHOUT_MACOS

All BSD excluding macOS

is_bsd_not_macos()

🐧

LINUX

Linux distributions

is_linux()

LINUX_LAYERS

Linux compatibility layers

is_linux_layers()

🐣

LINUX_LIKE

All Linux & compatibility layers

is_linux_like()

🅟

OTHER_POSIX

Other POSIX-compliant platforms

is_other_posix()

𝐕

SYSTEM_V

AT&T System Five

is_system_v()

UNIX

All Unix

is_unix()

UNIX_LAYERS

Unix compatibility layers

is_unix_layers()

UNIX_WITHOUT_MACOS

All Unix excluding macOS

is_unix_not_macos()

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.

Canonical groups

All platforms are distributed in groups that are guaranteed to be non-overlapping.

Here is the canonical groups and all platforms, visualized as a Sankey diagram:

        ---
config:
  sankey:
    height: 800
    showValues: false
    width: 800

---
sankey-beta

ALL_PLATFORMS,LINUX,45
ALL_PLATFORMS,BSD,7
ALL_PLATFORMS,SYSTEM_V,3
ALL_PLATFORMS,UNIX_LAYERS,2
ALL_PLATFORMS,OTHER_POSIX,2
ALL_PLATFORMS,LINUX_LAYERS,2
ALL_PLATFORMS,ALL_WINDOWS,1
LINUX,ALPINE,1
LINUX,ALTLINUX,1
LINUX,AMZN,1
LINUX,ANDROID,1
LINUX,ARCH,1
LINUX,BUILDROOT,1
LINUX,CACHYOS,1
LINUX,CENTOS,1
LINUX,CHROMEOS,1
LINUX,CLEARLINUX,1
LINUX,CLOUDLINUX,1
LINUX,DEBIAN,1
LINUX,EXHERBO,1
LINUX,FEDORA,1
LINUX,GENERIC_LINUX,1
LINUX,GENTOO,1
LINUX,GUIX,1
LINUX,IBM_POWERKVM,1
LINUX,KALI,1
LINUX,KVMIBM,1
LINUX,LINUXMINT,1
LINUX,MAGEIA,1
LINUX,MANDRIVA,1
LINUX,MANJARO,1
LINUX,NIXOS,1
LINUX,NOBARA,1
LINUX,OPENSUSE,1
LINUX,OPENWRT,1
LINUX,ORACLE,1
LINUX,PARALLELS,1
LINUX,PIDORA,1
LINUX,PIKAOS,1
LINUX,RASPBIAN,1
LINUX,RHEL,1
LINUX,ROCKY,1
LINUX,SCIENTIFIC,1
LINUX,SLACKWARE,1
LINUX,SLES,1
LINUX,SLITAZ,1
LINUX,SOURCEMAGE,1
LINUX,TUXEDO,1
LINUX,UBUNTU,1
LINUX,ULTRAMARINE,1
LINUX,VOID,1
LINUX,XENSERVER,1
BSD,DRAGONFLY_BSD,1
BSD,FREEBSD,1
BSD,MACOS,1
BSD,MIDNIGHTBSD,1
BSD,NETBSD,1
BSD,OPENBSD,1
BSD,SUNOS,1
SYSTEM_V,AIX,1
SYSTEM_V,ILLUMOS,1
SYSTEM_V,SOLARIS,1
UNIX_LAYERS,CYGWIN,1
UNIX_LAYERS,OS400,1
OTHER_POSIX,HAIKU,1
OTHER_POSIX,HURD,1
LINUX_LAYERS,WSL1,1
LINUX_LAYERS,WSL2,1
ALL_WINDOWS,WINDOWS,1
    

And the same groups visualized as a mindmap:

        ---
config:
  mindmap:
    padding: 5

---
mindmap
    ((⚙️ ALL_PLATFORMS))
        )≛ UNIX_LAYERS(
            (Ͼ CYGWIN)
            (🟦 OS400)
        )𝐕 SYSTEM_V(
            (➿ AIX)
            (🔥 ILLUMOS)
            (🌞 SOLARIS)
        )🅟 OTHER_POSIX(
            (🍂 HAIKU)
            (🦬 HURD)
        )≚ LINUX_LAYERS(
            (⊞ WSL1)
            (⊞ WSL2)
        )🐧 LINUX(
            (🏔️ ALPINE)
            (Δ ALTLINUX)
            (⤻ AMZN)
            (🤖 ANDROID)
            (🎗️ ARCH)
            (⛑️ BUILDROOT)
            (⌬ CACHYOS)
            (💠 CENTOS)
            (🧿 CHROMEOS)
            (✳️ CLEARLINUX)
            (꩜ CLOUDLINUX)
            (🌀 DEBIAN)
            (🐽 EXHERBO)
            (🎩 FEDORA)
            (🥚 GENERIC_LINUX)
            (🗜️ GENTOO)
            (🐃 GUIX)
            (🤹 IBM_POWERKVM)
            (🔱 KALI)
            (🤹 KVMIBM)
            (🌿 LINUXMINT)
            (⍥ MAGEIA)
            (💫 MANDRIVA)
            (▲ MANJARO)
            (❄️ NIXOS)
            ( NOBARA)
            (🦎 OPENSUSE)
            (📶 OPENWRT)
            (🦴 ORACLE)
            (∥ PARALLELS)
            (🍓 PIDORA)
            (🐹 PIKAOS)
            (🍓 RASPBIAN)
            (🎩 RHEL)
            (⛰️ ROCKY)
            (⚛️ SCIENTIFIC)
            (🚬 SLACKWARE)
            (🦎 SLES)
            (🕷️ SLITAZ)
            (🧙 SOURCEMAGE)
            (🤵 TUXEDO)
            (🎯 UBUNTU)
            (🌊 ULTRAMARINE)
            (∅ VOID)
            (Ⓧ XENSERVER)
        )Ⓑ BSD(
            (🪰 DRAGONFLY_BSD)
            (😈 FREEBSD)
            (🍎 MACOS)
            (🌘 MIDNIGHTBSD)
            (🚩 NETBSD)
            (🐡 OPENBSD)
            (🌅 SUNOS)
        )🪟 ALL_WINDOWS(
            (🪟 WINDOWS)
    

Predefined platforms

Platform definitions and metadata.

Important

Not every distribution gets a dedicated entry. The granularity policy is:

  • Independent derivative distributions each get their own platform, even when they build on a parent distribution. Ubuntu, Kali Linux, Linux Mint, Raspbian and PikaOS are all Debian derivatives, but each is managed by its own organization, with its own identity, release cadence and package repositories.

  • Release channels, variants and flavors of a single distribution, managed by the same organization as the parent, are folded into the parent’s platform. Every openSUSE channel (Tumbleweed, Leap, Slowroll, MicroOS, …) is detected as OPENSUSE by its is_opensuse() detection function, while the raw channel ID remains available through Platform.info().

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.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.AIX = Platform(id='aix', name='IBM AIX')
extra_platforms.ALPINE = Platform(id='alpine', name='Alpine Linux')
extra_platforms.ALTLINUX = Platform(id='altlinux', name='ALT Linux')
extra_platforms.AMZN = Platform(id='amzn', name='Amazon Linux')
extra_platforms.ANDROID = Platform(id='android', name='Android')
extra_platforms.ARCH = Platform(id='arch', name='Arch Linux')
extra_platforms.BUILDROOT = Platform(id='buildroot', name='Buildroot')
extra_platforms.CACHYOS = Platform(id='cachyos', name='CachyOS')
extra_platforms.CENTOS = Platform(id='centos', name='CentOS')
extra_platforms.CHROMEOS = Platform(id='chromeos', name='ChromeOS')
extra_platforms.CLEARLINUX = Platform(id='clearlinux', name='Clear Linux OS')
extra_platforms.CLOUDLINUX = Platform(id='cloudlinux', name='CloudLinux OS')
extra_platforms.CYGWIN = Platform(id='cygwin', name='Cygwin')
extra_platforms.DEBIAN = Platform(id='debian', name='Debian')
extra_platforms.DRAGONFLY_BSD = Platform(id='dragonfly_bsd', name='DragonFly BSD')
extra_platforms.EXHERBO = Platform(id='exherbo', name='Exherbo Linux')
extra_platforms.FEDORA = Platform(id='fedora', name='Fedora')
extra_platforms.FREEBSD = Platform(id='freebsd', name='FreeBSD')
extra_platforms.GENERIC_LINUX = Platform(id='generic_linux', name='Generic Linux')
extra_platforms.GENTOO = Platform(id='gentoo', name='Gentoo Linux')
extra_platforms.GUIX = Platform(id='guix', name='Guix System')
extra_platforms.HAIKU = Platform(id='haiku', name='Haiku')
extra_platforms.HURD = Platform(id='hurd', name='GNU/Hurd')
extra_platforms.IBM_POWERKVM = Platform(id='ibm_powerkvm', name='IBM PowerKVM')
extra_platforms.ILLUMOS = Platform(id='illumos', name='illumos')
extra_platforms.KALI = Platform(id='kali', name='Kali Linux')
extra_platforms.KVMIBM = Platform(id='kvmibm', name='KVM for IBM z Systems')
extra_platforms.LINUXMINT = Platform(id='linuxmint', name='Linux Mint')
extra_platforms.MACOS = Platform(id='macos', name='macOS')
extra_platforms.MAGEIA = Platform(id='mageia', name='Mageia')
extra_platforms.MANDRIVA = Platform(id='mandriva', name='Mandriva Linux')
extra_platforms.MANJARO = Platform(id='manjaro', name='Manjaro Linux')
extra_platforms.MIDNIGHTBSD = Platform(id='midnightbsd', name='MidnightBSD')
extra_platforms.NETBSD = Platform(id='netbsd', name='NetBSD')
extra_platforms.NIXOS = Platform(id='nixos', name='NixOS')
extra_platforms.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.OPENBSD = Platform(id='openbsd', name='OpenBSD')
extra_platforms.OPENSUSE = Platform(id='opensuse', name='openSUSE')
extra_platforms.OPENWRT = Platform(id='openwrt', name='OpenWrt')
extra_platforms.ORACLE = Platform(id='oracle', name='Oracle Linux')
extra_platforms.OS400 = Platform(id='os400', name='IBM i')
extra_platforms.PARALLELS = Platform(id='parallels', name='Parallels')
extra_platforms.PIDORA = Platform(id='pidora', name='Pidora')
extra_platforms.PIKAOS = Platform(id='pikaos', name='PikaOS')
extra_platforms.RASPBIAN = Platform(id='raspbian', name='Raspbian')
extra_platforms.RHEL = Platform(id='rhel', name='RedHat Enterprise Linux')
extra_platforms.ROCKY = Platform(id='rocky', name='Rocky Linux')
extra_platforms.SCIENTIFIC = Platform(id='scientific', name='Scientific Linux')
extra_platforms.SLACKWARE = Platform(id='slackware', name='Slackware')
extra_platforms.SLES = Platform(id='sles', name='SUSE Linux Enterprise Server')
extra_platforms.SLITAZ = Platform(id='slitaz', name='SliTaz GNU/Linux')
extra_platforms.SOLARIS = Platform(id='solaris', name='Solaris')
extra_platforms.SOURCEMAGE = Platform(id='sourcemage', name='Source Mage GNU/Linux')
extra_platforms.SUNOS = Platform(id='sunos', name='SunOS')
extra_platforms.TUXEDO = Platform(id='tuxedo', name='Tuxedo OS')
extra_platforms.UBUNTU = Platform(id='ubuntu', name='Ubuntu')
extra_platforms.ULTRAMARINE = Platform(id='ultramarine', name='Ultramarine')
extra_platforms.UNKNOWN_PLATFORM = Platform(id='unknown_platform', name='Unknown platform')
extra_platforms.VOID = Platform(id='void', name='Void Linux')
extra_platforms.WINDOWS = Platform(id='windows', name='Windows')
extra_platforms.WSL1 = Platform(id='wsl1', name='Windows Subsystem for Linux v1')
extra_platforms.WSL2 = Platform(id='wsl2', name='Windows Subsystem for Linux v2')
extra_platforms.XENSERVER = Platform(id='xenserver', name='XenServer')