FindLibs
FindLibs is a Python package designed to search for shared libraries across various platforms. It offers a robust search algorithm that includes checking Python module packages, system prefixes, environment variables, user-defined configuration files, and standard system paths. The current version is 0.1.2. It appears to be actively maintained by ECMWF, with regular updates and engagement on GitHub issues.
Warnings
- breaking Versions 0.1.0 and later of `findlibs` utilize Union type expressions, which are only supported in Python 3.10 and newer. However, the package classifiers on PyPI may incorrectly allow installation on Python versions as low as 3.6, 3.7, and 3.8. Attempting to use `findlibs` on Python < 3.10 will lead to runtime errors.
- gotcha While `findlibs` uses a comprehensive search strategy, its fallback mechanism includes `ctypes.util.find_library`. This underlying function is based on heuristics, which can be unreliable and prone to breaking changes or misleading results, especially on non-standard or newer Linux configurations (e.g., musl, Nix, AppImage) or platforms where Python's dynamic linker behavior doesn't align with system tools. The Python core development team is considering a 'soft deprecation' of `ctypes.util.find_library` in Python 3.15, indicating it will not be further developed and users should consider alternatives for robust library finding.
- gotcha Users on Ubuntu 20.04 and 24.04 have reported issues where `findlibs 0.1.0` returns an empty path for libraries like `eccodes.so`, even when the library is expected to be present. This indicates potential platform-specific issues with the search algorithm or expected library naming conventions on certain Linux distributions.
Install
-
pip install findlibs
Imports
- find
from findlibs import find
Quickstart
from findlibs import find
# Example: Try to find a common library like 'eccodes'
# Replace 'eccodes' with a library relevant to your system if it's not found
lib_path = find("eccodes")
if lib_path:
print(f"Found library at: {lib_path}")
else:
print("Library not found.")
# You can also specify a package name if it differs from the library name
# lib_path_with_pkg = find("mylib", pkg_name="my_python_package")
# if lib_path_with_pkg:
# print(f"Found 'mylib' via 'my_python_package' at: {lib_path_with_pkg}")