Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use 'selectable' interface for entry points only when available #2246

Merged
merged 1 commit into from
Dec 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changelog/2246.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Drop the runtime dependency of ``backports.entry-points-selectable`` - by :user:`hroncok`.
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 13 additions & 2 deletions src/virtualenv/run/plugin/base.py
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -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():
Expand Down