From ec16ecdd7aa3fe69ef5b51fa98cd9890a08db629 Mon Sep 17 00:00:00 2001 From: Capypara Date: Sun, 30 Jul 2023 17:37:17 +0200 Subject: [PATCH] Fix Python 3.9 compatibility --- requirements-mac-windows.txt | 2 +- requirements.txt | 2 +- setup.py | 2 +- skytemple/core/modules.py | 7 ++++--- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/requirements-mac-windows.txt b/requirements-mac-windows.txt index 1a457e08a..90473c1e9 100644 --- a/requirements-mac-windows.txt +++ b/requirements-mac-windows.txt @@ -18,4 +18,4 @@ psutil==5.9.5 sentry-sdk==1.22.1 cairocffi<=1.5.1 # https://github.com/Kozea/cairocffi/issues/217 packaging -importlib_metadata>=1.3; python_version < "3.9" +importlib_metadata>=4.6; python_version < "3.10" diff --git a/requirements.txt b/requirements.txt index 96ea3dea6..482dfa7af 100644 --- a/requirements.txt +++ b/requirements.txt @@ -18,4 +18,4 @@ psutil==5.9.5 sentry-sdk==1.22.1 packaging types-setuptools -importlib_metadata>=1.3; python_version < "3.9" +importlib_metadata>=4.6; python_version < "3.10" diff --git a/setup.py b/setup.py index c3f0ed6c5..63eac8be3 100644 --- a/setup.py +++ b/setup.py @@ -80,7 +80,7 @@ def recursive_pkg_files_in(xpath): 'psutil >= 5.9.0', 'sentry-sdk >= 1.5', 'packaging', - 'importlib_metadata>=1.3; python_version < "3.9"' + 'importlib_metadata>=4.6; python_version < "3.10"' ], extras_require={ 'discord': ["pypresence >= 4.2.1"], diff --git a/skytemple/core/modules.py b/skytemple/core/modules.py index ba4824217..da6223353 100644 --- a/skytemple/core/modules.py +++ b/skytemple/core/modules.py @@ -19,11 +19,11 @@ import sys import logging -from typing import TYPE_CHECKING, Type +from typing import TYPE_CHECKING, Type, Iterable from typing import Dict -if sys.version_info >= (3, 9): +if sys.version_info >= (3, 10): import importlib.metadata as importlib_metadata else: import importlib_metadata @@ -41,12 +41,13 @@ class Modules: @classmethod def load(cls): # Look up package entrypoints for modules + cls._modules = {} try: cls._modules = { entry_point.name: entry_point.load() for entry_point in importlib_metadata.entry_points().select(group=MODULE_ENTRYPOINT_KEY) } - except BaseException as ex: + except Exception as ex: logger.warning("Failed loading modules.", exc_info=ex) if len(cls._modules) < 1: