Skip to content

Commit

Permalink
MAINT: improve error reporting when meson --version fails
Browse files Browse the repository at this point in the history
  • Loading branch information
dnicolodi committed May 19, 2024
1 parent dc23cff commit 27dd7ad
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions mesonpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -998,13 +998,15 @@ def _get_meson_command(
# package, however, it may occur that the meson Python package is installed
# but the corresponding meson command is not available in $PATH. Implement
# a runtime check to verify that the build environment is setup correcly.
required_version = _parse_version_string(version)
try:
meson_version = subprocess.run(cmd + ['--version'], check=False, text=True, capture_output=True).stdout
r = subprocess.run(cmd + ['--version'], text=True, capture_output=True)
except FileNotFoundError as err:
raise ConfigError(f'meson executable "{meson}" not found') from err
if r.returncode != 0:
raise ConfigError(f'Could not execute meson: {r.stderr.strip()}')
meson_version = r.stdout.strip()

if _parse_version_string(meson_version) < required_version:
if _parse_version_string(meson_version) < _parse_version_string(version):
raise ConfigError(f'Could not find meson version {version} or newer, found {meson_version}.')

return cmd
Expand Down

0 comments on commit 27dd7ad

Please sign in to comment.