(src_path: str, dest_dir: str, patcher: ElfPatcher)
return new_soname, dest_path
Graft a shared library from the system into the wheel and update the
    relevant links.

    1) Copy the file from src_path to dest_dir/
    2) Rename the shared object from soname to soname.<unique>
    3) If the library has a RUNPATH/RPATH, clear it and set RPATH to point to
    its new location.
Graft a shared library from the system into the wheel and update the
    relevant links.
Graft a shared library from the system into the wheel and update the relevant links .
def copylib(src_path: str, dest_dir: str, patcher: ElfPatcher) -> Tuple[str, str]:
    """Graft a shared library from the system into the wheel and update the
    relevant links.

    1) Copy the file from src_path to dest_dir/
    2) Rename the shared object from soname to soname.<unique>
    3) If the library has a RUNPATH/RPATH, clear it and set RPATH to point to
    its new location.
    """
    # Copy the a shared library from the system (src_path) into the wheel
    # if the library has a RUNPATH/RPATH we clear it and set RPATH to point to
    # its new location.

    with open(src_path, "rb") as f:
        shorthash = hashfile(f)[:8]

    src_name = os.path.basename(src_path)
    base, ext = src_name.split(".", 1)
    if not base.endswith("-%s" % shorthash):
        new_soname = f"{base}-{shorthash}.{ext}"
    else:
        new_soname = src_name

    dest_path = os.path.join(dest_dir, new_soname)
    if os.path.exists(dest_path):
        return new_soname, dest_path

    logger.debug("Grafting: %s -> %s", src_path, dest_path)
    rpaths = elf_read_rpaths(src_path)
    shutil.copy2(src_path, dest_path)
    statinfo = os.stat(dest_path)
    if not statinfo.st_mode & stat.S_IWRITE:
        os.chmod(dest_path, statinfo.st_mode | stat.S_IWRITE)

    patcher.set_soname(dest_path, new_soname)

    if any(itertools.chain(rpaths["rpaths"], rpaths["runpaths"])):
        patcher.set_rpath(dest_path, dest_dir)

    return new_soname, dest_path
def copylib ( src_path : str , dest_dir : str , patcher : ElfPatcher ) -> Tuple [ str , str ] : # Copy the a shared library from the system (src_path) into the wheel # if the library has a RUNPATH/RPATH we clear it and set RPATH to point to # its new location. with open ( src_path , "rb" ) as f : shorthash = hashfile ( f ) [ : 8 ] src_name = os . path . basename ( src_path ) base , ext = src_name . split ( "." , 1 ) if not base . endswith ( "-%s" % shorthash ) : new_soname = f"{base}-{shorthash}.{ext}" else : new_soname = src_name dest_path = os . path . join ( dest_dir , new_soname ) if os . path . exists ( dest_path ) : return new_soname , dest_path logger . debug ( "Grafting: %s -> %s" , src_path , dest_path ) rpaths = elf_read_rpaths ( src_path ) shutil . copy2 ( src_path , dest_path ) statinfo = os . stat ( dest_path ) if not statinfo . st_mode & stat . S_IWRITE : os . chmod ( dest_path , statinfo . st_mode | stat . S_IWRITE ) patcher . set_soname ( dest_path , new_soname ) if any ( itertools . chain ( rpaths [ "rpaths" ] , rpaths [ "runpaths" ] ) ) : patcher . set_rpath ( dest_path , dest_dir ) return new_soname , dest_path