Skip to content

Commit

Permalink
ENH: error on failure to map installed files into wheel directories
Browse files Browse the repository at this point in the history
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().
  • Loading branch information
dnicolodi authored and FFY00 committed Mar 14, 2023
1 parent 87435a5 commit 961fb56
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions mesonpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def _init_colors() -> Dict[str, str]:
}


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


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


class BuildError(Error):
"""Error when building the wheel."""


class MesonBuilderError(Error):
"""Error when building the Meson package."""

Expand Down

0 comments on commit 961fb56

Please sign in to comment.