{"id":4943,"library":"findlibs","title":"FindLibs","description":"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.","status":"active","version":"0.1.2","language":"en","source_language":"en","source_url":"https://github.com/ecmwf/findlibs","tags":["shared libraries","native libraries","ffi","platform","ctypes"],"install":[{"cmd":"pip install findlibs","lang":"bash","label":"Install FindLibs"}],"dependencies":[{"reason":"Requires Python 3.10 or higher due to the use of Union type expressions.","package":"python"}],"imports":[{"symbol":"find","correct":"from findlibs import find"}],"quickstart":{"code":"from findlibs import find\n\n# Example: Try to find a common library like 'eccodes'\n# Replace 'eccodes' with a library relevant to your system if it's not found\nlib_path = find(\"eccodes\")\nif lib_path:\n    print(f\"Found library at: {lib_path}\")\nelse:\n    print(\"Library not found.\")\n\n# You can also specify a package name if it differs from the library name\n# lib_path_with_pkg = find(\"mylib\", pkg_name=\"my_python_package\")\n# if lib_path_with_pkg:\n#     print(f\"Found 'mylib' via 'my_python_package' at: {lib_path_with_pkg}\")","lang":"python","description":"This quickstart demonstrates how to import the `find` function and use it to locate a shared library by its base name. The function returns the full path to the library if found, otherwise `None`. You can optionally provide `pkg_name` if the library is associated with a specific Python package name different from the library's base name."},"warnings":[{"fix":"Ensure your Python environment is version 3.10 or higher. If you must use an older Python, you may need to pin `findlibs` to an earlier version if one exists that supports it (though none are explicitly stated to do so in the search results) or consider using an alternative library. Update your `pyproject.toml` or `requirements.txt` to specify `python_version >= '3.10'` for `findlibs`.","message":"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.","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"Be aware that library detection, especially as a last resort, might fail or be incorrect. If `findlibs` cannot locate a library, manually provide the path through environment variables (e.g., `LD_LIBRARY_PATH`, `DYLD_LIBRARY_PATH`, `PKG_NAME_HOME`/`_DIR`) or a `~/.findlibs` configuration file, as these take precedence in `findlibs`'s search algorithm.","message":"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.","severity":"gotcha","affected_versions":"All versions of `findlibs` that rely on `ctypes.util.find_library` (which appears to be all versions based on the README)."},{"fix":"If `findlibs` fails to locate a library on Linux, verify the library's actual location and exact filename. Utilize `findlibs`'s configurable search paths, such as setting `PKG_NAME_HOME` or `PKG_NAME_DIR` environment variables (e.g., `ECCODES_HOME`), or defining paths in `~/.findlibs` or `~/.config/findlibs/findlibs.conf`, to explicitly guide `findlibs` to the library's directory.","message":"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.","severity":"gotcha","affected_versions":"0.1.0 (and potentially later versions due to underlying platform differences)"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}