From c39ee881a1959ae37aded8e0c24cec23b2bd6a90 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Sun, 16 Apr 2023 00:00:55 -0400 Subject: [PATCH] select the correct python_command for pyinstaller builds, even on not-Windows Checking the executable basename sort of works, at least for Windows, since Windows always happens to use exactly this approach. However, the official pyinstaller documentation suggests a very different approach: https://pyinstaller.org/en/stable/runtime-information.html This approach is more robust since it works on any OS, and in particular it allows me to test the PyInstaller bundle functionality on Linux, even though we don't officially distribute it as such. --- mesonbuild/utils/universal.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mesonbuild/utils/universal.py b/mesonbuild/utils/universal.py index 8c35803cd..fc217c8a7 100644 --- a/mesonbuild/utils/universal.py +++ b/mesonbuild/utils/universal.py @@ -176,8 +176,8 @@ project_meson_versions = collections.defaultdict(str) # type: T.DefaultDict[str from glob import glob -if os.path.basename(sys.executable) == 'meson.exe': - # In Windows and using the MSI installed executable. +if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'): + # using a PyInstaller bundle, e.g. the MSI installed executable python_command = [sys.executable, 'runpython'] else: python_command = [sys.executable]