summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiro HronĨok <miro@hroncok.cz>2021-12-27 12:01:35 +0100
committerGitHub <noreply@github.com>2021-12-27 11:01:35 +0000
commitbb82a73b6dbf577874f6d4bfaf72d2a7f59dfffe (patch)
tree96c0cbf87efeebaa7ca9077def4e64abc33fef07
parent12a1fc2860761a9cd47c88a24093455d121570a3 (diff)
downloadvirtualenv-bb82a73b6dbf577874f6d4bfaf72d2a7f59dfffe.tar.gz
Use 'selectable' interface for entry points only when available (#2246)
-rw-r--r--docs/changelog/2246.feature.rst1
-rw-r--r--setup.cfg1
-rw-r--r--src/virtualenv/run/plugin/base.py15
3 files changed, 14 insertions, 3 deletions
diff --git a/docs/changelog/2246.feature.rst b/docs/changelog/2246.feature.rst
new file mode 100644
index 0000000..4be877d
--- /dev/null
+++ b/docs/changelog/2246.feature.rst
@@ -0,0 +1 @@
+Drop the runtime dependency of ``backports.entry-points-selectable`` - by :user:`hroncok`.
diff --git a/setup.cfg b/setup.cfg
index 2b48a54..1ab1dfc 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -40,7 +40,6 @@ project_urls =
[options]
packages = find:
install_requires =
- backports.entry-points-selectable>=1.0.4
distlib>=0.3.1,<1
filelock>=3.2,<4
platformdirs>=2,<3
diff --git a/src/virtualenv/run/plugin/base.py b/src/virtualenv/run/plugin/base.py
index f1f4ee0..048c76a 100644
--- a/src/virtualenv/run/plugin/base.py
+++ b/src/virtualenv/run/plugin/base.py
@@ -1,8 +1,16 @@
from __future__ import absolute_import, unicode_literals
+import sys
from collections import OrderedDict
-from backports.entry_points_selectable import entry_points
+if sys.version_info >= (3, 8):
+ from importlib.metadata import entry_points
+
+ importlib_metadata_version = ()
+else:
+ from importlib_metadata import entry_points, version
+
+ importlib_metadata_version = tuple(int(i) for i in version("importlib_metadata").split(".")[:2])
class PluginLoader(object):
@@ -11,7 +19,10 @@ class PluginLoader(object):
@classmethod
def entry_points_for(cls, key):
- return OrderedDict((e.name, e.load()) for e in cls.entry_points().select(group=key))
+ if sys.version_info >= (3, 10) or importlib_metadata_version >= (3, 6):
+ return OrderedDict((e.name, e.load()) for e in cls.entry_points().select(group=key))
+ else:
+ return OrderedDict((e.name, e.load()) for e in cls.entry_points().get(key, {}))
@staticmethod
def entry_points():