summaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorCharles Brunet <charles.brunet@optelgroup.com>2025-05-14 13:00:38 -0400
committerJussi Pakkanen <jussi.pakkanen@mailbox.org>2025-05-14 23:08:55 +0300
commit0ca85ebf2e6f2c7cc3bcdcae96ea00d07461bd75 (patch)
tree10aaa6f99d9b1127c5892da5009571a249dfcfa8 /mesonbuild
parenta096df02e17f8f0644f988c10986688d97ec1a66 (diff)
downloadmeson-0ca85ebf2e6f2c7cc3bcdcae96ea00d07461bd75.tar.gz
devenv: do not use os.execv on Windows
On Windows, os.execv spawn the process in background and returns 0. Therefore, it prevents devenv to return proper exit code from the called process. (see https://github.com/python/cpython/issues/63323 for reference.) The solution is to call subprocess.run instead, on Windows, at the price of keeping the meson python process alive while the devenv subprocess runs.
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/mdevenv.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/mesonbuild/mdevenv.py b/mesonbuild/mdevenv.py
index 4962d96c6..e9974fe86 100644
--- a/mesonbuild/mdevenv.py
+++ b/mesonbuild/mdevenv.py
@@ -4,6 +4,7 @@ import os, subprocess
import argparse
import tempfile
import shutil
+import sys
import itertools
import typing as T
@@ -226,8 +227,14 @@ def run(options: argparse.Namespace) -> int:
args[0] = abs_path or args[0]
try:
- os.chdir(workdir)
- os.execvpe(args[0], args, env=devenv)
+ if is_windows():
+ # execvpe doesn't return exit code on Windows
+ # see https://github.com/python/cpython/issues/63323
+ result = subprocess.run(args, env=devenv, cwd=workdir)
+ sys.exit(result.returncode)
+ else:
+ os.chdir(workdir)
+ os.execvpe(args[0], args, env=devenv)
except FileNotFoundError:
raise MesonException(f'Command not found: {args[0]}')
except OSError as e: