Skip to content

Commit 961fb56

Browse files
dnicolodiFFY00
authored andcommitted
ENH: error on failure to map installed files into wheel directories
Turn the warning emitted so far into an hard error: warnings are easy to miss when building packages containing many files and the reason for missing files in the installed wheel can be hard to track down. Remove the message suggesting that a missing installation path placeholder in a Meson installation path is a Meson bug: this can be caused by the user using absolute paths as installation directories, for example using py.get_path() instead of py.get_install_dir().
1 parent 87435a5 commit 961fb56

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

mesonpy/__init__.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def _init_colors() -> Dict[str, str]:
143143
}
144144

145145

146-
def _map_meson_destination(destination: str) -> Tuple[Optional[str], pathlib.Path]:
146+
def _map_meson_destination(destination: str) -> Tuple[str, pathlib.Path]:
147147
"""Map a Meson installation path to a wheel installation location.
148148
149149
Return a (wheel path identifier, subpath inside the wheel path) tuple.
@@ -153,10 +153,7 @@ def _map_meson_destination(destination: str) -> Tuple[Optional[str], pathlib.Pat
153153
for folder, placeholders in _SCHEME_MAP.items():
154154
if parts[0] in placeholders:
155155
return folder, pathlib.Path(*parts[1:])
156-
warnings.warn(f'Could not map installation path to an equivalent wheel directory: {destination!r}')
157-
if not re.match(r'^{\w+}$', parts[0]):
158-
raise RuntimeError('Meson installation path {destination!r} does not start with a placeholder. Meson bug!')
159-
return None, pathlib.Path(destination)
156+
raise BuildError(f'Could not map installation path to an equivalent wheel directory: {destination!r}')
160157

161158

162159
def _map_to_wheel(sources: Dict[str, Dict[str, Any]]) -> DefaultDict[str, List[Tuple[pathlib.Path, str]]]:
@@ -205,6 +202,10 @@ class ConfigError(Error):
205202
"""Error in the backend configuration."""
206203

207204

205+
class BuildError(Error):
206+
"""Error when building the wheel."""
207+
208+
208209
class MesonBuilderError(Error):
209210
"""Error when building the Meson package."""
210211

0 commit comments

Comments
 (0)