From a612f0fa16e64671508bb2a6e373117d4de1b543 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Sun, 15 Feb 2026 14:00:44 -0600 Subject: [PATCH] Use copilot self-review suggestion for pkg_resources replacement --- codepy/libraries.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/codepy/libraries.py b/codepy/libraries.py index cdc5032..2eef51f 100644 --- a/codepy/libraries.py +++ b/codepy/libraries.py @@ -185,8 +185,14 @@ def get_numpy_incpath() -> str: def add_py_module(toolchain: Toolchain, name: str) -> None: def get_module_include_path(name: str) -> str: - from importlib.resources import files - return str(files(name) / "include") + 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") toolchain.add_library(name, [get_module_include_path(name)], [], [])