From 308ec75ce55a9feac2cc2a11efe41765181526c0 Mon Sep 17 00:00:00 2001 From: Kevin Deldycke Date: Wed, 18 Sep 2024 18:58:48 +0200 Subject: [PATCH] Fix detection heuristics for Linux, closes #72 --- changelog.md | 2 ++ extra_platforms/detection.py | 11 ++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/changelog.md b/changelog.md index a169986d..d5518172 100644 --- a/changelog.md +++ b/changelog.md @@ -5,6 +5,8 @@ > [!IMPORTANT] > This version is not released yet and is under active development. +- Fix conflicting detection heuristics for Linux distributions. Closes #72. + ## [1.3.0 (2024-09-11)](https://github.com/kdeldycke/extra-platforms/compare/v1.2.1...v1.3.0) - Add detection of all versions of macOS and Windows. Closes #55. diff --git a/extra_platforms/detection.py b/extra_platforms/detection.py index f7a9197b..83091e54 100644 --- a/extra_platforms/detection.py +++ b/extra_platforms/detection.py @@ -37,6 +37,7 @@ from __future__ import annotations +import logging import platform import sys from os import environ @@ -284,9 +285,13 @@ def is_unknown_linux() -> bool: Excludes WSL1 and WSL2 from this check to `avoid false positives `_. """ - return sys.platform.startswith("linux") and not ( - is_ubuntu() or is_wsl1() or is_wsl2() - ) + unknown_linux = sys.platform.startswith("linux") and not (is_wsl1() or is_wsl2()) + if unknown_linux: + logging.warning( + f"Unknow Linux detected: {distro.info()!r}. You can report this warning to" + " the extra-platforms project to improve detection heuristics." + ) + return unknown_linux @cache