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
Trueif current terminal isAPPLE_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_armv5tel()[source]ยถ
Return
Trueif current architecture isARMV5TEL.- 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. On BusyBox-based systems (ALPINE,OPENWRT),$SHELLtypically resolves to/bin/ash, so BusyBox environments are 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_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://cirrus-ci.org/guide/writing-tasks/#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_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 current platform isCLOUDLINUX.- Return type:
- extra_platforms.is_cmd()[source]ยถ
Return
Trueif current shell isCMD.Hint
Detected on Windows when the
PROMPTenvironment 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_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 current platform isDRAGONFLY_BSD.- 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_generic_linux()[source]ยถ
Return
Trueif current platform isGENERIC_LINUX.Matches when running on a Linux kernel but
distrocannot identify the specific distribution (like minimal containers or build chroots without/etc/os-release).- 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
Trueif current terminal isGNOME_TERMINAL.- Return type:
- extra_platforms.is_gnu_screen()[source]ยถ
Return
Trueif current terminal isGNU_SCREEN.- Return type:
- extra_platforms.is_guix_build()[source]ยถ
Return
Trueif current CI isGUIX_BUILD.Note
The Guix build daemon runs packages in an isolated sandbox with
HOMEset to/homeless-shelter(a non-existent directory). This prevents builds from reading or writing to a real home directory.See also
Build environment reference: <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 current 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
Trueif current architecture isLOONGARCH64.- 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 current platform isMIDNIGHTBSD.- Return type:
- extra_platforms.is_mips64el()[source]ยถ
Return
Trueif current architecture isMIPS64EL.- 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_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 current 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_solaris()[source]ยถ
Return
Trueif current platform isSOLARIS.Note
Gates on
sys.platform == "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_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_tumbleweed()[source]ยถ
Return
Trueif current platform isTUMBLEWEED.- Return type:
- extra_platforms.is_ultramarine()[source]ยถ
Return
Trueif current platform isULTRAMARINE.- Return type:
- extra_platforms.is_unknown_agent()[source]ยถ
Return
Trueif current agent isUNKNOWN_AGENT.- Return type:
- extra_platforms.is_unknown_architecture()[source]ยถ
Return
Trueif current architecture isUNKNOWN_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 current platform isUNKNOWN_PLATFORM.- Return type:
- extra_platforms.is_unknown_shell()[source]ยถ
Return
Trueif current shell isUNKNOWN_SHELL.- Return type:
- extra_platforms.is_unknown_terminal()[source]ยถ
Return
Trueif current terminal isUNKNOWN_TERMINAL.- Return type:
- extra_platforms.is_vscode_terminal()[source]ยถ
Return
Trueif current terminal isVSCODE_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_windows_terminal()[source]ยถ
Return
Trueif current terminal isWINDOWS_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.platform == "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.- 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.- Return type:
- extra_platforms.is_xterm()[source]ยถ
Return
Trueif current terminal isXTERM.Note
We check for
XTERM_VERSIONrather thanTERM=xtermbecause many headless environments (e.g., 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_linux() or is_x86_64(), group detection functions check for membership in a collection of traits.
These functions are dynamically generated for each group and test whether at least one trait from the group matches the current system:
- extra_platforms.is_any_agent(_group=Group(id='all_agents', name='AI coding agents'))[source]ยถ
Return
Trueif at least onecurrent_traits()is found in theALL_AGENTSgroup.- 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:
- 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]ยถ
Returns the
Architecturematching the current environment.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.- Return type:
- extra_platforms.current_platform(strict=False)[source]ยถ
Always returns the best matching
Platformfor the current environment.Returns
UNKNOWN_PLATFORMif not running inside a recognized platform. To raise an error instead, setstricttoTrue.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).
/procparent process tree (strong: the shell is an ancestor process actively running).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_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 (e.g.,
TMUXinsideKITTY), multiplexers are filtered out first to identify the innermost terminal. 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 is set, an unrecognized terminal logs atWARNINGlevel, as it suggests a terminal emulator is present but not recognized. Otherwise, it logs atINFOlevel.- 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 the
LLMenvironment variable is 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 all cached properties.
Inspired by the new platform.invalidate_caches() from Python 3.14, which is also called here when available.