[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Python C-library import paths



On Sat, 02 Apr 2022 at 12:55:37 +0100, Wookey wrote:
> On 2022-04-01 00:30 -0400, M. Zhou wrote:
> > They have written
> > their own ffi loader, so I think it is an upstream bug. The upstream
> > should detect and add multiarch directory to the paths.
>
> A correct implemntation really should use the full ldconfig set of search paths.

I think what they should actually be doing on Linux (at least in distro
packages) is taking a step back from all these attempts to reproduce
the system's search path for public shared libraries, and instead doing
this in https://github.com/apache/tvm/blob/main/python/tvm/_ffi/base.py:

    ctypes.CDLL('libtvm.so.0')

which will (ask glibc to) do the correct path search, in something like
99% less code.

Maybe all this complexity is needed on Windows or in a "relocatable"
package, but for a distro package it's completely unnecessary and
sometimes harmful.

> I also don't think it should use the $PATH paths for finding
> libraries (but maybe upstream have some reason for doing that)

I suspect the reason is: on Windows, PATH is the equivalent of Linux PATH,
but it also has a dual role as the equivalent of Linux LD_LIBRARY_PATH.

    smcv


Reply to: