(
    lib_name: str, rpath: str, wheel_base_dir: str, patcher: ElfPatcher
)
Add a new rpath entry to a file while preserving as many existing
    rpath entries as possible.

    In order to preserve an rpath entry it must:

    1) Point to a location within wheel_base_dir.
    2) Not be a duplicate of an already-existing rpath entry.
Add a new rpath entry to a file while preserving as many existing
    rpath entries as possible.
Add a new rpath entry to a file while preserving as many existing rpath entries as possible .
def append_rpath_within_wheel(
    lib_name: str, rpath: str, wheel_base_dir: str, patcher: ElfPatcher
) -> None:
    """Add a new rpath entry to a file while preserving as many existing
    rpath entries as possible.

    In order to preserve an rpath entry it must:

    1) Point to a location within wheel_base_dir.
    2) Not be a duplicate of an already-existing rpath entry.
    """
    if not isabs(lib_name):
        lib_name = abspath(lib_name)
    lib_dir = dirname(lib_name)
    if not isabs(wheel_base_dir):
        wheel_base_dir = abspath(wheel_base_dir)

    def is_valid_rpath(rpath: str) -> bool:
        return _is_valid_rpath(rpath, lib_dir, wheel_base_dir)

    old_rpaths = patcher.get_rpath(lib_name)
    rpaths = filter(is_valid_rpath, old_rpaths.split(":"))
    # Remove duplicates while preserving ordering
    # Fake an OrderedSet using OrderedDict
    rpath_set = OrderedDict([(old_rpath, "") for old_rpath in rpaths])
    rpath_set[rpath] = ""

    patcher.set_rpath(lib_name, ":".join(rpath_set))
def append_rpath_within_wheel ( lib_name : str , rpath : str , wheel_base_dir : str , patcher : ElfPatcher ) -> None : if not isabs ( lib_name ) : lib_name = abspath ( lib_name ) lib_dir = dirname ( lib_name ) if not isabs ( wheel_base_dir ) : wheel_base_dir = abspath ( wheel_base_dir ) def is_valid_rpath ( rpath : str ) -> bool : return _is_valid_rpath ( rpath , lib_dir , wheel_base_dir ) old_rpaths = patcher . get_rpath ( lib_name ) rpaths = filter ( is_valid_rpath , old_rpaths . split ( ":" ) ) # Remove duplicates while preserving ordering # Fake an OrderedSet using OrderedDict rpath_set = OrderedDict ( [ ( old_rpath , "" ) for old_rpath in rpaths ] ) rpath_set [ rpath ] = "" patcher . set_rpath ( lib_name , ":" . join ( rpath_set ) )