DetectionΒΆ

extra_platforms.detection APIΒΆ

Heuristics to detect each platform.

All these heuristics can be hard-cached as the underlying system is not changing between code execution.

We mostly rely on distro to detect the Linux distribution, as it is the recommended replacement for Python’s original platform.linux_distribution function (which was removed in Python 3.8).

We then fill in the gaps with sys.platform and environment variables to detect systems not covered by distro.

This collection of heuristics is designed as a set of separate function with minimal logic and dependencies. That way we can double-check during execution that no heuristics are conflicting or matching multiple systems at the same time.

Note

Heuristics for unrecognized platforms can be transplanted from Rust’s sysinfo crate.

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

Return True only if current platform is AIX.

Return type:

bool

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

Return True only if current platform is ALT Linux.

Return type:

bool

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

Return True only if current platform is Amazon Linux.

Return type:

bool

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

Return True only if current platform is Android.

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

Return type:

bool

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

Return True only if current platform is Arch Linux.

Return type:

bool

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

Return True only if current platform is Buildroot.

Return type:

bool

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

Return True only if current platform is CentOS.

Return type:

bool

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

Return True only if current platform is CloudLinux OS.

Return type:

bool

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

Return True only if current platform is Cygwin.

Return type:

bool

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

Return True only if current platform is Debian.

Return type:

bool

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

Return True only if current platform is Exherbo Linux.

Return type:

bool

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

Return True only if current platform is Fedora.

Return type:

bool

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

Return True only if current platform is FreeBSD.

Return type:

bool

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

Return True only if current platform is GenToo Linux.

Return type:

bool

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

Return True only if current platform is Guix System.

Return type:

bool

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

Return True only if current platform is GNU/Hurd.

Return type:

bool

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

Return True only if current platform is IBM PowerKVM.

Return type:

bool

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

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

Return type:

bool

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

Return True only if current platform is Linux Mint.

Return type:

bool

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

Return True only if current platform is macOS.

Return type:

bool

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

Return True only if current platform is Mageia.

Return type:

bool

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

Return True only if current platform is Mandriva Linux.

Return type:

bool

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

Return True only if current platform is MidnightBSD.

Return type:

bool

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

Return True only if current platform is NetBSD.

Return type:

bool

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

Return True only if current platform is OpenBSD.

Return type:

bool

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

Return True only if current platform is openSUSE.

Return type:

bool

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

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

Return type:

bool

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

Return True only if current platform is Parallels.

Return type:

bool

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

Return True only if current platform is Pidora.

Return type:

bool

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

Return True only if current platform is Raspbian.

Return type:

bool

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

Return True only if current platform is RedHat Enterprise Linux.

Return type:

bool

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

Return True only if current platform is Rocky Linux.

Return type:

bool

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

Return True only if current platform is Scientific Linux.

Return type:

bool

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

Return True only if current platform is Slackware.

Return type:

bool

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

Return True only if current platform is SUSE Linux Enterprise Server.

Return type:

bool

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

Return True only if current platform is Solaris.

Return type:

bool

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

Return True only if current platform is SunOS.

Return type:

bool

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

Return True only if current platform is Ubuntu.

Return type:

bool

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

Return True only if current platform is an unknown Linux.

Excludes WSL1 and WSL2 from this check to avoid false positives.

Return type:

bool

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

Return True only if current platform is Windows.

Return type:

bool

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

Return True only if current platform is Windows Subsystem for Linux v1. :rtype: bool

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
    
extra_platforms.detection.is_wsl2()[source]ΒΆ

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

Return type:

bool

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

Return True only if current platform is XenServer.

Return type:

bool