diff options
Diffstat (limited to 'Lib/test/support/__init__.py')
-rw-r--r-- | Lib/test/support/__init__.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index 37a69fd..b9ccf7b 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -3015,3 +3015,22 @@ def is_libssl_fips_mode(): except ImportError: return False # more of a maybe, unless we add this to the _ssl module. return get_fips_mode() != 0 + + +def linked_to_musl(): + """ + Test if the Python executable is linked to the musl C library. + """ + if sys.platform != 'linux': + return False + + import subprocess + exe = getattr(sys, '_base_executable', sys.executable) + cmd = ['ldd', exe] + try: + stdout = subprocess.check_output(cmd, + text=True, + stderr=subprocess.STDOUT) + except (OSError, subprocess.CalledProcessError): + return False + return ('musl' in stdout) |