ITADN

Python `find_library`

#76Opencarschandler 创建于 2024-07-15
C
carschandlercommented
I have been testing out `nix-ld-rs` with the `pixi` package manager, which is similar to `conda`. I've been having success so far by just adding the libraries as needed on the spot as I find them, but what I've come across now is a package that uses `find_library()` from the builtin `ctypes.util` Python module. This method [tries a few options](https://github.com/python/cpython/blob/94bee45dee41876e88fe023b9163178d376355dc/Lib/ctypes/util.py#L339-L342) starting by using a hardcoded `/sbin/ldconfig`, then trying to use `gcc -t`, and finally by using `LD_LIBRARY_PATH`. `LD_LIBRARY_PATH` would in theory be compatiple with `nix-ld-rs` but it finds the library by spawning a new shell process that uses `ld` to try to find the library. Because a standard nix install does not contain `ld`, though, this fails. If I make `ld` available via nix, then it warns about not being able to find `ld-linux-x86-64.so.2` which to my understanding is because `nix-ld-rs` doesn't "activate" for nix programs. What's the best way to get this function working in a `nix-ld` setup?
0 条评论