From f5eebef64385e45b56781b2954cf207ea8ae0de1 Mon Sep 17 00:00:00 2001 From: Nabil Ghodbane Date: Wed, 13 Mar 2024 14:49:27 +0100 Subject: [PATCH] [bos #41189] Expose relevant DLL directories to ensure SALOME starts --- src/Basics/KernelBasis.i | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/src/Basics/KernelBasis.i b/src/Basics/KernelBasis.i index 54616f81e..7e8e2d5f6 100644 --- a/src/Basics/KernelBasis.i +++ b/src/Basics/KernelBasis.i @@ -19,6 +19,38 @@ %module KernelBasis +%pythonbegin %{ + # new mechanism introduced in Python 3.8+ about DLL resolution + import os + def __add_dll_directory__(path): + paths = [ p.replace("\\\\", "\\").replace("/", "\\") for p in sys.path] + if not path in paths and os.path.exists(path): + os.add_dll_directory(path) + else: + print("DEBUG: directory is already present in {}".format(path)) + return + + import platform + if platform.system() == "Windows": + import sys + if sys.version_info > (3,8) : + try: + import os + _dll_exposed = os.getenv("KERNEL_DLLs_Exposed", "") + if _dll_exposed == "" : + print("INFO: Exposing DLL directories") + __add_dll_directory__(os.path.join(os.getenv("KERNEL_ROOT_DIR"), "lib", "salome")) + __add_dll_directory__(os.path.join(os.getenv("GUI_ROOT_DIR"), "lib", "salome")) + __add_dll_directory__(os.path.join(os.getenv("GUI_ROOT_DIR"), "lib", "salome")) + __add_dll_directory__(os.path.join(os.getenv("PTHREAD_ROOT_DIR"), "lib" )) + __add_dll_directory__(os.path.join(os.getenv("PRODUCT_ROOT_DIR"), "W64", "lib" )) + __add_dll_directory__(os.path.join(os.getenv("PRODUCT_ROOT_DIR"), "W64", "bin" )) + __add_dll_directory__(os.getenv("OMNIORB_BIN_DIR")) + os.environ["KERNEL_DLLs_Exposed"] = "1" + except Exception: + print("FATAL: Exception raise while trying to expose DLLs") +%} + %{ #include "KernelBasis.hxx" #include "HeatMarcel.hxx" @@ -123,4 +155,4 @@ std::string VerbosityLevelSwig() def ReadFloatsInFile( fileName ): ret = ReadFloatsInFileSwig( fileName ) return ret -%} \ No newline at end of file +%} -- 2.39.2