tl;dr: I propose to soft-deprecate ctypes.util.find_library in 3.15. It’ll stay where it is, but it won’t get developed further.
The purpose of the find_library() function, according to the docs is to locate a library in a way similar to what the compiler does. The word similar does a lot of heavy lifting.
Unfortunately, platforms don’t provide an API for this task, so the function ended up implemented as a bunch of heuristics, and so it has the typical problems of a heuristic-based function in stdlib:
- any change has a real chance of breaking working code
- it can practically never be complete (especially on unsupported OSes and “new” Linux configurations – containers, Nix, AppImage…)
I recently added an explicit warning that’s been implied by (old & stable) docs on Linux behaviour:
Note that if the output of [the programs
/sbin/ldconfig,gcc,objdump, andld] does not correspond to the dynamic linker used by Python, the result of this function may be misleading.
But, that’s far from the only case when it’s misleading.
It is time to officially tell users to consider something else – and possibly fork the function and build something else on PyPI, free from CPython’s platform support policy, release cadence, and problems with pinning a known-good version.
If find_library is blocking you from running some app on, say, musl [1], perhaps the app’s maintainers will be more likely to accept a PR if you show them that it’s is officially nailed to the perch.
or a system that mixes
musl&glibc, which is a real user need ↩︎