Skip to content

Commit 14c8cbc

Browse files
committed
Use copilot self-review suggestion for pkg_resources replacement
1 parent 61334d2 commit 14c8cbc

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

codepy/libraries.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,14 @@ def get_numpy_incpath() -> str:
185185

186186
def add_py_module(toolchain: Toolchain, name: str) -> None:
187187
def get_module_include_path(name: str) -> str:
188-
from importlib.resources import files
189-
return str(files(name) / "include")
188+
from importlib.util import find_spec
189+
spec = find_spec(name)
190+
if spec is None:
191+
raise RuntimeError(f"Could not find module '{name}'")
192+
libdir = spec.submodule_search_locations
193+
assert libdir is not None
194+
from os.path import join
195+
return join(libdir[0], "include")
190196

191197
toolchain.add_library(name, [get_module_include_path(name)], [], [])
192198

0 commit comments

Comments
 (0)