From e4d216be27b3692d4cda4d06b46fad34d855cda2 Mon Sep 17 00:00:00 2001 From: poly000 <34085039+poly000@users.noreply.github.com> Date: Wed, 24 Jan 2024 05:05:18 +0800 Subject: [PATCH] Update feeluown/plugin.py Co-authored-by: Shaowen Yin --- feeluown/plugin.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/feeluown/plugin.py b/feeluown/plugin.py index a1874320f4..e7e358775e 100644 --- a/feeluown/plugin.py +++ b/feeluown/plugin.py @@ -201,9 +201,13 @@ def _scan_entry_points(self): https://packaging.python.org/guides/creating-and-discovering-plugins/ """ try: - import importlib_metadata # pylint: disable=redefined-outer-name - entry_points = importlib_metadata.entry_points() \ - .select(group='fuo.plugins_v1') + import importlib.metadata # pylint: disable=redefined-outer-name + try: + entry_points = importlib.metadata.entry_points() \ + .select(group='fuo.plugins_v1') + except AttributeError: # old version does not has `select` method + entry_points = importlib.metadata.entry_points() \ + .get('fuo.plugins_v1', []) except ImportError: import pkg_resources entry_points = pkg_resources.iter_entry_points('fuo.plugins_v1')