{"id":6539,"library":"backports-entry-points-selectable","title":"Backports Entry Points Selectable","description":"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.","status":"active","version":"1.3.0","language":"en","source_language":"en","source_url":"https://github.com/jaraco/backports.entry_points_selectable","tags":["backport","entry-points","compatibility","importlib.metadata","metadata"],"install":[{"cmd":"pip install backports-entry-points-selectable","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Provides foundational `importlib.metadata` APIs on Python versions older than 3.8, or older versions of `importlib.metadata` in 3.8/3.9 that lack selectable entry points. This shim relies on it but also wraps its `entry_points` function for compatibility. While this backport might conditionally install it, projects using other `importlib.metadata` functions should explicitly require `importlib_metadata` for full API coverage on older Pythons.","package":"importlib_metadata","optional":true}],"imports":[{"note":"On Python versions older than 3.10 (or `importlib_metadata` < 3.6), importing `entry_points` directly from `importlib.metadata` will not provide the 'selectable' interface (i.e., passing keyword arguments like `group` or `name` or using the `.select()` method on the result). This shim explicitly provides that compatibility.","wrong":"from importlib.metadata import entry_points","symbol":"entry_points","correct":"from backports.entry_points_selectable import entry_points"}],"quickstart":{"code":"from backports.entry_points_selectable import entry_points\n\n# Example: Find all console scripts\nconsole_scripts = entry_points(group='console_scripts')\nprint(f\"Found {len(console_scripts)} console scripts.\")\nfor ep in console_scripts:\n    print(f\"  - {ep.name}: {ep.value}\")\n\n# Example: Find a specific entry point by name and group\ntry:\n    (mypy_ep,) = entry_points(group='console_scripts', name='mypy')\n    print(f\"\\nFound specific entry point: {mypy_ep.name} -> {mypy_ep.value}\")\n    # Load and execute the entry point (caution: this runs code)\n    # mypy_main = mypy_ep.load()\n    # mypy_main([])\nexcept ValueError:\n    print(\"\\n'mypy' console script not found or multiple found.\")\n\n# Fallback using .select() if no arguments were passed initially (less common with this backport)\nall_entry_points = entry_points()\npython_eps = all_entry_points.select(group='pytest11')\nprint(f\"\\nFound {len(python_eps)} pytest plugins.\")\nfor ep in python_eps:\n    print(f\"  - {ep.name}: {ep.value}\")","lang":"python","description":"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."},"warnings":[{"fix":"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`.","message":"This backport is primarily for Python versions older than 3.10 or environments using `importlib_metadata` older than 3.6. For Python 3.10+ (which includes the selectable entry point interface in `importlib.metadata` directly), this library may be unnecessary and can be removed.","severity":"gotcha","affected_versions":"<3.10"},{"fix":"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.","message":"The dictionary-like interface for `entry_points()` (e.g., `entry_points()['group_name']`) is deprecated in upstream `importlib.metadata` (Python 3.10+ and `importlib_metadata` 3.9+). While `backports.entry_points_selectable` aims to provide compatibility, relying on the dict interface is discouraged.","severity":"deprecated","affected_versions":"All versions when used with older `importlib_metadata` or Python < 3.10 (where the dict interface might still be implicitly supported but is considered deprecated upstream)."},{"fix":"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']`.","message":"This library only shims the `entry_points` function. If your project uses other APIs from `importlib.metadata` (e.g., `metadata`, `version`, `files`, `requires`), you might still need to explicitly depend on the `importlib_metadata` PyPI package if targeting Python versions older than 3.8.","severity":"gotcha","affected_versions":"All versions, particularly when supporting Python < 3.8."}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z","problems":[]}