From 0fc92ef2581b966d48c7e30465408e6f9d8ab87a Mon Sep 17 00:00:00 2001 From: Jonathan Haigh Date: Thu, 24 Apr 2025 12:05:33 +0100 Subject: [PATCH 1/4] specify python install to fix linux standalone launch --- qt/applications/workbench/workbench/app/start.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/qt/applications/workbench/workbench/app/start.py b/qt/applications/workbench/workbench/app/start.py index c4bf515d2d49..69e9f8b0e651 100644 --- a/qt/applications/workbench/workbench/app/start.py +++ b/qt/applications/workbench/workbench/app/start.py @@ -6,6 +6,7 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. import argparse +import os import subprocess import sys @@ -66,7 +67,7 @@ def start(options: argparse.ArgumentParser): # this is already the default on Windows/macOS. # This will mean the relevant 'atexit' code will execute in the child process, and therefore the # FrameworkManager and UsageService will be shutdown as expected. - launch_command = f"python {wp.__file__}" + launch_command = f"./python {wp.__file__}" if options.script: launch_command += f" {options.script}" if options.execute: @@ -74,11 +75,13 @@ def start(options: argparse.ArgumentParser): if options.quit: launch_command += " --quit" + launch_directory = os.environ["MANTIDPATH"] + if not is_windows(): # preexec_fn is not supported on Windows - workbench_process = subprocess.Popen(launch_command, shell=True, preexec_fn=setup_core_dump_files) + workbench_process = subprocess.Popen(launch_command, shell=True, cwd=launch_directory, preexec_fn=setup_core_dump_files) else: - workbench_process = subprocess.Popen(launch_command, shell=True) + workbench_process = subprocess.Popen(launch_command, shell=True, cwd=launch_directory) workbench_pid = str(workbench_process.pid) workbench_process.wait() From 30941f4a313f83013de9300c9ee6100026baa63f Mon Sep 17 00:00:00 2001 From: Jonathan Haigh Date: Thu, 24 Apr 2025 12:08:27 +0100 Subject: [PATCH 2/4] change pystack message to be warning not error --- qt/python/mantidqt/mantidqt/dialogs/errorreports/run_pystack.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qt/python/mantidqt/mantidqt/dialogs/errorreports/run_pystack.py b/qt/python/mantidqt/mantidqt/dialogs/errorreports/run_pystack.py index 4cc573a1b2f8..4dc29f4a9931 100644 --- a/qt/python/mantidqt/mantidqt/dialogs/errorreports/run_pystack.py +++ b/qt/python/mantidqt/mantidqt/dialogs/errorreports/run_pystack.py @@ -30,7 +30,7 @@ def retrieve_thread_traces_from_coredump_file(workbench_pid: str) -> bytes: try: core_dumps_path = _get_core_dumps_dir() except ValueError as e: - log.error(str(e)) + log.warning(str(e)) return b"" # Get most recent dump file. From 5c637c7f4b9f73bdbaa0d87596ab60e69df138fd Mon Sep 17 00:00:00 2001 From: Jonathan Haigh Date: Thu, 24 Apr 2025 14:52:51 +0100 Subject: [PATCH 3/4] simplify startup test now that workbench calls launch_mantidworkbench --- .../tests/qt/WorkbenchStartupTest.py | 45 +++++-------------- 1 file changed, 12 insertions(+), 33 deletions(-) diff --git a/Testing/SystemTests/tests/qt/WorkbenchStartupTest.py b/Testing/SystemTests/tests/qt/WorkbenchStartupTest.py index d8366f904f86..914ba2177b84 100644 --- a/Testing/SystemTests/tests/qt/WorkbenchStartupTest.py +++ b/Testing/SystemTests/tests/qt/WorkbenchStartupTest.py @@ -6,28 +6,14 @@ # SPDX - License - Identifier: GPL - 3.0 + import os import subprocess -import sys import systemtesting -from mantid.kernel import ConfigService from tempfile import NamedTemporaryFile TEST_MESSAGE = "Hello Mantid!" -EXECUTABLE_SWITCHER = { - "linux": ["launch_mantidworkbench.sh", "workbench"], - "darwin": ["workbench"], - "win32": ["workbench"], -} SUBPROCESS_TIMEOUT_SECS = 300 -def get_mantid_executables_for_platform(platform): - workbench_executables = EXECUTABLE_SWITCHER.get(platform, None) - if workbench_executables is None: - raise RuntimeError(f"Unknown platform {platform}.") - return workbench_executables - - def start_and_wait_for_completion(args_list): process = subprocess.Popen(args_list, stdout=subprocess.PIPE, stderr=subprocess.PIPE) exitcode = process.wait(timeout=SUBPROCESS_TIMEOUT_SECS) @@ -58,28 +44,21 @@ def __init__(self): self._test_file = NamedTemporaryFile(suffix=".txt", delete=False).name.replace("\\", "/") self._test_script = NamedTemporaryFile(suffix=".py", delete=False).name.replace("\\", "/") - self._executables = get_mantid_executables_for_platform(sys.platform) write_test_script(self._test_script, self._test_file) def runTest(self): - directory = ConfigService.getPropertiesDir().replace("\\", "/") - for executable in self._executables: - file_path = os.path.join(directory, executable) - executable, module = (file_path, False) if os.path.exists(file_path) else (executable, True) - arg_list = [executable, "--execute", self._test_script, "--quit"] - if module: - arg_list = ["python", "-m"] + arg_list - - exitcode, stderr = start_and_wait_for_completion(arg_list) - # Was the process successful - self.assertEqual(0, exitcode) - # Check for no warnings or errors on startup - error_warning_lines = [line for line in stderr.split("\n") if "[Error]" in line or "[Warning]" in line] - self.assertEqual([], error_warning_lines, f"stderr was warning / error output: {error_warning_lines}") - # Assert that the test script runs successfully by writing to a .txt file - with open(self._test_file, "r") as file: - self.assertEqual(TEST_MESSAGE, file.readline()) - remove_file(self._test_file) + arg_list = ["python", "-m", "workbench", "--execute", self._test_script, "--quit"] + + exitcode, stderr = start_and_wait_for_completion(arg_list) + # Check for no warnings or errors on startup + error_warning_lines = [line for line in stderr.split("\n") if "[Error]" in line or "[Warning]" in line] + self.assertEqual([], error_warning_lines, f"stderr was warning / error output: {error_warning_lines}") + # Assert that the test script runs successfully by writing to a .txt file + with open(self._test_file, "r") as file: + self.assertEqual(TEST_MESSAGE, file.readline()) + remove_file(self._test_file) + # Was the process successful + self.assertEqual(0, exitcode) def cleanup(self): remove_file(self._test_script) From 682a68532cf0caca9699edb110d620543f5711ae Mon Sep 17 00:00:00 2001 From: Jonathan Haigh Date: Fri, 25 Apr 2025 08:59:40 +0100 Subject: [PATCH 4/4] switch to specifying python install using sys.executable --- qt/applications/workbench/workbench/app/start.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/qt/applications/workbench/workbench/app/start.py b/qt/applications/workbench/workbench/app/start.py index 69e9f8b0e651..aa2342f5ff97 100644 --- a/qt/applications/workbench/workbench/app/start.py +++ b/qt/applications/workbench/workbench/app/start.py @@ -6,7 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. import argparse -import os import subprocess import sys @@ -67,7 +66,7 @@ def start(options: argparse.ArgumentParser): # this is already the default on Windows/macOS. # This will mean the relevant 'atexit' code will execute in the child process, and therefore the # FrameworkManager and UsageService will be shutdown as expected. - launch_command = f"./python {wp.__file__}" + launch_command = f"{sys.executable} {wp.__file__}" if options.script: launch_command += f" {options.script}" if options.execute: @@ -75,13 +74,11 @@ def start(options: argparse.ArgumentParser): if options.quit: launch_command += " --quit" - launch_directory = os.environ["MANTIDPATH"] - if not is_windows(): # preexec_fn is not supported on Windows - workbench_process = subprocess.Popen(launch_command, shell=True, cwd=launch_directory, preexec_fn=setup_core_dump_files) + workbench_process = subprocess.Popen(launch_command, shell=True, preexec_fn=setup_core_dump_files) else: - workbench_process = subprocess.Popen(launch_command, shell=True, cwd=launch_directory) + workbench_process = subprocess.Popen(launch_command, shell=True) workbench_pid = str(workbench_process.pid) workbench_process.wait()