saturnin.lib.metadata

Utility functions for interacting with Python’s importlib.metadata.

This module provides helper functions to simplify common tasks related to discovering and inspecting package distributions and their registered entry points, acting as a focused interface to importlib.metadata functionalities.

Functions

saturnin.lib.metadata.iter_entry_points(group: str, name: str | None = None) Generator[EntryPoint, None, None][source]

Provides an iterator for entry points, similar to pkg_resources.iter_entry_points.

This function leverages importlib.metadata.entry_points() to find and yield EntryPoint objects.

Parameters:
  • group (str) – The name of the entry point group to iterate over (e.g., ‘console_scripts’).

  • name (str | None) – Optional. The specific name of the entry point to retrieve. If None, all entry points within the specified group are yielded.

Yields:

EntryPoint – An EntryPoint object for each matching entry point found.

Return type:

Generator[EntryPoint, None, None]

saturnin.lib.metadata.get_entry_point_distribution(entry_point: EntryPoint) Distribution | None[source]

Finds the distribution package that registered a given entry point.

This function iterates through all available distributions to find the one containing the specified entry_point. It is not limited to distributions that might have registered specific Saturnin components but searches globally.

Parameters:

entry_point (EntryPoint) – The EntryPoint object for which the parent distribution is to be located.

Returns:

The Distribution object that registered the

entry_point, or None if no such distribution can be found.

Return type:

Distribution | None