1
1
from __future__ import annotations
2
2
3
3
import dataclasses
4
+ import os
4
5
import re
5
6
import shlex
6
7
import sys
@@ -84,6 +85,18 @@ def _filter_env_cmake_args(env_cmake_args: list[str]) -> Generator[str, None, No
84
85
yield arg
85
86
86
87
88
+ def _sanitize_path (path : os .PathLike [str ]) -> list [Path ]:
89
+ # This handles classes like:
90
+ # MultiplexedPath from importlib.resources.readers (3.11+)
91
+ # MultiplexedPath from importlib.readers (3.10)
92
+ # MultiplexedPath from importlib_resources.readers
93
+ if hasattr (path , "_paths" ):
94
+ # pylint: disable-next=protected-access
95
+ return [Path (os .fspath (p )) for p in path ._paths ]
96
+
97
+ return [Path (os .fspath (path ))]
98
+
99
+
87
100
@dataclasses .dataclass
88
101
class Builder :
89
102
settings : ScikitBuildSettings
@@ -124,11 +137,15 @@ def configure(
124
137
125
138
# Add any extra CMake modules
126
139
eps = metadata .entry_points (group = "cmake.module" )
127
- self .config .module_dirs .extend (resources .files (ep .load ()) for ep in eps )
140
+ self .config .module_dirs .extend (
141
+ p for ep in eps for p in _sanitize_path (resources .files (ep .load ()))
142
+ )
128
143
129
144
# Add any extra CMake prefixes
130
145
eps = metadata .entry_points (group = "cmake.prefix" )
131
- self .config .prefix_dirs .extend (resources .files (ep .load ()) for ep in eps )
146
+ self .config .prefix_dirs .extend (
147
+ p for ep in eps for p in _sanitize_path (resources .files (ep .load ()))
148
+ )
132
149
133
150
# Add site-packages to the prefix path for CMake
134
151
site_packages = Path (sysconfig .get_path ("purelib" ))
@@ -137,6 +154,7 @@ def configure(
137
154
if site_packages != DIR .parent .parent :
138
155
self .config .prefix_dirs .append (DIR .parent .parent )
139
156
logger .debug ("Extra SITE_PACKAGES: {}" , DIR .parent .parent )
157
+ logger .debug ("PATH: {}" , sys .path )
140
158
141
159
# Add the FindPython backport if needed
142
160
if self .config .cmake .version < self .settings .backport .find_python :
0 commit comments