diff --git a/src/prisma/binaries/platform.py b/src/prisma/binaries/platform.py index 62789631d..74020a9a4 100644 --- a/src/prisma/binaries/platform.py +++ b/src/prisma/binaries/platform.py @@ -32,15 +32,12 @@ def linux_distro() -> str: def _get_linux_distro_details() -> Tuple[str, str]: - process = subprocess.run(['cat', '/etc/os-release'], stdout=subprocess.PIPE, check=True) - output = str(process.stdout, sys.getdefaultencoding()) - - match = re.search(r'ID="?([^"\n]*)"?', output) - distro_id = match.group(1) if match else '' - - match = re.search(r'ID_LIKE="?([^"\n]*)"?', output) - distro_id_like = match.group(1) if match else '' - return distro_id, distro_id_like + if hasattr(platform, 'freedesktop_os_release'): + # For python >= 3.10 + distro = platform.freedesktop_os_release() + else: + distro = platform.linux_distribution() + return distro.get('ID', ''), distro.get('ID_LIKE', '') @lru_cache(maxsize=None)