Skip to content

Commit 271f7d6

Browse files
dnicolodirgommers
authored andcommitted
MAINT: improve error reporting when meson --version fails
1 parent dc23cff commit 271f7d6

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

mesonpy/__init__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -998,13 +998,15 @@ def _get_meson_command(
998998
# package, however, it may occur that the meson Python package is installed
999999
# but the corresponding meson command is not available in $PATH. Implement
10001000
# a runtime check to verify that the build environment is setup correcly.
1001-
required_version = _parse_version_string(version)
10021001
try:
1003-
meson_version = subprocess.run(cmd + ['--version'], check=False, text=True, capture_output=True).stdout
1002+
r = subprocess.run(cmd + ['--version'], text=True, capture_output=True)
10041003
except FileNotFoundError as err:
10051004
raise ConfigError(f'meson executable "{meson}" not found') from err
1005+
if r.returncode != 0:
1006+
raise ConfigError(f'Could not execute meson: {r.stderr.strip()}')
1007+
meson_version = r.stdout.strip()
10061008

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

10101012
return cmd

0 commit comments

Comments
 (0)