From 9f33645d2c4432cd6940c455b34f4c09d655f080 Mon Sep 17 00:00:00 2001 From: bbhtt Date: Sat, 9 Aug 2025 11:38:14 +0530 Subject: [PATCH] meson: Clearly print error when distutils or packaging is missing Previously, if neither packaging.version or distutils.version is present in the environment the has_mako check would return non-zero exit code and meson would print that mako is required which is misleading since mako can be in the environment but not packaging or distutils. This can happen for Python>=3.12 where distutils is no longer in the Python stdlib but provided externally by setuptools. Signed-off-by: bbhtt Part-of: --- meson.build | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/meson.build b/meson.build index 85a561a5851..883185fa27d 100644 --- a/meson.build +++ b/meson.build @@ -924,15 +924,29 @@ prog_python = find_program('python3', 'python', version : '>= 3.9') has_mako = run_command( prog_python, '-c', ''' +import sys + try: - from packaging.version import Version + try: + from packaging.version import Version + except: + from distutils.version import StrictVersion as Version except: - from distutils.version import StrictVersion as Version -import mako -assert Version(mako.__version__) >= Version("0.8.0") - ''', check: false) -if has_mako.returncode() != 0 + sys.exit(2) + +try: + import mako +except: + sys.exit(1) + +if Version(mako.__version__) < Version("0.8.0"): + sys.exit(1) +''', check: false) + +if has_mako.returncode() == 1 error('Python (3.x) mako module >= 0.8.0 required to build mesa.') +elif has_mako.returncode() == 2 + error('One of Python (3.x) packaging or distutils module is required.') endif has_yaml = run_command(