From 17caadc974cb2a24f70374525596cd1160579594 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 9 Jul 2021 11:30:40 -0400 Subject: [PATCH] Rely on 'selectable' interface for entry points. (#2126) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- docs/changelog/2093.misc.rst | 1 + setup.cfg | 1 + src/virtualenv/run/plugin/base.py | 8 ++------ 3 files changed, 4 insertions(+), 6 deletions(-) create mode 100644 docs/changelog/2093.misc.rst diff --git a/docs/changelog/2093.misc.rst b/docs/changelog/2093.misc.rst new file mode 100644 index 000000000..c713d6ad5 --- /dev/null +++ b/docs/changelog/2093.misc.rst @@ -0,0 +1 @@ +Plugins now use 'selectable' entry points. diff --git a/setup.cfg b/setup.cfg index 1419844c4..5b845d565 100644 --- a/setup.cfg +++ b/setup.cfg @@ -41,6 +41,7 @@ project_urls = packages = find: install_requires = appdirs>=1.4.3,<2 + backports.entry_points_selectable>=1.0.4 distlib>=0.3.1,<1 filelock>=3.0.0,<4 six>=1.9.0,<2 # keep it >=1.9.0 as it may cause problems on LTS platforms diff --git a/src/virtualenv/run/plugin/base.py b/src/virtualenv/run/plugin/base.py index ed10fe0e2..f1f4ee061 100644 --- a/src/virtualenv/run/plugin/base.py +++ b/src/virtualenv/run/plugin/base.py @@ -1,12 +1,8 @@ from __future__ import absolute_import, unicode_literals -import sys from collections import OrderedDict -if sys.version_info >= (3, 8): - from importlib.metadata import entry_points -else: - from importlib_metadata import entry_points +from backports.entry_points_selectable import entry_points class PluginLoader(object): @@ -15,7 +11,7 @@ class PluginLoader(object): @classmethod def entry_points_for(cls, key): - return OrderedDict((e.name, e.load()) for e in cls.entry_points().get(key, {})) + return OrderedDict((e.name, e.load()) for e in cls.entry_points().select(group=key)) @staticmethod def entry_points():