dlinfo

2.0.0 · active · verified Mon Apr 13

dlinfo is a Python wrapper for libc's dlinfo (on Linux) and dyld_find (on macOS), providing a way to inspect dynamically loaded shared objects. The current version is 2.0.0. The project maintains an active development status with regular updates for Python compatibility and bug fixes, typically with releases tied to significant changes or Python version support.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to load the C standard library using `ctypes`, create a `DLInfo` object, and retrieve the library's absolute file path and SONAME (if available). This is the primary usage pattern for `dlinfo`.

import ctypes
import ctypes.util
from dlinfo import DLInfo

# Load the C standard library
# This will typically find 'libc.so.6' on Linux or 'libc.dylib' on macOS
lib_path = ctypes.util.find_library('c')
if lib_path is None:
    print("Could not find the C standard library. This example may not run on your system.")
    # Exit gracefully or raise an error depending on desired behavior
else:
    lib = ctypes.cdll.LoadLibrary(lib_path)

    # Create a DLInfo instance
    dlinfo_instance = DLInfo(lib)

    # Get the path of the loaded library
    library_path = dlinfo_instance.path
    print(f"Path of 'c' library: {library_path}")

    # Example of getting SONAME (if available and applicable)
    # On some systems, DLInfo.soname might return None if not explicitly set by the library
    soname = dlinfo_instance.soname
    if soname:
        print(f"SONAME of 'c' library: {soname}")
    else:
        print("SONAME not explicitly available or not set for 'c' library.")

view raw JSON →