backports.entry_points_selectable is a compatibility shim that provides selectable entry points, specifically designed to ease the adoption of `importlib.metadata` 3.6+. It enables 'selectable' entry points (passing keyword arguments to `entry_points()` or invoking `.select()` on the result) even on older Python versions (prior to 3.10) or when `importlib_metadata` is older than 3.6. The current version is 1.3.0, and it receives updates as needed to maintain compatibility.
pip install backports-entry-points-selectableVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to import and use the `entry_points` function provided by `backports.entry_points_selectable`. It shows how to retrieve entry points by group and how to find a specific entry point by both group and name, utilizing the 'selectable' interface. This is the primary functionality backported by the library.
On Python 3.10 and newer, remove `backports-entry-points-selectable` from your dependencies and import `entry_points` directly from `importlib.metadata`. For example, replace `from backports.entry_points_selectable import entry_points` with `from importlib.metadata import entry_points`.
Always use the 'selectable' interface by passing keyword arguments directly to `entry_points()` (e.g., `entry_points(group='console_scripts')`) or by calling the `.select()` method on the returned `EntryPoints` object for explicit filtering.
If supporting Python < 3.8 and using other `importlib.metadata` APIs, ensure `importlib_metadata` is also a dependency in your project. For example: `install_requires = ['importlib_metadata; python_version < "3.8"', 'backports-entry-points-selectable']`.
Install the package using pip: `pip install backports.entry-points-selectable`
Ensure `backports.entry_points_selectable` is installed and then import `entry_points` from it: `from backports.entry_points_selectable import entry_points`.
Update your code to use the `select` method or keyword arguments for `entry_points`, for example: `entry_points().select(group='group_name')` or `entry_points(group='group_name').