Registry / http-networking / dlinfo

dlinfo

JSON →
library2.0.0pypypi✓ verified 23d ago

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.

pip install dlinfo
INSTALL
IMPORT
SIG · DLINFO
D
dlinfo
http-networkingpythonv2.0.0
Install
1.5s avg
Import
44ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.040s · 17.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.5s · import 0.048s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

DLInfo
from dlinfo import DLInfo

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.")
Debug
Known issues
breakingVersion 2.0.0 removed compatibility with Python versions 3.5, 3.6, 3.7, and 3.8. Users on these older Python interpreters must remain on `dlinfo<2.0.0` or upgrade their Python environment to 3.9 or newer.
fix
Upgrade Python to version 3.9 or later, or pin `dlinfo` to `<2.0.0`.
affects: >=2.0.0
breakingAs of v2.0.0, the exception raised when the underlying `libc's dlinfo` function fails has changed from a generic `Exception` to a more specific `RuntimeError`. Update `except` blocks in your code accordingly.
fix
Change `except Exception:` to `except RuntimeError:` (or a more specific exception if applicable) for error handling related to `dlinfo` function failures.
affects: >=2.0.0
gotchaThe library's core functionality relies on system-level C libraries (`libc's dlinfo` on Linux and `dyld_find` on macOS). This means its behavior is inherently platform-dependent and may not work on other operating systems like Windows without a POSIX compatibility layer, or might yield different results.
fix
Ensure your deployment environment is Linux or macOS. Be aware of potential platform-specific differences in behavior and available information.
affects: <all>
gotchaThe usage pattern involves direct interaction with Python's `ctypes` module to load shared libraries. Incorrect paths, non-existent libraries, or issues with `ctypes.util.find_library()` can lead to `OSError` or `AttributeError` when attempting to create `DLInfo` instances or access its properties.
fix
Validate library paths and ensure the target shared library is accessible and correctly named for `ctypes.util.find_library()`. Add robust error handling around `ctypes` calls.
affects: <all>
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'dlinfo'
The 'dlinfo' package is not installed in your current Python environment.
fix
pip install dlinfo
Exception (or generic error handling) when dlinfo function fails with dlinfo>=2.0.0
As of dlinfo version 2.0.0, the exception raised for underlying C library failures changed from a generic 'Exception' to a more specific 'RuntimeError'.
fix
Update your exception handling to catch `RuntimeError` instead of or in addition to a generic `Exception`.

```python
try:
    # dlinfo usage
    pass
except RuntimeError as e:
    print(f"dlinfo operation failed: {e}")
```
dlinfo functionality not working or raising errors on Windows (or other non-Linux/macOS systems)
The dlinfo library is a Python wrapper for system-level C libraries (`libc's dlinfo` on Linux and `dyld_find` on macOS), making its core functionality inherently platform-dependent and not supported on Windows.
fix
Ensure your deployment environment is Linux or macOS. The library is not designed to work on Windows without a POSIX compatibility layer.
OSError or AttributeError when using dlinfo with ctypes.util.find_library() or DLInfo instantiation
This error typically occurs when the shared library path provided to `ctypes.util.find_library()` is incorrect, the library does not exist, or there are issues with the `ctypes` interaction when creating a `DLInfo` instance or accessing its properties.
fix
Validate that the shared library you are trying to load exists and its path is correct and accessible. Add robust error handling around `ctypes` calls and `DLInfo` instantiation.

```python
import ctypes
import ctypes.util
from dlinfo import DLInfo

lib_name = 'c'
lib_path = ctypes.util.find_library(lib_name)

if lib_path is None:
    print(f"Error: Could not find the '{lib_name}' library. Check if it's installed and in your system's library paths.")
else:
    try:
        lib = ctypes.cdll.LoadLibrary(lib_path)
        dlinfo_instance = DLInfo(lib)
        print(f"Library path: {dlinfo_instance.path}")
    except OSError as e:
        print(f"OSError loading library or creating DLInfo: {e}")
    except AttributeError as e:
        print(f"AttributeError accessing DLInfo properties: {e}")
```
dlinfo installation fails or import errors on Python 3.5, 3.6, 3.7, or 3.8 after upgrading dlinfo
Version 2.0.0 of the `dlinfo` library removed compatibility with Python versions 3.5, 3.6, 3.7, and 3.8.
fix
Upgrade your Python environment to version 3.9 or later, or if you must use an older Python version, pin the `dlinfo` library to a version less than 2.0.0 (e.g., `pip install dlinfo<2.0.0`).
Upgrade
Version history
2.0.0latest on PyPI · released Jan 16, 2025
Audit
Dependencies
pythonrequiredRequires Python 3.9 or higher for compatibility, as older versions (3.5-3.8) are no longer supported.
Agent activity
12 hits · last 30 days
node
10
OpenAI (training)
1
Resources
dlinfo — pip install dlinfo · libregistry