-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
29 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,35 @@ | ||
import sys | ||
|
||
def load_entry_points(group): | ||
# The api that allows selecting groups more easily | ||
# is not available in Py3.9 and earlier. | ||
# The api that allows selecting groups more easily | ||
# is not available in Py3.9 and earlier. | ||
|
||
def iter_entry_points_group__pkg_resources(group): | ||
""" This is the old version, everyone loved, or not | ||
but now is deprecated in setuptools. It worked | ||
in Py2.7 and older Py3 | ||
""" | ||
|
||
from pkg_resources import entry_points | ||
for entry in entry_points(group=group): | ||
yield entry | ||
|
||
def iter_entry_points_group__importlib_selectable(group): | ||
""" This is the brand new api that does not | ||
work in all still supported Py3 versions.""" | ||
|
||
from importlib.metadata import entry_points | ||
for entry in entry_points(group=group): | ||
yield entry | ||
|
||
def iter_entry_points(group): | ||
if sys.version_info < (3,0): | ||
return iter_entry_points_group__pkg_resources(group) | ||
return iter_entry_points_group__importlib_selectable(group) | ||
|
||
def load_entry_points(group): | ||
return dict( | ||
(entry.name, entry.load()) | ||
for entry in entry_points() | ||
if entry.group == group | ||
for entry in iter_entry_points(group) | ||
) | ||
|
||
|
||
|
||
|
||
|
||
|