Skip to content

Use copilot self-review suggestion for pkg_resources replacement#66

Merged
inducer merged 1 commit intomainfrom
fix-importlib
Feb 15, 2026
Merged

Use copilot self-review suggestion for pkg_resources replacement#66
inducer merged 1 commit intomainfrom
fix-importlib

Conversation

@inducer
Copy link
Owner

@inducer inducer commented Feb 15, 2026

No description provided.

Copilot AI review requested due to automatic review settings February 15, 2026 20:01
@inducer inducer enabled auto-merge (rebase) February 15, 2026 20:01
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR replaces the importlib.resources.files approach with importlib.util.find_spec in the add_py_module function to achieve consistency with the existing add_numpy function implementation.

Changes:

  • Modified get_module_include_path function within add_py_module to use find_spec and submodule_search_locations instead of importlib.resources.files

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +188 to +195
from importlib.util import find_spec
spec = find_spec(name)
if spec is None:
raise RuntimeError(f"Could not find module '{name}'")
libdir = spec.submodule_search_locations
assert libdir is not None
from os.path import join
return join(libdir[0], "include")
Copy link

Copilot AI Feb 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change from importlib.resources.files to find_spec with submodule_search_locations makes this function consistent with add_numpy above, but moves away from the more modern and robust approach. The importlib.resources.files API is the recommended way to access package resources and works with any import mechanism including zip files, while the new approach assumes filesystem-based packages. For this use case (finding C/C++ include directories), filesystem-based packages are expected, so the practical impact is minimal. However, if consistency is the goal, consider updating add_numpy to also use importlib.resources.files for better maintainability.

Copilot uses AI. Check for mistakes.
@inducer inducer merged commit 14c8cbc into main Feb 15, 2026
13 checks passed
@inducer inducer deleted the fix-importlib branch February 15, 2026 20:05
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