Detection¶
All detection functions¶
Detection function |
Icon |
Associated symbol |
|---|---|---|
📱 |
||
➿ |
||
🔳 |
||
|
||
🏔️ |
||
Δ |
||
⤻ |
||
🤖 |
||
🧠 |
||
🏛️ |
||
📱 |
||
♺ |
||
🔲 |
||
⚙️ |
||
🐚 |
||
☀️ |
||
💻 |
||
⁕ |
||
🪟 |
||
🍏 |
||
🎗️ |
||
³² |
||
⁶⁴ |
||
📱 |
||
📱 |
||
📱 |
||
📱 |
||
📱 |
||
⟁ |
||
🪶 |
||
═ |
||
⟲ |
||
# |
||
⬆️ |
||
💲 |
||
Ⓑ |
||
🅱️ |
||
🪁 |
||
⛑️ |
||
🅲 |
||
⌬ |
||
💠 |
||
🧿 |
||
⪾ |
||
≋ |
||
✴️ |
||
✳️ |
||
👾 |
||
꩜ |
||
▶ |
||
ᚙ |
||
📕 |
||
◰ |
||
✈️ |
||
💘 |
||
✜ |
||
𝐂 |
||
➤ |
||
Ͼ |
||
💨 |
||
🌀 |
||
🪰 |
||
🚀 |
||
🐽 |
||
🎩 |
||
🐟 |
||
🦶 |
||
😈 |
||
♊ |
||
🥚 |
||
🗜️ |
||
👻 |
||
🐙 |
||
🦊 |
||
𝐆 |
||
📺 |
||
🎮 |
||
🐃 |
||
🍂 |
||
🥫 |
||
⥁ |
||
🦬 |
||
⬡ |
||
𝗶 |
||
𝗶 |
||
𝗶 |
||
🏢 |
||
🤹 |
||
🔥 |
||
⬛ |
||
🔱 |
||
🐱 |
||
💎 |
||
𝐊 |
||
🤹 |
||
🐧 |
||
≚ |
||
🐣 |
||
🌿 |
||
⬇️ |
||
🐉 |
||
🐉 |
||
🍎 |
||
⍥ |
||
💫 |
||
▲ |
||
🌘 |
||
🔲 |
||
🔲 |
||
🔲 |
||
🔲 |
||
⧉ |
||
▦ |
||
🚩 |
||
❄️ |
||
|
||
𝜈 |
||
🃏 |
||
🐡 |
||
🦎 |
||
📶 |
||
🦴 |
||
🟦 |
||
🅟 |
||
◇ |
||
∥ |
||
π |
||
🍓 |
||
🐹 |
||
⚡ |
||
🔷 |
||
⚡ |
||
⚡ |
||
⚡ |
||
🍓 |
||
🎩 |
||
🏞️ |
||
Ⅴ |
||
Ⅴ |
||
Ⅴ |
||
⛰️ |
||
🏢 |
||
⚛️ |
||
𝐒 |
||
🚬 |
||
🦎 |
||
🕷️ |
||
🌞 |
||
|
||
🧙 |
||
☀️ |
||
☀️ |
||
🌅 |
||
𝐕 |
||
🐈 |
||
𝐓 |
||
🏙️ |
||
🔀 |
||
📟 |
||
👷 |
||
🤵 |
||
🎯 |
||
🌊 |
||
⨷ |
||
≛ |
||
⨂ |
||
❓ |
||
❓ |
||
❓ |
||
❓ |
||
❓ |
||
❓ |
||
❓ |
||
∅ |
||
🔵 |
||
🌐 |
||
🌐 |
||
⬢ |
||
🌐 |
||
🌴 |
||
🔡 |
||
🪟 |
||
⌨️ |
||
⊡ |
||
⊞ |
||
⊞ |
||
𝘅 |
||
🖥️ |
||
Ⓧ |
||
🐍 |
||
𝐗 |
||
🪵 |
||
ℤ |
Trait detection functions¶
- extra_platforms.is_aarch64()[source]¶
Return
Trueif current architecture isAARCH64.Caution
platform.machine()returns different values depending on the OS:Linux:
aarch64macOS:
arm64Windows:
ARM64
- Return type:
- extra_platforms.is_android()[source]¶
Return
Trueif current platform isANDROID.See also
Source: <https://github.com/kivy/kivy/blob/master/kivy/utils.py>
- Return type:
- extra_platforms.is_apple_terminal()[source]¶
Return
TrueinAPPLE_TERMINAL.- Return type:
- extra_platforms.is_arm()[source]¶
Return
Trueif current architecture isARM.Hint
This is a fallback detection for generic ARM architecture. It will return
Truefor any ARM architecture not specifically covered by the more precise variants:is_aarch64(),is_armv5tel(),is_armv6l(),is_armv7l()oris_armv8l().- Return type:
- extra_platforms.is_ash()[source]¶
Return
Trueif current shell isASH.Hint
Detected via the
SHELLenvironment variable path, as Almquist Shell does not set its own version variable.Note
BusyBox’s built-in shell is an
ASHderivative, which itsshandashapplets both run (seeextra_platforms._process_tree). On BusyBox-based systems (ALPINE,OPENWRT),/bin/shand/bin/ashboth link to BusyBox, so either one, as$SHELLor running, is detected asASH.- Return type:
- extra_platforms.is_azure_pipelines()[source]¶
Return
Trueif current CI isAZURE_PIPELINES.See also
Environment variables reference: <https://learn.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&viewFallbackFrom=vsts&tabs=yaml#system-variables>.
- Return type:
- extra_platforms.is_bamboo()[source]¶
Return
Trueif current CI isBAMBOO.See also
Environment variables reference: <https://confluence.atlassian.com/bamboo/bamboo-variables-289277087.html#Bamboovariables-Build-specificvariables>.
- Return type:
- extra_platforms.is_bash()[source]¶
Return
Trueif current shell isBASH.Hint
Detected via the
BASH_VERSIONenvironment variable (set by Bash on startup), or via theSHELLpath as a fallback.Attention
GitHub’s
ubuntu-slimrunner is a stripped-down environments, running as a WSL2 container on top of Windows. It uses Bash as the default shell, but does not set neitherBASH_VERSIONnorSHELL. In that case we fall back to walking the parent process tree via/procto find it.- Return type:
- extra_platforms.is_buildkite()[source]¶
Return
Trueif current CI isBUILDKITE.See also
Environment variables reference: <https://buildkite.com/docs/pipelines/environment-variables>.
- Return type:
- extra_platforms.is_chromeos()[source]¶
Return
Trueif current platform isCHROMEOS.Matches ChromeOS itself, whose
os-releasefile setsID=chromeos(the environment targeted by Chromebrew), as well as open-source ChromiumOS builds and their derivatives like FydeOS and openFyde, which setID=chromiumos. Accepting both IDs was the practice of Google’s own flashrom tester.Also matches the Crostini Linux development environment. Crostini being a Debian-based container, its
os-releasefile reports Debian. So the/dev/.cros_milestonefile exposed by the ChromeOS host is used as the detection marker instead, a practice shared with LXD, Incus and the Dart SDK.Caution
Within Crostini, both this function and
is_debian()returnTrue, the same way WSL sessions match bothis_wsl2()and the distribution it hosts. In that situation,current_platform()prefers the container’s own distribution.- Return type:
- extra_platforms.is_circle_ci()[source]¶
Return
Trueif current CI isCIRCLE_CI.See also
Environment variables reference: <https://circleci.com/docs/reference/variables/#built-in-environment-variables>.
- Return type:
- extra_platforms.is_cirrus_ci()[source]¶
Return
Trueif current CI isCIRRUS_CI.See also
Environment variables reference: <https://github.com/cirruslabs/cirrus-ci-docs/blob/4ca6123b9832eb5f0ead8a27ef5a5806ed2f2157/docs/guide/writing-tasks.md#environment-variables>.
- Return type:
- extra_platforms.is_claude_code()[source]¶
Return
Trueif current agent isCLAUDE_CODE.See also
Claude Code sets the
CLAUDECODEenvironment variable when running.- Return type:
- extra_platforms.is_clearlinux()[source]¶
Return
Trueif current platform isCLEARLINUX.Note
Clear Linux OS sets
ID=clear-linux-osin itsos-releasefile. Being a stateless distribution, it ships that file at/usr/lib/os-releaserather than/etc/os-release, relying on the fallback path mandated by the os-release specification.- Return type:
- extra_platforms.is_cline()[source]¶
Return
Trueif current agent isCLINE.See also
Cline sets the
CLINE_ACTIVEenvironment variable when running.- Return type:
- extra_platforms.is_cloudlinux()[source]¶
Return
Trueif the platform isCLOUDLINUX.- Return type:
- extra_platforms.is_cmd()[source]¶
Return
Trueif current shell isCMD.Hint
Detected on Windows via
cmd.exein the parent process tree, or when thePROMPTenvironment variable is set andPSModulePathis not (to exclude PowerShell).- Return type:
- extra_platforms.is_codebuild()[source]¶
Return
Trueif current CI isCODEBUILD.See also
Environment variables reference: <https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html>.
- Return type:
- extra_platforms.is_codex()[source]¶
Return
Trueif current agent isCODEX.See also
Codex sets the
CODEX_CIenvironment variable when running. The name says CI, but the variable is one entry of theUNIFIED_EXEC_ENVarray Codex applies to every process it spawns, in codex-rs/core/src/unified_exec/process_manager.rs.- Return type:
- extra_platforms.is_copilot_cli()[source]¶
Return
Trueif current agent isCOPILOT_CLI.See also
GitHub Copilot CLI sets the
COPILOT_CLIenvironment variable in its subprocesses, so git hooks can detect it.- Return type:
- extra_platforms.is_crush()[source]¶
Return
Trueif current agent isCRUSH.See also
Crush sets the
CRUSHenvironment variable on every shell it spawns, next toAGENT=crushandAI_AGENT=crush, fromCrushEnvMarkers()in internal/shell/shell.go. The bash tool and the hook runner both apply them.- Return type:
- extra_platforms.is_csh()[source]¶
Return
Trueif current shell isCSH.Hint
Detected via the
SHELLenvironment variable path.- Return type:
- extra_platforms.is_cursor()[source]¶
Return
Trueif current agent isCURSOR.See also
Cursor sets the
CURSOR_AGENTenvironment variable when running.- Return type:
- extra_platforms.is_dash()[source]¶
Return
Trueif current shell isDASH.Hint
Detected via the
SHELLenvironment variable path, as Dash does not set its own version variable.- Return type:
- extra_platforms.is_dragonfly_bsd()[source]¶
Return
Trueif the platform isDRAGONFLY_BSD.- Return type:
- extra_platforms.is_endeavouros()[source]¶
Return
Trueif the platform isENDEAVOUROS.- Return type:
- extra_platforms.is_fish()[source]¶
Return
Trueif current shell isFISH.Hint
Detected via the
FISH_VERSIONenvironment variable (set by Fish on startup), or via theSHELLpath as a fallback.- Return type:
- extra_platforms.is_gemini_cli()[source]¶
Return
Trueif current agent isGEMINI_CLI.See also
Gemini CLI sets the
GEMINI_CLIenvironment variable in the subprocesses it spawns, so scripts can detect it.- Return type:
- extra_platforms.is_generic_linux()[source]¶
Return
Trueif the platform isGENERIC_LINUX.Matches when running on a Linux kernel whose distribution no other platform identifies: a distribution with an
os-releaseID no platform recognizes yet, or a minimal container or build chroot shipping no/etc/os-releaseand reaching nosystemd-hostnamed. This keeps an unrecognized distribution in theLINUXgroup, and in every group built on it.Note
A distribution identified by another marker is no generic Linux, like
SLITAZfrom its/etc/slitaz-releasefile.CHROMEOScounts only through its ownos-releaseID: its Crostini marker also shows inside a container, whose own distribution stays unidentified.- Return type:
- extra_platforms.is_github_ci()[source]¶
Return
Trueif current CI isGITHUB_CI.See also
Environment variables reference: <https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables>.
- Return type:
- extra_platforms.is_gitlab_ci()[source]¶
Return
Trueif current CI isGITLAB_CI.See also
Environment variables reference: <https://docs.gitlab.com/ci/variables/predefined_variables/#predefined-variables>.
- Return type:
- extra_platforms.is_gnome_terminal()[source]¶
Return
TrueinGNOME_TERMINAL.- Return type:
- extra_platforms.is_gnu_screen()[source]¶
Return
Trueif the terminal isGNU_SCREEN.- Return type:
- extra_platforms.is_hermetic_build()[source]¶
Return
Trueif current CI isHERMETIC_BUILD.Note
Keys on
HOME=/homeless-shelter: a non-existent home directory the build daemon assigns so a package build cannot read or write a real home. The value originated in Nix (2003) and was inherited verbatim by GNU Guix, so this matches both, plus Nix-ecosystem wrappers that reuse the sandbox (like devbox). It does not catch hermetic builders that isolateHOMEdifferently, such as Bazel, Buck2 or Spack.Todo
Grow extra signals to recognize the other hermetic builders above, should users ask for it. Only the
/homeless-sheltersignal is checked for now.See also
The Guix build environment, which documents the sentinel: <https://guix.gnu.org/manual/en/html_node/Build-Environment-Setup.html>.
- Return type:
- extra_platforms.is_heroku_ci()[source]¶
Return
Trueif current CI isHEROKU_CI.See also
Environment variables reference: <https://devcenter.heroku.com/articles/heroku-ci#immutable-environment-variables>.
- Return type:
- extra_platforms.is_hurd()[source]¶
Return
Trueif current platform isHURD.Caution
sys.platformcan returnsGNUorgnu0, see: <https://github.com/kdeldycke/extra-platforms/issues/308>- Return type:
- extra_platforms.is_ibm_powerkvm()[source]¶
Return
Trueif the platform isIBM_POWERKVM.- Return type:
- extra_platforms.is_illumos()[source]¶
Return
Trueif current platform isILLUMOS.Hint
Illumos is a Unix OS derived from OpenSolaris. It shares
sys.platform == 'sunos5'with Solaris, but can be distinguished by checkingplatform.uname().versionwhich contains “illumos” on Illumos-based systems (like OpenIndiana, SmartOS, OmniOS).Note
Gates on
sys.platformbefore readingplatform.uname()so the function returns immediately on non-SunOS hosts. This matters on Windows, whereplatform.uname()shells out viaplatform._syscmd_ver()to populate itsversionfield.- Return type:
- extra_platforms.is_ksh()[source]¶
Return
Trueif current shell isKSH.Hint
Detected via the
KSH_VERSIONenvironment variable (set by Korn shell on startup), or via theSHELLpath as a fallback.- Return type:
- extra_platforms.is_loongarch64()[source]¶
Return
TrueonLOONGARCH64.- Return type:
- extra_platforms.is_macos()[source]¶
Return
Trueif current platform isMACOS.Note
Uses
sys.platformrather thanplatform.platform(). The former is a constant baked in by CPython at compile time (always"darwin"on macOS), while the latter performs runtime introspection and, on Windows, shells out viaplatform._syscmd_ver()to invokecmd /c ver. Callingplatform.platform()here would therefore spawn a subprocess on every non-macOS host, and break test suites that globally patchsubprocess.run(). Sincesys.platform == "darwin"is unambiguous for macOS (unlike Solaris vs. SunOS, which both report"sunos5"and genuinely needplatform.platform()to be told apart), there is no reason to pay that cost here.- Return type:
- extra_platforms.is_midnightbsd()[source]¶
Return
Trueif the platform isMIDNIGHTBSD.- Return type:
- extra_platforms.is_nushell()[source]¶
Return
Trueif current shell isNUSHELL.Hint
Detected via the
NU_VERSIONenvironment variable (set by Nushell on startup), or via theSHELLpath as a fallback.- Return type:
- extra_platforms.is_opensuse()[source]¶
Return
Trueif current platform isOPENSUSE.Note
Matches the main
opensuseID as well as anyopensuse-*release channel (Tumbleweed, Leap, Slowroll, MicroOS, …), per the granularity policy documented in theplatform_datamodule. The raw channel ID remains available throughPlatform.info().- Return type:
- extra_platforms.is_oracle()[source]¶
Return
Trueif current platform isORACLE.Note
Oracle Linux sets
ID=olin itsos-releasefile. The platform keeps the more explicitoracleID, mirroring the naming of the distro library.- Return type:
- extra_platforms.is_os400()[source]¶
Return
Trueif current platform isOS400.Note
Detects IBM i (formerly OS/400), whose AIX-compatible PASE runtime hosts Python. Python 3.9+ on IBM i reports
sys.platformasos400rather thanaix(as older versions did), so PASE is distinguished fromAIXdespite their binary compatibility.Note
OS400is grouped underUNIX_LAYERS(besideCYGWIN), notSYSTEM_Vwhere its AIX kin lives. IBM i’s native OS is not Unix: its only Unix surface is the PASE runtime thatos400runs in. The Wikipedia Unix taxonomy that these platform families track classes PASE as a Unix compatibility layer (a peer of Cygwin on Windows), so the trait sits there rather than with its System V binary kin.- Return type:
- extra_platforms.is_pi()[source]¶
Return
Trueif current agent isPI.See also
Pi sets the
PI_CODING_AGENTenvironment variable at startup, next to a genericAI_AGENT=pimarker, in packages/coding-agent/src/cli.ts. Child processes inherit both, but neither is set when Pi is embedded through its SDK.- Return type:
- extra_platforms.is_pikaos()[source]¶
Return
Trueif current platform isPIKAOS.Note
PikaOS, an Ubuntu-based gaming distribution, sets
ID=pika(notpikaos) in itsos-releasefile. ItsID_LIKE=debianfield is ignored, so this stays distinct fromis_debian().- Return type:
- extra_platforms.is_powershell()[source]¶
Return
Trueif current shell isPOWERSHELL.Note
PowerShell is cross-platform and available on Linux and macOS. Detection covers all platforms via
PSModulePath,SHELLpath, and parent process tree.Attention
PSModulePathcan leak into non-PowerShell child processes via two vectors:Process-level inheritance (all platforms): PowerShell modifies
PSModulePathat startup, and all non-PowerShell children inherit it.System-wide registry variable (Windows only):
PSModulePathis a persistent machine-level environment variable visible to all processes.
This is the case for all GitHub Ubuntu runners, where
PSModulePathleaks from Azure infrastructure. This leads to multiple shell detections, which is arbitraged bycurrent_shell(), which deprioritizes PowerShell when other shells are detected.- Return type:
- extra_platforms.is_scientific()[source]¶
Return
Trueif the platform isSCIENTIFIC.- Return type:
- extra_platforms.is_sh()[source]¶
Return
Trueif current shell isSH.Hint
Detected via the
SHELLenvironment variable path, after symlink resolution. Only matches when the resolved shell binary is literallysh, not when/bin/shis a symlink to another shell (like bash or dash).Note
On most modern systems,
/bin/shis a symlink to a concrete shell (bash,dash, etc.). In that case,is_sh()returnsFalseand the concrete shell’s detection function returnsTrueinstead. To test whether the environment provides a Bourne-compatible interface regardless of the underlying implementation, useis_bourne_shells()instead.Important
SHis treated as a low-specificity fallback bycurrent_shell()(likeGENERIC_LINUXfor platforms): when bothSHand a more specific shell are detected,current_shell()returns the specific shell.- Return type:
- extra_platforms.is_slitaz()[source]¶
Return
Trueif current platform isSLITAZ.Note
SliTaz does not ship any
os-releasefile: itsslitaz-base-filespackage only provides/etc/slitaz-release, whose existence is used as the detection marker. The standardos-releasecheck is still performed first, in case future releases adopt the specification.- Return type:
- extra_platforms.is_solaris()[source]¶
Return
Trueif current platform isSOLARIS.Hint
An illumos distribution reports
Solaris-2.11fromplatform.platform(), because it inherits the SunOS 5.11 release string from OpenSolaris. That prefix alone therefore cannot tell Oracle Solaris from its fork, andis_illumos()has to exclude it, or both match at once andcurrent_platform()raises. Measured on OpenIndiana Hipster 2026.04.Note
Gates on
sys.platformbeing"sunos5"before invokingplatform.platform(), which on Windows would shell out viaplatform._syscmd_ver(). Solaris and SunOS share the samesys.platformvalue, soplatform.platform()is still needed to tell them apart, but only when we already know we’re on a SunOS-based host.- Return type:
- extra_platforms.is_sourcemage()[source]¶
Return
Trueif the platform isSOURCEMAGE.- Return type:
- extra_platforms.is_sunos()[source]¶
Return
Trueif current platform isSUNOS.Note
See
is_solaris()for the rationale behind thesys.platformguard.- Return type:
- extra_platforms.is_tcsh()[source]¶
Return
Trueif current shell isTCSH.Hint
Detected via the
SHELLenvironment variable path.- Return type:
- extra_platforms.is_teamcity()[source]¶
Return
Trueif current CI isTEAMCITY.See also
Environment variables reference: <https://www.jetbrains.com/help/teamcity/predefined-build-parameters.html#Predefined+Server+Build+Parameters>.
- Return type:
- extra_platforms.is_travis_ci()[source]¶
Return
Trueif current CI isTRAVIS_CI.See also
Environment variables reference: <https://docs.travis-ci.com/user/environment-variables/#default-environment-variables>.
- Return type:
- extra_platforms.is_ultramarine()[source]¶
Return
Trueif the platform isULTRAMARINE.- Return type:
- extra_platforms.is_unknown_agent()[source]¶
Return
Trueif the agent isUNKNOWN_AGENT.- Return type:
- extra_platforms.is_unknown_architecture()[source]¶
Return
Trueif the architecture is unknown.See
UNKNOWN_ARCHITECTURE.- Return type:
- extra_platforms.is_unknown_ci()[source]¶
Return
Trueif current CI isUNKNOWN_CI.- Return type:
- extra_platforms.is_unknown_platform()[source]¶
Return
Trueif the platform is unknown.See
UNKNOWN_PLATFORM.- Return type:
- extra_platforms.is_unknown_shell()[source]¶
Return
Trueif the shell isUNKNOWN_SHELL.- Return type:
- extra_platforms.is_unknown_terminal()[source]¶
Return
Trueif the terminal is unknown.See
UNKNOWN_TERMINAL.- Return type:
- extra_platforms.is_vscode_terminal()[source]¶
Return
TrueinVSCODE_TERMINAL.- Return type:
- extra_platforms.is_wasm32()[source]¶
Return
Trueif current architecture isWASM32.Hint
WebAssembly detection is based on Emscripten’s platform identifier.
- Return type:
- extra_platforms.is_wasm64()[source]¶
Return
Trueif current architecture isWASM64.Hint
WebAssembly detection is based on Emscripten’s platform identifier.
- Return type:
- extra_platforms.is_webos()[source]¶
Return
Trueif current platform isWEBOS.Note
webOS TV, the edition LG ships on its TVs, sets
ID=starfishin itsos-releasefile:starfishis the name of LG’s TV build. The platform keeps the more explicitwebosID. Captured on an LG OLED77B46LA TV, running webOS TV10.3.2(firmware33.31.75).Todo
Also match the ID of webOS Open Source Edition, once an
os-releasefile captured on it confirms that ID. LG manages both editions, so they share this platform. Its Yocto layer setsDISTRO = "webos"in meta-webos/conf/distro/webos.conf, which suggestsID=webos.- Return type:
- extra_platforms.is_windows_terminal()[source]¶
Return
TrueinWINDOWS_TERMINAL.- Return type:
- extra_platforms.is_wsl1()[source]¶
Return
Trueif current platform isWSL1.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
Note
Gates on
sys.platformbeing"linux"before invokingplatform.release(). WSL is by definition a Linux subsystem, so on any other host the answer is triviallyFalse. The guard also avoids aplatform._syscmd_ver()subprocess on Windows, whereplatform.release()is implemented as acmd /c vershell-out.- Return type:
- extra_platforms.is_wsl2()[source]¶
Return
Trueif current platform isWSL2.Note
See
is_wsl1()for the rationale behind thesys.platformguard.- Return type:
- extra_platforms.is_x86_64()[source]¶
Return
Trueif current architecture isX86_64.Caution
Windows returns
AMD64in uppercase, so we normalize to lowercase.Hint
Solaris and illumos answer
i86pc, which names the machine family rather than the ISA, the same waysun4uandsun4vdo foris_sparc64(). Both keep that string on 64-bit hardware, and neither ships a 32-bit kernel any more. Measured on OpenIndiana Hipster 2026.04.- Return type:
- extra_platforms.is_xonsh()[source]¶
Return
Trueif current shell isXONSH.Hint
Detected via the
XONSH_VERSIONenvironment variable (set by Xonsh on startup), or via theSHELLpath as a fallback.Note
Xonsh runs as a Python script rather than a standalone binary, so the parent process tree shows
pythonrather thanxonsh. When neitherXONSH_VERSIONnorSHELLidentifies it, the tree walk inspects interpreter arguments for thexonshlauncher (seeinterpreter).- Return type:
- extra_platforms.is_xterm()[source]¶
Return
Trueif current terminal isXTERM.Note
We check for
XTERM_VERSIONrather thanTERM=xtermbecause many headless environments, like GitHub Actionsubuntu-slimrunners, setTERM=xtermfor termcap/terminfo compatibility without actually running xterm.- Return type:
Group detection functions¶
Contrary to individual trait detection functions like is_ubuntu() or is_x86_64(), group detection functions check for membership in a collection of traits.
These functions are generated for each group and test whether at least one trait from the group matches the current system. Each one runs the detection functions of its own members and stops at the first match: is_linux() never runs a shell or terminal heuristic.
- extra_platforms.is_any_agent()[source]¶
Return
Trueif at least one member of theALL_AGENTSgroup matches the current environment.- Return type:
- extra_platforms.is_any_architecture()[source]¶
Return
Trueif at least one member of theALL_ARCHITECTURESgroup matches the current environment.- Return type:
- extra_platforms.is_any_arm()[source]¶
Return
Trueif at least one member of theALL_ARMgroup matches the current environment.- Return type:
- extra_platforms.is_any_ci()[source]¶
Return
Trueif at least one member of theALL_CIgroup matches the current environment.- Return type:
- extra_platforms.is_any_mips()[source]¶
Return
Trueif at least one member of theALL_MIPSgroup matches the current environment.- Return type:
- extra_platforms.is_any_platform()[source]¶
Return
Trueif at least one member of theALL_PLATFORMSgroup matches the current environment.- Return type:
- extra_platforms.is_any_shell()[source]¶
Return
Trueif at least one member of theALL_SHELLSgroup matches the current environment.- Return type:
- extra_platforms.is_any_sparc()[source]¶
Return
Trueif at least one member of theALL_SPARCgroup matches the current environment.- Return type:
- extra_platforms.is_any_terminal()[source]¶
Return
Trueif at least one member of theALL_TERMINALSgroup matches the current environment.- Return type:
- extra_platforms.is_any_trait()[source]¶
Return
Trueif at least one member of theALL_TRAITSgroup matches the current environment.- Return type:
- extra_platforms.is_any_windows()[source]¶
Return
Trueif at least one member of theALL_WINDOWSgroup matches the current environment.- Return type:
- extra_platforms.is_arch_32_bit()[source]¶
Return
Trueif at least one member of theARCH_32_BITgroup matches the current environment.- Return type:
- extra_platforms.is_arch_64_bit()[source]¶
Return
Trueif at least one member of theARCH_64_BITgroup matches the current environment.- Return type:
- extra_platforms.is_big_endian()[source]¶
Return
Trueif at least one member of theBIG_ENDIANgroup matches the current environment.- Return type:
- extra_platforms.is_bourne_shells()[source]¶
Return
Trueif at least one member of theBOURNE_SHELLSgroup matches the current environment.- Return type:
- extra_platforms.is_bsd()[source]¶
Return
Trueif at least one member of theBSDgroup matches the current environment.- Return type:
- extra_platforms.is_bsd_not_macos()[source]¶
Return
Trueif at least one member of theBSD_WITHOUT_MACOSgroup matches the current environment.- Return type:
- extra_platforms.is_c_shells()[source]¶
Return
Trueif at least one member of theC_SHELLSgroup matches the current environment.- Return type:
- extra_platforms.is_gpu_terminals()[source]¶
Return
Trueif at least one member of theGPU_TERMINALSgroup matches the current environment.- Return type:
- extra_platforms.is_ibm_mainframe()[source]¶
Return
Trueif at least one member of theIBM_MAINFRAMEgroup matches the current environment.- Return type:
- extra_platforms.is_linux()[source]¶
Return
Trueif at least one member of theLINUXgroup matches the current environment.- Return type:
- extra_platforms.is_linux_layers()[source]¶
Return
Trueif at least one member of theLINUX_LAYERSgroup matches the current environment.- Return type:
- extra_platforms.is_linux_like()[source]¶
Return
Trueif at least one member of theLINUX_LIKEgroup matches the current environment.- Return type:
- extra_platforms.is_little_endian()[source]¶
Return
Trueif at least one member of theLITTLE_ENDIANgroup matches the current environment.- Return type:
- extra_platforms.is_loongarch()[source]¶
Return
Trueif at least one member of theLOONGARCHgroup matches the current environment.- Return type:
- extra_platforms.is_multiplexers()[source]¶
Return
Trueif at least one member of theMULTIPLEXERSgroup matches the current environment.- Return type:
- extra_platforms.is_native_terminals()[source]¶
Return
Trueif at least one member of theNATIVE_TERMINALSgroup matches the current environment.- Return type:
- extra_platforms.is_other_posix()[source]¶
Return
Trueif at least one member of theOTHER_POSIXgroup matches the current environment.- Return type:
- extra_platforms.is_other_shells()[source]¶
Return
Trueif at least one member of theOTHER_SHELLSgroup matches the current environment.- Return type:
- extra_platforms.is_powerpc()[source]¶
Return
Trueif at least one member of thePOWERPCgroup matches the current environment.- Return type:
- extra_platforms.is_riscv()[source]¶
Return
Trueif at least one member of theRISCVgroup matches the current environment.- Return type:
- extra_platforms.is_system_v()[source]¶
Return
Trueif at least one member of theSYSTEM_Vgroup matches the current environment.- Return type:
- extra_platforms.is_unix()[source]¶
Return
Trueif at least one member of theUNIXgroup matches the current environment.- Return type:
- extra_platforms.is_unix_layers()[source]¶
Return
Trueif at least one member of theUNIX_LAYERSgroup matches the current environment.- Return type:
- extra_platforms.is_unix_not_macos()[source]¶
Return
Trueif at least one member of theUNIX_WITHOUT_MACOSgroup matches the current environment.- Return type:
- extra_platforms.is_unknown()[source]¶
Return
Trueif at least one member of theUNKNOWNgroup matches the current environment.- Return type:
- extra_platforms.is_web_terminals()[source]¶
Return
Trueif at least one member of theWEB_TERMINALSgroup matches the current environment.- Return type:
- extra_platforms.is_webassembly()[source]¶
Return
Trueif at least one member of theWEBASSEMBLYgroup matches the current environment.- Return type:
- extra_platforms.is_windows_shells()[source]¶
Return
Trueif at least one member of theWINDOWS_SHELLSgroup matches the current environment.- Return type:
Current trait functions¶
current_traits() returns all detectable traits (multiple per type are possible). The individual current_*() functions return the single primary trait per type, after disambiguation. machine_architecture() returns the architecture of the machine, which can differ from current_architecture(): see Interpreter and machine.
- extra_platforms.current_traits()[source]¶
Returns all traits matching the current environment.
This includes
Architecture,Platform,Shell,Terminal,CIsystems, andAgentenvironments.Caution
Never returns
UNKNOWNtraits.Raises
SystemErrorif the current environment is not recognized at all.Important
This function returns all detectable traits, not the disambiguated primary trait per category. Multiple shells, platforms, or other traits may appear in the result (for example, both
BASHandPOWERSHELLon GitHub Ubuntu runners wherePSModulePathleaks from Azure).Use the individual
current_*()functions (current_shell(),current_platform(), etc.) to get the single best match per trait type.Attention
At this point it is too late to worry about caching. This function has no choice but to evaluate all detection heuristics.
- extra_platforms.current_architecture(strict=False)[source]¶
Return the
Architecturethe Python interpreter runs as.This is the architecture the detection functions, the groups and the
pytestdecorators all follow. A 32-bit Python on a 64-bit ARM kernel isARMV8L, and inARCH_32_BIT. The architecture of the machine itself comes frommachine_architecture().Returns
UNKNOWN_ARCHITECTUREif not running inside a recognized architecture. To raise an error instead, setstricttoTrue.Important
Always raises an error if multiple architectures match.
Warning
An architecture is always expected to be detected. An unrecognized result logs a
WARNINGand likely indicates a missing detection heuristic that should be reported.Todo
Also rename the machine of a 32-bit interpreter on a 64-bit PowerPC, SPARC, MIPS or RISC-V kernel, once a measured host gives the name its kernel reports to a 32-bit process. Only ARM and x86 get a name for now.
- Return type:
- extra_platforms.machine_architecture(strict=False)[source]¶
Return the
Architectureof the machine.This is the architecture the operating system reports, from
platform.machine(). It differs fromcurrent_architecture()only on a 64-bit ARM or x86 machine, for an interpreter that is narrower or emulated:a 32-bit Python on a 64-bit Linux kernel, like the one of LG’s webOS TVs,
a 32-bit Python on 64-bit Windows,
an x64 Python emulated on Windows for ARM.
Everywhere else, it returns
current_architecture(), with the samestrictbehavior.Caution
The machine architecture is what the kernel runs, not what the system can load. A 64-bit kernel with a 32-bit userland, like the one of LG’s webOS TVs, runs a static 64-bit binary, but lacks the loader and libraries that a dynamically linked one needs.
Todo
Read the CPU under Rosetta 2 on macOS, where
platform.machinereports the translated architecture, once a measured host shows how.- Return type:
- extra_platforms.current_platform(strict=False)[source]¶
Return the best matching
Platform, always.Returns
UNKNOWN_PLATFORMif not running inside a recognized platform. To raise an error instead, setstricttoTrue.Note
When
sys.platformislinux, the result is neverUNKNOWN_PLATFORM. A distribution that no platform recognizes givesGENERIC_LINUX, and logs a warning that asks for a report. Instrictmode, an unrecognizedos-releaseID raises an error instead.Important
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.
Warning
A platform is always expected to be detected. An unrecognized result logs a
WARNINGand likely indicates a missing detection heuristic that should be reported.- Return type:
- extra_platforms.current_shell(strict=False)[source]¶
Returns the
Shellmatching the current environment.Uses a tiered disambiguation strategy with cached signals shared with
_detect_shell():Shell-specific environment variables (strongest: the Python process is the shell).
Parent process tree, read from
/procon Linux orpson macOS, the BSDs and illumos (strong: the shell is an ancestor process actively running). When shells nest, the nearest ancestor wins.SHELLenvironment variable resolved through symlinks (weak: configured login shell, may differ from the active shell).
SHis treated as a low-specificity fallback (likeGENERIC_LINUXfor platforms): on modern systems/bin/shis almost always a symlink to a concrete shell, soSHis stripped when a more specific shell is also detected.Returns
UNKNOWN_SHELLif not running inside a recognized shell. To raise an error instead, setstricttoTrue.Important
If both
POWERSHELLand another shell are detected (becausePSModulePathleaks into child processes), the other shell is preferred.Note
This returns the single primary shell, after disambiguation.
current_traits()may include additional shells that are detectable but not primary (likePOWERSHELLon GitHub Ubuntu runners).Warning
A shell is always expected to be detected. An unrecognized result logs a
WARNINGand likely indicates a missing detection heuristic that should be reported.See also
Inspired by UV’s cross-platform shell detection.
- Return type:
- extra_platforms.current_shell_path()[source]¶
Returns the executable path of the current shell, or
None.Resolution order:
The actual running shell binary, taken from the nearest ancestor in the parent process tree that matches
current_shell()(read from/procon Linux,pson macOS, the BSDs and illumos). This is the true interpreter, even whenSHELLis unset or points elsewhere.The
SHELLenvironment variable (the configured login shell), as a fallback, when it names the same shell ascurrent_shell().
Returns
Nonewhen neither is available: no recognized shell, a stripped environment withoutSHELL, or aSHELLnaming another shell.Note
On some BSDs,
psreports only the bareargv[0]rather than a full path. The non-absolute name is discarded, so this falls back toSHELLthere. illumos and Solaris get the path from procfs instead (seeextra_platforms._process_tree).See also
Comparable to shellingham’s
detect_shell(), which returns the shell name paired with its path. Here the name iscurrent_shell()and the path is this function.
- extra_platforms.current_terminal(strict=False)[source]¶
Returns the
Terminalmatching the current environment.Returns
UNKNOWN_TERMINALif not running inside a recognized terminal. To raise an error instead, setstricttoTrue.Important
If multiple terminals match (like
TMUXinsideKITTY), multiplexers are filtered out first to report the terminal emulator hosting the session. If multiple non-multiplexer terminals still match, aRuntimeErroris raised.Note
Unlike architectures, platforms, and shells, a terminal is not always present. Headless environments (CI runners, cron jobs, Docker containers, SSH non-interactive commands) have no terminal emulator attached.
If the
TERMenvironment variable names a terminal type, an unrecognized terminal logs atWARNINGlevel, as it suggests a terminal emulator is present but not recognized. Otherwise, it logs atINFOlevel:TERMis unset, or declares a dumb terminal (see_DUMB_TERMS). An SSH session also logs atINFO: its emulator runs on the client, out of reach of any heuristic on the remote end.- Return type:
- extra_platforms.current_ci(strict=False)[source]¶
Returns the
CIsystem matching the current environment.Returns
UNKNOWN_CIif not running inside a recognized CI system. To raise an error instead, setstricttoTrue.Important
Always raises an error if multiple CI systems match.
Note
Unlike architectures, platforms, and shells, a CI system is not always present. Local development environments have no CI system running.
If the
CIenvironment variable is set, an unrecognized CI system logs atWARNINGlevel, as it suggests a CI system is present but not recognized. Otherwise, it logs atINFOlevel.- Return type:
- extra_platforms.current_agent(strict=False)[source]¶
Returns the
Agentmatching the current environment.Returns
UNKNOWN_AGENTif not running inside a recognized agent. To raise an error instead, setstricttoTrue.Important
Always raises an error if multiple agents match.
Note
Unlike architectures, platforms, and shells, an agent is not always present. Local development without AI agents has no agent running.
If any variable of
_AGENT_PRESENCE_ENV_VARSis set, an unrecognized agent logs atWARNINGlevel, as it suggests an AI agent is present but not recognized. Otherwise, it logs atINFOlevel.- Return type:
Cache management¶
- extra_platforms.invalidate_caches()[source]¶
Invalidate every cached detection result.
Inspired by platform.invalidate_caches(), which is also called here on Python 3.14 and newer.
- Return type: