1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
#!/usr/bin/env python3
# --------------------( LICENSE )--------------------
# Copyright (c) 2014-2025 Beartype authors.
# See "LICENSE" for further details.
'''
Project-wide **platform tester** (i.e., functions detecting the current
platform the active Python interpreter is running under) utilities.
This private submodule is *not* intended for importation by downstream callers.
'''
# ....................{ IMPORTS }....................
from beartype._util.cache.utilcachecall import callable_cached
from platform import system as platform_system
from sys import platform as sys_platform
# ....................{ TESTERS }....................
@callable_cached
def is_os_linux() -> bool:
'''
:data:`True` only if the current platform is a **Linux distribution.**
This tester is memoized for efficiency.
'''
return platform_system() == 'Linux'
@callable_cached
def is_os_macos() -> bool:
'''
:data:`True` only if the current platform is **Apple macOS**, the operating
system previously known as "OS X."
This tester is memoized for efficiency.
'''
return platform_system() == 'Darwin'
@callable_cached
def is_os_windows_vanilla() -> bool:
'''
:data:`True` only if the current platform is **vanilla Microsoft Windows**
(i.e., *not* running the Cygwin POSIX compatibility layer).
This tester is memoized for efficiency.
'''
return sys_platform == 'win32'
|