From ff350594c3bfdd1e70561d1b418560962321beb9 Mon Sep 17 00:00:00 2001 From: Ian Hurst Date: Wed, 30 Oct 2024 18:32:11 +0000 Subject: [PATCH] Ignore extension suffixes if the interpreter is Python 2 --- rpm/__init__.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/rpm/__init__.py b/rpm/__init__.py index 64f346f..c986611 100644 --- a/rpm/__init__.py +++ b/rpm/__init__.py @@ -38,15 +38,20 @@ def get_system_sitepackages_and_suffixes() -> List[Dict[str, List[str]]]: def get_sitepackages_and_suffixes(interpreter): script = textwrap.dedent( """ - import importlib - import importlib.machinery import json import site + + try: + import importlib.machinery + except ImportError: + suffixes = [] + else: + suffixes = importlib.machinery.EXTENSION_SUFFIXES print( json.dumps( { "sitepackages": site.getsitepackages(), - "suffixes": importlib.machinery.EXTENSION_SUFFIXES, + "suffixes": suffixes, } ) )