fix: restore original simple_refrig_api and platform path fixes
This commit is contained in:
BIN
app/ipm/lib/linux/libR12.so
Normal file
BIN
app/ipm/lib/linux/libR12.so
Normal file
Binary file not shown.
BIN
app/ipm/lib/linux/libR1233zd.so
Normal file
BIN
app/ipm/lib/linux/libR1233zd.so
Normal file
Binary file not shown.
BIN
app/ipm/lib/linux/libR1234ze.so
Normal file
BIN
app/ipm/lib/linux/libR1234ze.so
Normal file
Binary file not shown.
BIN
app/ipm/lib/linux/libR134a.so
Normal file
BIN
app/ipm/lib/linux/libR134a.so
Normal file
Binary file not shown.
BIN
app/ipm/lib/linux/libR22.so
Normal file
BIN
app/ipm/lib/linux/libR22.so
Normal file
Binary file not shown.
BIN
app/ipm/lib/linux/libR290.so
Normal file
BIN
app/ipm/lib/linux/libR290.so
Normal file
Binary file not shown.
BIN
app/ipm/lib/linux/libR32.so
Normal file
BIN
app/ipm/lib/linux/libR32.so
Normal file
Binary file not shown.
BIN
app/ipm/lib/linux/libR404A.so
Normal file
BIN
app/ipm/lib/linux/libR404A.so
Normal file
Binary file not shown.
BIN
app/ipm/lib/linux/libR410A.so
Normal file
BIN
app/ipm/lib/linux/libR410A.so
Normal file
Binary file not shown.
BIN
app/ipm/lib/linux/libR502.so
Normal file
BIN
app/ipm/lib/linux/libR502.so
Normal file
Binary file not shown.
BIN
app/ipm/lib/linux/libR507A.so
Normal file
BIN
app/ipm/lib/linux/libR507A.so
Normal file
Binary file not shown.
BIN
app/ipm/lib/linux/libR717.so
Normal file
BIN
app/ipm/lib/linux/libR717.so
Normal file
Binary file not shown.
BIN
app/ipm/lib/linux/libR744.so
Normal file
BIN
app/ipm/lib/linux/libR744.so
Normal file
Binary file not shown.
BIN
app/ipm/lib/linux/librefifc.so
Normal file
BIN
app/ipm/lib/linux/librefifc.so
Normal file
Binary file not shown.
@@ -101,7 +101,7 @@ class GenRefProperties(Structure):
|
||||
|
||||
|
||||
if os.name == 'nt':
|
||||
REFIFC_LIB_NAME = "refifc"
|
||||
REFIFC_LIB_NAME = "refifc.dll"
|
||||
else: # 'posix'
|
||||
REFIFC_LIB_NAME = "librefifc.so"
|
||||
|
||||
@@ -113,10 +113,10 @@ class Refifc(object):
|
||||
# Sauvegardez le répertoire courant pour pouvoir y revenir plus tard
|
||||
self.original_directory = os.getcwd()
|
||||
# Determine candidate directories for the native library. Prefer
|
||||
# app/ipm/lib/<platform> if present, otherwise fall back to the
|
||||
# package directory (for compatibility with older layouts).
|
||||
# app/ipm/lib/dll (Windows) or app/ipm/lib/so (POSIX) if present,
|
||||
# otherwise fall back to the package directory (for compatibility).
|
||||
package_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
platform_dir = os.path.join(package_dir, 'lib', 'windows' if os.name == 'nt' else 'linux')
|
||||
platform_dir = os.path.join(package_dir, 'lib', 'dll' if os.name == 'nt' else 'so')
|
||||
dll_directory = platform_dir if os.path.isdir(platform_dir) else package_dir
|
||||
|
||||
# Change working directory to the chosen directory while loading
|
||||
@@ -124,13 +124,22 @@ class Refifc(object):
|
||||
|
||||
# Try to load the native library from the chosen directory; if that
|
||||
# fails, attempt to load by name (for system-installed libs) and
|
||||
# otherwise raise the original exception.
|
||||
# otherwise raise the original exception. Use RTLD_GLOBAL on POSIX
|
||||
# to make symbols available for dependent shared objects.
|
||||
try:
|
||||
self.lib = ctypes.cdll.LoadLibrary(os.path.join(dll_directory, REFIFC_LIB_NAME))
|
||||
full_lib_path = os.path.join(dll_directory, REFIFC_LIB_NAME)
|
||||
if os.name == 'nt':
|
||||
self.lib = ctypes.cdll.LoadLibrary(full_lib_path)
|
||||
else:
|
||||
# Use RTLD_GLOBAL so dependent .so files can resolve symbols
|
||||
self.lib = ctypes.CDLL(full_lib_path, mode=ctypes.RTLD_GLOBAL)
|
||||
except OSError:
|
||||
try:
|
||||
self.lib = ctypes.cdll.LoadLibrary(REFIFC_LIB_NAME)
|
||||
except Exception as e:
|
||||
if os.name == 'nt':
|
||||
self.lib = ctypes.cdll.LoadLibrary(REFIFC_LIB_NAME)
|
||||
else:
|
||||
self.lib = ctypes.CDLL(REFIFC_LIB_NAME, mode=ctypes.RTLD_GLOBAL)
|
||||
except Exception:
|
||||
# Restore cwd before raising
|
||||
os.chdir(self.original_directory)
|
||||
raise
|
||||
@@ -145,12 +154,24 @@ class Refifc(object):
|
||||
try:
|
||||
ctypes.CDLL(os.path.join(dll_directory, REFIFC_LIB_NAME))
|
||||
except OSError:
|
||||
# best-effort warning; not fatal here (the main loader already succeeded)
|
||||
print(f"Refrig {refrig_name} not found, please check!")
|
||||
|
||||
func = self.lib.refdll_load
|
||||
func.restype = POINTER(c_void_p)
|
||||
func.argtypes = [c_char_p, c_void_p]
|
||||
self.handle = func(c_char_p(refrig_name.encode('utf-8')), c_void_p())
|
||||
# On POSIX the native loader often expects the full SO filename
|
||||
# (e.g. "libR290.so"). We built `ctypes_refrig_name` above to match
|
||||
# that convention; use it when calling the native loader.
|
||||
name_to_pass = ctypes_refrig_name if ctypes_refrig_name else refrig_name
|
||||
try:
|
||||
self.handle = func(c_char_p(name_to_pass.encode('utf-8')), c_void_p())
|
||||
finally:
|
||||
# restore cwd even if the native call raises
|
||||
try:
|
||||
os.chdir(self.original_directory)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# def __del__(self):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user