Skip to content

Use stdlib importlib.metadata instead of importlib_metadata + pkg_resources fallback - #426

Open
andlo wants to merge 1 commit into
OpenVoiceOS:devfrom
andlo:fix/drop-pkg-resources-fallback
Open

Use stdlib importlib.metadata instead of importlib_metadata + pkg_resources fallback#426
andlo wants to merge 1 commit into
OpenVoiceOS:devfrom
andlo:fix/drop-pkg-resources-fallback

Conversation

@andlo

@andlo andlo commented Aug 5, 2026

Copy link
Copy Markdown

What

Replaces the try: from importlib_metadata import entry_points / except ImportError: import pkg_resources fallback in _iter_plugins() with a direct from importlib.metadata import entry_points (stdlib).

Why

This project already requires python_requires >= 3.10 (pyproject.toml), well past the Python 3.8 floor for stdlib importlib.metadata. Both the external importlib_metadata backport and the pkg_resources fallback are unnecessary now.

Confirmed as a real, reproducible bug on real hardware, not just a style cleanup: in a fresh virtualenv where importlib_metadata isn't installed (it's not declared as a dependency of this package), _iter_plugins() falls through to the pkg_resources branch -- which itself raises ModuleNotFoundError, since recent setuptools releases no longer bundle pkg_resources by default (and are removing it entirely per the upstream deprecation notice). This broke skill loading end-to-end for us -- reproduced consistently via skill-ovos-stop: ModuleNotFoundError: No module named 'pkg_resources'.

Using importlib.metadata directly removes both failure modes at once, with no new dependency to declare.

Testing

All 27 existing tests in test/unittests/test_utils.py pass unchanged against this change.

Context

Found while building a venv-per-skill isolation layer for a Home Assistant integration project -- happy to share more reproduction detail if useful.

Summary by CodeRabbit

  • Refactor
    • Updated plugin discovery to use Python’s standard library.
    • Removed legacy compatibility paths for plugin discovery.

…ort + pkg_resources fallback

This project already requires Python >=3.10 (pyproject.toml), well past
the Python 3.8 floor for stdlib importlib.metadata -- so the external
importlib_metadata backport package, and the pkg_resources fallback for
when it's missing, are both unnecessary now.

Confirmed as a real, reproducible bug, not just a style cleanup: in a
fresh virtualenv where importlib_metadata isn't installed (it's not
declared as a dependency of this package), _iter_plugins() falls
through to the pkg_resources branch, which itself raises
ModuleNotFoundError on a recent setuptools -- setuptools no longer
bundles pkg_resources by default in current releases, and is removing
it entirely. This broke skill loading end-to-end for us (confirmed via
skill-ovos-stop: ModuleNotFoundError: No module named 'pkg_resources',
reproduced consistently on real hardware).

Using importlib.metadata directly removes both failure modes at once,
with no dependency to add. All 27 existing tests in test/unittests/test_utils.py
still pass unchanged.
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1ee70951-5873-4b61-b3b2-85450918d679

📥 Commits

Reviewing files that changed from the base of the PR and between d0aeae5 and d5df7d9.

📒 Files selected for processing (1)
  • ovos_plugin_manager/utils/__init__.py

📝 Walkthrough

Walkthrough

Entry-point discovery now uses Python’s standard-library importlib.metadata API. The importlib_metadata and pkg_resources fallbacks were removed. _iter_plugins yields entries for the requested group.

Changes

Entry-point discovery

Layer / File(s) Summary
Standard-library entry-point lookup
ovos_plugin_manager/utils/__init__.py
The compatibility imports and pkg_resources fallback were removed. _iter_plugins now uses importlib.metadata.entry_points for the requested group.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: jarbasal

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: replacing compatibility fallbacks with the standard-library importlib.metadata API.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

andlo added a commit to andlo/haos-ovos-addons that referenced this pull request Aug 5, 2026
… -- filed OpenVoiceOS/ovos-plugin-manager#426 proposing the actual root-cause fix (stdlib importlib.metadata instead of the importlib_metadata+pkg_resources fallback). Our setuptools pin stays either way, as a safety net for any already-published release.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant