[Mesa-dev] [PATCH v3 44/48] meson: Use python module to find python2 on windows

Dylan Baker dylan at pnwbakers.com
Tue Aug 7 00:51:24 UTC 2018

The python installer on Windows installs two `python.exe`, one for
python2 and one for python3 and no `python2.exe` nor `python3.exe`.

This seems utterly broken to me, but luckily for us meson handles this
craziness for us, but only since version 0.46.

This is higher than we require for now, but since we only need this on
Windows, I suggest bumping the required version only on windows, and
leaving all the other OSes as is.

(Note: some future version of Meson (0.48 probably) will handle this
 internally in the find_program() call.)

Reported-by: Alexander Ashevchenko <sav_ix at ukr.net>
Cc: Mathieu Bridon <bochecha at daitauha.fr>
Signed-off-by: Eric Engestrom <eric.engestrom at intel.com>
Reviewed-by: Dylan Baker <dylan.c.baker at intel.com>
 meson.build | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/meson.build b/meson.build
index 100d12f475d..bbfd7c3c73f 100644
--- a/meson.build
+++ b/meson.build
@@ -710,7 +710,15 @@ if with_platform_haiku
   pre_args += '-DHAVE_HAIKU_PLATFORM'
-prog_python2 = find_program('python2')
+if build_machine.system() == 'windows'
+  if meson.version().version_compare('< 0.46')
+    error('Windows requires Meson 0.46+; please update and try again.')
+  else
+    prog_python2 = import('python').find_installation('python2')
+  endif
+  prog_python2 = find_program('python2')
 has_mako = run_command(prog_python2, '-c', 'import mako')
 if has_mako.returncode() != 0
   error('Python (2.x) mako module required to build mesa.')

More information about the mesa-dev mailing list