diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4597fbb..1314b65 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,7 +16,7 @@ jobs: #- '3.8' # oldest supported Py3 gha #- '3.9' # newest passing Py3, reason: pyyaml binaries - '3.11' # newest passing Py3, reason: pyyaml binaries - #- '3' # newest supported Py3 + - '3' # newest supported Py3 name: Python ${{ matrix.python-version }} steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it diff --git a/customblocks/entrypoints.py b/customblocks/entrypoints.py index 19c0b98..2add47e 100644 --- a/customblocks/entrypoints.py +++ b/customblocks/entrypoints.py @@ -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) ) - - - - +