Remove importlib-metadata dependency (#5203)
* Remove importlib-metadata dependency Remove the third-party importlib-metadata dependency in favor of the standard library's importlib.metadata, which is stable and available natively since Python >= 3.10. Implements a unified, branchless caching wrapper in `opentelemetry-api` that: - Bypasses standard `entry_points()` version-specific return type differences (SelectableGroups vs EntryPoints) by building a flat `EntryPoints` sequence directly from the low-level `distributions()` API. - Caches all resolved entry points in-memory on the first call to avoid severe startup performance degradation caused by repeated filesystem scans in standard library `importlib.metadata` (resulting in a 37x speedup on subsequent lookups and a 2x faster cold start). - Cleans up obsolete `importlib-metadata` and `zipp` requirements across 19 test and documentation configurations. Assisted-by: Gemini * Refactor importlib.metadata caching wrapper to address PR comments - Leverage stdlib `entry_points()` directly instead of the custom `distributions()` loop, ensuring standard library's `sys.path` shadowing resolution (uniqueness filtering) is perfectly preserved. - Map Python 3.10/3.11 `SelectableGroups` (dict-like object) to `EntryPoints` (sequence) using a compatibility helper `_as_entry_points`. - Cache the result of the no-argument stdlib `entry_points()` call via `@cache` to eliminate redundant disk-scanning on repeated lookups. - Add a compatibility unit test for `_as_entry_points` with dict-like input. Assisted-by: Gemini * Apply suggestion from @herin049 Co-authored-by: Lukas Hering <40302054+herin049@users.noreply.github.com> * Add Sphinx RST module docstring to _importlib_metadata.py Assisted-by: Gemini * Undo rename of _original_entry_points_cached and document test behavior - Revert the caching function name back to _original_entry_points_cached to avoid unnecessary churn. - Add a docstring to test_as_entry_points_selectable_groups_compat explaining the normalization of Python 3.10 SelectableGroups vs 3.11+. Assisted-by: Gemini --------- Co-authored-by: Lukas Hering <40302054+herin049@users.noreply.github.com> Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
A
Aaron Abbott committed
1a33c692f0248271023519fd52a1f6b51d787655
Parent: 4a85110
Committed by GitHub <noreply@github.com>
on 5/14/2026, 3:31:10 PM