A package to search for shared libraries on various platforms
Maintained. Last release 4 weeks ago, commits in 6 of the last 26 weeks.
pip install findlibsfindlibs
A Python package that searches for shared libraries on various platforms.
Usage
import findlibs
lib = findlibs.find("eccodes")
# If package name differs from library name use:
lib = findlibs.find(lib_name="odccore", pkg_name="odc")
Installation
pip install findlibs
Testing
git clone https://github.com/ecmwf/findlibs
cd findlibs
pip install -e ".[test]"
pytest
find
The module only contains the find() function.
def find(lib_name, pkg_name=None)
Returns the path to the selected library, or None if not found.
Arguments:
lib_namestr - Library name without thelibprefix. The name of the library to find is formed usinglib_nameand a platform specific suffix (by default ".so"). E.g. whenlib_nameis "eccodes" the library name will be "libeccodes.so" on Linux and "libeccodes.dylib" on macOS.pkg_namestr, optional - Package name if it differs from the library name.
Returns:
str or None: Path to selected library
The algorithm to find the library is as follows:
-
First, tries to find the library in an installed python module package with the given name, e.g. eccodeslib, eckitlib. Disable this search option by setting environment variable
FINDLIBS_DISABLE_PACKAGE=yes. -
Next, tries the
libandlib64directories undersys.prefixand$CONDA_PREFIX. Disable this search option by setting environment variableFINDLIBS_DISABLE_PYTHON=yes. -
Next, tries the
libandlib64directories under the paths defined by thepkg_name + "_HOME"andpkg_name + "_DIR"environment variables. Both lowercase and uppercase versions are tested. E.g. ifpkg_nameis "eccodes" it will check the paths defined by$eccodes_dir,$eccodes_home,$ECCODES_DIRand$ECCODES_HOME. Disable this search option by setting environment variable .