11"""
22Library loading utilities
33
4- Takes care only on loading the needed compiled libraries .
4+ Takes care only on loading the needed compiled library .
55"""
66
77import os
@@ -40,16 +40,17 @@ def _load_single_library(lib_name: str, search_paths: list[Path]) -> Optional[ct
4040 logger .error (f"Failed to load library from { lib_path } : { e } " )
4141 return None
4242
43- def dynamically_load_library (lib_name : Optional [str ] = None , load_c2pa : bool = True ) -> Tuple [ Optional [ctypes .CDLL ], Optional [ ctypes . CDLL ] ]:
43+ def dynamically_load_library (lib_name : Optional [str ] = None ) -> Optional [ctypes .CDLL ]:
4444 """
45- Load the dynamic libraries based on the platform.
45+ Load the dynamic library containing the C-API based on the platform.
4646
4747 Args:
4848 lib_name: Optional specific library name to load. If provided, only this library will be loaded.
49- load_c2pa: Whether to load the c2pa library (default: True). Ignored if lib_name is provided.
49+ This enables to potentially load wrapper libraries of the C-API that may have an other name
50+ (the presence of required symbols will nevertheless be verified once the library is loaded).
5051
5152 Returns:
52- Tuple of (adobe_lib, c2pa_lib). If load_c2pa is False or lib_name is provided, c2pa_lib will be None.
53+ The loaded library or None if loading failed
5354 """
5455 if sys .platform == "darwin" :
5556 c2pa_lib_name = "libc2pa_c.dylib"
@@ -67,7 +68,7 @@ def dynamically_load_library(lib_name: Optional[str] = None, load_c2pa: bool = T
6768 try :
6869 lib = _load_single_library (env_lib_name , possible_paths )
6970 if lib :
70- return lib , None
71+ return lib
7172 else :
7273 logger .error (f"Could not find library { env_lib_name } in any of the search paths" )
7374 # Continue with normal loading if environment variable library name fails
@@ -94,10 +95,9 @@ def dynamically_load_library(lib_name: Optional[str] = None, load_c2pa: bool = T
9495 raise RuntimeError (f"Could not find { lib_name } in any of the search paths" )
9596 return lib
9697
97- c2pa_lib = None
98- if load_c2pa :
99- c2pa_lib = _load_single_library (c2pa_lib_name , possible_paths )
100- if not c2pa_lib :
101- raise RuntimeError (f"Could not find { c2pa_lib_name } in any of the search paths" )
98+ # Default paht (no library name provided in the environment)
99+ c2pa_lib = _load_single_library (c2pa_lib_name , possible_paths )
100+ if not c2pa_lib :
101+ raise RuntimeError (f"Could not find { c2pa_lib_name } in any of the search paths" )
102102
103103 return c2pa_lib
0 commit comments