From 5bb265a29878888bd249061f878e69bcef12577f Mon Sep 17 00:00:00 2001 From: Erwan MATHIEU Date: Wed, 28 Aug 2024 11:11:21 +0200 Subject: [PATCH 1/5] Add environment log when starting engine/plugin CURA-12091 --- cura/BackendPlugin.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cura/BackendPlugin.py b/cura/BackendPlugin.py index 5e885c3fd8a..9e39026791c 100644 --- a/cura/BackendPlugin.py +++ b/cura/BackendPlugin.py @@ -93,6 +93,8 @@ def start(self) -> bool: } if Platform.isWindows(): popen_kwargs["creationflags"] = subprocess.CREATE_NO_WINDOW + + Logger.info(os.environ) self._process = subprocess.Popen(self._validatePluginCommand(), **popen_kwargs) self._is_running = True return True From 40400b2be29b29f171015dc4a18951a2b16db9fd Mon Sep 17 00:00:00 2001 From: Erwan MATHIEU Date: Fri, 30 Aug 2024 08:55:37 +0200 Subject: [PATCH 2/5] Reset APPRUN_RUNTIME environment variable before calling plugin CURA-12091 --- cura/BackendPlugin.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cura/BackendPlugin.py b/cura/BackendPlugin.py index 9e39026791c..2bcd99194b6 100644 --- a/cura/BackendPlugin.py +++ b/cura/BackendPlugin.py @@ -94,8 +94,13 @@ def start(self) -> bool: if Platform.isWindows(): popen_kwargs["creationflags"] = subprocess.CREATE_NO_WINDOW - Logger.info(os.environ) - self._process = subprocess.Popen(self._validatePluginCommand(), **popen_kwargs) + plugin_env = os.environ + if "APPRUN_RUNTIME" in plugin_env and "APPRUN_ORIGINAL_APPRUN_RUNTIME" in plugin_env: + plugin_env["APPRUN_RUNTIME"] = plugin_env["APPRUN_ORIGINAL_APPRUN_RUNTIME"] + + Logger.info(plugin_env) + + self._process = subprocess.Popen(self._validatePluginCommand(), env=plugin_env, **popen_kwargs) self._is_running = True return True except PermissionError: From 79ad3e70eeaaeb0894c579a20aff8f984ab47e4c Mon Sep 17 00:00:00 2001 From: Erwan MATHIEU Date: Fri, 30 Aug 2024 10:59:48 +0200 Subject: [PATCH 3/5] Reset LD_PRELOAD environment variable before calling plugin CURA-12091 --- cura/BackendPlugin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cura/BackendPlugin.py b/cura/BackendPlugin.py index 2bcd99194b6..9b7621204c5 100644 --- a/cura/BackendPlugin.py +++ b/cura/BackendPlugin.py @@ -95,8 +95,8 @@ def start(self) -> bool: popen_kwargs["creationflags"] = subprocess.CREATE_NO_WINDOW plugin_env = os.environ - if "APPRUN_RUNTIME" in plugin_env and "APPRUN_ORIGINAL_APPRUN_RUNTIME" in plugin_env: - plugin_env["APPRUN_RUNTIME"] = plugin_env["APPRUN_ORIGINAL_APPRUN_RUNTIME"] + if "LD_PRELOAD" in plugin_env and "APPRUN_ORIGINAL_LD_PRELOAD" in plugin_env: + plugin_env["LD_PRELOAD"] = plugin_env["APPRUN_ORIGINAL_LD_PRELOAD"] Logger.info(plugin_env) From 34dcd3801d970cef3c14f19a8d702f790aec7987 Mon Sep 17 00:00:00 2001 From: Erwan MATHIEU Date: Fri, 30 Aug 2024 12:20:00 +0200 Subject: [PATCH 4/5] Specify the plugin directory as being an AppImage module directory CURA-12091 --- cura/BackendPlugin.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cura/BackendPlugin.py b/cura/BackendPlugin.py index 9b7621204c5..ab66d585bde 100644 --- a/cura/BackendPlugin.py +++ b/cura/BackendPlugin.py @@ -3,6 +3,7 @@ import socket import os import subprocess +import pathlib from typing import Optional, List from UM.Logger import Logger @@ -74,7 +75,8 @@ def start(self) -> bool: """ if not self.usePlugin(): return False - Logger.info(f"Starting backend_plugin [{self._plugin_id}] with command: {self._validatePluginCommand()}") + validated_plugin_command = self._validatePluginCommand() + Logger.info(f"Starting backend_plugin [{self._plugin_id}] with command: {validated_plugin_command}") plugin_log_path = os.path.join(Resources.getDataStoragePath(), f"{self.getPluginId()}.log") if os.path.exists(plugin_log_path): try: @@ -95,12 +97,14 @@ def start(self) -> bool: popen_kwargs["creationflags"] = subprocess.CREATE_NO_WINDOW plugin_env = os.environ - if "LD_PRELOAD" in plugin_env and "APPRUN_ORIGINAL_LD_PRELOAD" in plugin_env: - plugin_env["LD_PRELOAD"] = plugin_env["APPRUN_ORIGINAL_LD_PRELOAD"] + if Platform.isLinux() and len(validated_plugin_command) > 0: + # Add plugin directory to AppImage "modules" directory so that it is started as if it was + # part of the AppImage and uses the sames libraries + plugin_env["APPDIR_MODULE_DIR"] = str(pathlib.Path(validated_plugin_command[0]).parent.absolute()) Logger.info(plugin_env) - self._process = subprocess.Popen(self._validatePluginCommand(), env=plugin_env, **popen_kwargs) + self._process = subprocess.Popen(validated_plugin_command, env=plugin_env, **popen_kwargs) self._is_running = True return True except PermissionError: From 19ac42f875670318cffb0579cfd8bfbbc17eb3a1 Mon Sep 17 00:00:00 2001 From: Erwan MATHIEU Date: Fri, 30 Aug 2024 13:15:35 +0200 Subject: [PATCH 5/5] Remove debug log CURA-12091 --- cura/BackendPlugin.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/cura/BackendPlugin.py b/cura/BackendPlugin.py index ab66d585bde..0af40d89e9e 100644 --- a/cura/BackendPlugin.py +++ b/cura/BackendPlugin.py @@ -102,8 +102,6 @@ def start(self) -> bool: # part of the AppImage and uses the sames libraries plugin_env["APPDIR_MODULE_DIR"] = str(pathlib.Path(validated_plugin_command[0]).parent.absolute()) - Logger.info(plugin_env) - self._process = subprocess.Popen(validated_plugin_command, env=plugin_env, **popen_kwargs) self._is_running = True return True