INNER CODE UNIT · Python

ensure_loader_name

mumu-lhl/Ciyue · tools/bundle_linux_dependencies.py:114

def ensure_loader_name(library_dir: Path, name: str, source: Path) -> Path:
    destination = library_dir / name
    if destination.exists() or destination.is_symlink():
        return destination

    if source.parent == library_dir:
        destination.symlink_to(source.name)
        return destination

    shutil.copy2(source.resolve(), destination)
    patchelf = shutil.which("patchelf")
    if patchelf:
        subprocess.run([patchelf, "--remove-rpath", str(destination)], check=True)
    return destination


def collect(bundle_dir: Path, search_roots: list[Path]) -> None:
    library_dir = bundle_dir / "lib"

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…