Detect whether the current Linux system uses musl libc (e.g. Alpine).
()
| 38 | |
| 39 | |
| 40 | def _is_musl() -> bool: |
| 41 | """Detect whether the current Linux system uses musl libc (e.g. Alpine).""" |
| 42 | if sys.platform != "linux": |
| 43 | return False |
| 44 | try: |
| 45 | import subprocess |
| 46 | |
| 47 | result = subprocess.run(["ldd", "--version"], capture_output=True, text=True, timeout=5) |
| 48 | # musl's ldd prints "musl libc" in its output |
| 49 | output = result.stdout + result.stderr |
| 50 | return "musl" in output.lower() |
| 51 | except (FileNotFoundError, subprocess.TimeoutExpired, OSError): |
| 52 | return False |
| 53 | |
| 54 | |
| 55 | def get_platform_key() -> tuple[str, str]: |
no test coverage detected
searching dependent graphs…