Skip to main content

findlibs

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_name str - Library name without the lib prefix. The name of the library to find is formed using lib_name and a platform specific suffix (by default ".so"). E.g. when lib_name is "eccodes" the library name will be "libeccodes.so" on Linux and "libeccodes.dylib" on macOS.
  • pkg_name str, 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 lib and lib64 directories under sys.prefix and $CONDA_PREFIX. Disable this search option by setting environment variable FINDLIBS_DISABLE_PYTHON=yes.

  • Next, tries the lib and lib64 directories under the paths defined by the pkg_name + "_HOME" and pkg_name + "_DIR" environment variables. Both lowercase and uppercase versions are tested. E.g. if pkg_name is "eccodes" it will check the paths defined by $eccodes_dir, $eccodes_home, $ECCODES_DIR and $ECCODES_HOME. Disable this search option by setting environment variable FINDLIBS_DISABLE_HOME=yes.

  • Next, tries to load the search paths from the user defined ~/.findlibs or ~/.config/findlibs/findlibs.conf INI configuration files. Then for all the user defined search paths, the lib and lib64 subdirectories are tried.

    Please note that only one of these files can exist. The configuration file can contain multiple search paths, but no relative paths or paths to files are allowed. The file can even be completely empty or can contain no paths at all. The file format is as follows:

    [Paths]
    /path/to/lib_directory
    

    Disable this search option by setting environment variable FINDLIBS_DISABLE_CONFIG_PATHS=yes.

  • Next, tries the directories defined by the $LD_LIBRARY_PATH and $DYLD_LIBRARY_PATH environment variables. Disable this search option by setting environment variable FINDLIBS_DISABLE_LD_PATH=yes.

  • Next, tries the lib and lib64 directories under the following paths "/", "/usr/", "/usr/local/", "/opt/", "/opt/homebrew/" and "~/.local/". Disable this search option by setting environment variable FINDLIBS_DISABLE_SYS=yes.

  • Finally, tries calling the ctypes.util.find_library function. Disable this search option by setting environment variable FINDLIBS_DISABLE_CTYPES_UTIL=yes.

Metadata

Release files for findlibs 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for findlibs 0.1.3
File Size Uploaded
findlibs-0.1.3.tar.gz 11.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for findlibs 0.1.3
File Interpreter ABI Platform
findlibs-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 22.0 kB

Release files / findlibs-0.1.3.tar.gz

Download URL findlibs-0.1.3.tar.gz
Size 11.3 kB
Tags Source
SHA-256 checksum
How to use checksums
49bbe509c8b439ecd9c0d021c301aa9db643a2e6ab4e189a40b505ee4a49db62
BLAKE2b-256 checksum
How to use checksums
9121235e81c0e29a5aa84e5374d469723d508de63692049e80654b1b56d1c57e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.6

Release files / findlibs-0.1.3-py3-none-any.whl

Download URL findlibs-0.1.3-py3-none-any.whl
Size 10.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9c14f8506cdcd37e38369259f8cd9aa3c002d58cd7c2beff4852bd205495c555
BLAKE2b-256 checksum
How to use checksums
d11363305a756cb6e9408828961d4ff8542f3625d7cfb62289b19016216a9fa2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.6

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.5

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page