Skip to content

Commit

Permalink
Use 'selectable' interface for entry points only when available
Browse files Browse the repository at this point in the history
This reverts commit 17caadc.
  • Loading branch information
hroncok committed Dec 9, 2021
1 parent f92eda6 commit b4ee383
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
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 = None
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

0 comments on commit b4ee383

Please sign in to comment.