mesonbuild / meson-python

Meson PEP 517 Python build backend
https://mesonbuild.com/meson-python/
MIT License
118 stars 59 forks source link

MAINT: improve error message when meson isn't found #631

Closed rgommers closed 1 month ago

rgommers commented 1 month ago

This is a follow-up to gh-495.

There are several ways that meson may go missing:

The git submodule case was ending with:

meson-python: error: Could not find meson version 0.63.3 or newer, found .

and after this ends with:

meson-python: error: Could not find specified meson: vendored-meson/meson/meson.py

If the executable is missing, the build ended with a very long traceback. Changing FileNotFoundError to ConfigError elides the traceback and clearly reports that the executable wasn't found. Easy to verify with any package with:

$ MESON=nonsense python -m build -wnx
* Building wheel...

meson-python: error: meson executable `nonsense` not found

ERROR Backend subproccess exited when trying to invoke build_wheel

Closes https://github.com/numpy/numpy/issues/26397

rgommers commented 1 month ago

Thanks @dnicolodi. Adopted your suggestions for error messages.

In that I also check the return code of meson --version and raise an error with what was printed on the standard error if the return code is not zero.

If you have that already, do you want to put that on top of this PR (either push a commit or do in a follow-up PR)?

dnicolodi commented 1 month ago

Sure, I will do that later today.