From b03f666bf527c4cfcf452bb96434126f9800b8d9 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Fri, 31 Jan 2020 12:52:10 +0100 Subject: WIP: Make it work with Python 3.7 packaing --- cura/CuraApplication.py | 3 +++ cura_app.py | 1 + plugins/CuraEngineBackend/CuraEngineBackend.py | 20 ++++++++++++++++---- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index edd8872fe9..7b17583f68 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -348,6 +348,9 @@ class CuraApplication(QtApplication): for dir_name in ["extruders", "machine_instances", "materials", "plugins", "quality", "quality_changes", "user", "variants", "intent"]: Resources.addExpectedDirNameInData(dir_name) + app_root = os.path.abspath(os.path.join(os.path.dirname(sys.executable))) + Resources.addSearchPath(os.path.join(app_root, "share", "cura", "resources")) + Resources.addSearchPath(os.path.join(self._app_install_dir, "share", "cura", "resources")) if not hasattr(sys, "frozen"): resource_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), "..", "resources") diff --git a/cura_app.py b/cura_app.py index 5184a5ab8b..d1f7ad1c46 100755 --- a/cura_app.py +++ b/cura_app.py @@ -171,6 +171,7 @@ else: # tries to create PyQt objects on a non-main thread. import Arcus #@UnusedImport import Savitar #@UnusedImport + from cura.CuraApplication import CuraApplication diff --git a/plugins/CuraEngineBackend/CuraEngineBackend.py b/plugins/CuraEngineBackend/CuraEngineBackend.py index 1437153f32..247936bf77 100755 --- a/plugins/CuraEngineBackend/CuraEngineBackend.py +++ b/plugins/CuraEngineBackend/CuraEngineBackend.py @@ -55,10 +55,22 @@ class CuraEngineBackend(QObject, Backend): if Platform.isWindows(): executable_name += ".exe" default_engine_location = executable_name - if os.path.exists(os.path.join(CuraApplication.getInstallPrefix(), "bin", executable_name)): - default_engine_location = os.path.join(CuraApplication.getInstallPrefix(), "bin", executable_name) - if hasattr(sys, "frozen"): - default_engine_location = os.path.join(os.path.dirname(os.path.abspath(sys.executable)), executable_name) + + search_path = [ + os.path.abspath(os.path.dirname(sys.executable)), + os.path.abspath(os.path.join(os.path.dirname(sys.executable), "bin")), + os.path.abspath(os.path.join(os.path.dirname(sys.executable), "..")), + + os.path.join(CuraApplication.getInstallPrefix(), "bin"), + os.path.dirname(os.path.abspath(sys.executable)), + ] + + for path in search_path: + engine_path = os.path.join(path, executable_name) + if os.path.isfile(engine_path): + default_engine_location = engine_path + break + if Platform.isLinux() and not default_engine_location: if not os.getenv("PATH"): raise OSError("There is something wrong with your Linux installation.") -- cgit v1.2.3