Entrypoints

0.4 · maintenance · verified Sun Mar 29

The `entrypoints` library facilitates the discovery and loading of entry points advertised by installed Python packages. It offers a lightweight and faster alternative to `pkg_resources` for this specific functionality, avoiding the full package scans that can slow down `pkg_resources` at import time. The current version is 0.4. The package is in maintenance-only mode, with new code advised to use the `importlib.metadata` module from the Python standard library for entry point management.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to find and load entry points, specifically 'console_scripts'. It iterates through found entry points, prints their details, and attempts to load the associated Python object.

from entrypoints import get_group_all

# Example: Find all 'console_scripts' entry points
console_scripts = get_group_all('console_scripts')

print(f"Found {len(console_scripts)} console scripts:")
for ep in console_scripts:
    print(f"  - {ep.name}: {ep.module}.{ep.attr}")
    try:
        # Load the entry point (e.g., a function)
        loaded_object = ep.load()
        # You can then call the loaded_object if it's a function
        # print(f"    Loaded object: {loaded_object}")
    except Exception as e:
        print(f"    Could not load {ep.name}: {e}")

view raw JSON →