c2pa.lib¶
Library loading utilities
Takes care only on loading the needed compiled library.
Attributes¶
Classes¶
CPU architecture enum for platform-specific identifiers. |
Functions¶
Get the platform identifier (arch-os) for the current system, |
|
|
Load the dynamic library containing the C-API based on the platform. |
|
Keep the PID that created this native-handle wrapper |
|
Return True when this object is being finalized in a forked child that did not |
Module Contents¶
- c2pa.lib.DEBUG_LIBRARY_LOADING = False¶
- c2pa.lib.logger¶
- class c2pa.lib.CPUArchitecture¶
Bases:
enum.EnumCPU architecture enum for platform-specific identifiers.
- AARCH64 = 'aarch64'¶
- X86_64 = 'x86_64'¶
- ARM64 = 'arm64'¶
- c2pa.lib.get_platform_identifier()¶
Get the platform identifier (arch-os) for the current system, matching the downloaded identifiers used by the Github publisher.
Returns one of: - universal-apple-darwin (for Mac universal) - aarch64-apple-darwin (for Mac ARM64) - x86_64-apple-darwin (for Mac x86_64) - x86_64-pc-windows-msvc (for Windows x64) - aarch64-pc-windows-msvc (for Windows ARM64) - x86_64-unknown-linux-gnu (for Linux 64-bit) - aarch64-unknown-linux-gnu (for Linux ARM)
- Return type:
str
- c2pa.lib.dynamically_load_library(lib_name=None)¶
Load the dynamic library containing the C-API based on the platform.
- Parameters:
lib_name (Optional[str]) – Optional specific library name to load. If provided, only this library will be loaded.
libraries (This enables to potentially load wrapper)
name (of the C-API that may have an other)
nevertheless ((the presence of required symbols will)
loaded). (be verified once the library is)
- Returns:
The loaded library or None if loading failed
- Return type:
Optional[ctypes.CDLL]
- c2pa.lib.record_owner_pid(obj)¶
Keep the PID that created this native-handle wrapper (call from __init__ as needed).
- c2pa.lib.is_foreign_process(obj)¶
Return True when this object is being finalized in a forked child that did not create it. After a multithreaded fork(), native mutexes may be held by threads absent in the child -> any lock() call deadlocks. Callers must skip native frees when this returns True.
Skipping the free does not cause a cumulative leak. If the child calls exec() the address space is replaced entirely; if it exits, the OS reclaims all process memory. Even a long-lived fork child (e.g. a multiprocessing fork-start worker) leaks at most the objects inherited at fork time — a one-time, bounded amount reclaimed when the child terminates. Objects the child creates itself carry the child’s PID and are freed normally.
Defensive default: if _owner_pid was never set, returns False (no regression).