···167 found: bool = False # Whether it was found somewhere
168169170-def auto_patchelf_file(path: Path, runtime_deps: list[Path]) -> list[Dependency]:
171 try:
172 with open_elf(path) as elf:
173···235 dependencies.append(Dependency(path, dep, False))
236 print(f" {dep} -> not found!")
23700238 # Dedup the rpath
239 rpath_str = ":".join(dict.fromkeys(map(Path.as_posix, rpath)))
240···251 paths_to_patch: List[Path],
252 lib_dirs: List[Path],
253 runtime_deps: List[Path],
254- recursive: bool =True,
255- ignore_missing: List[str] = []) -> None:
0256257 if not paths_to_patch:
258 sys.exit("No paths to patch, stopping.")
···265 dependencies = []
266 for path in chain.from_iterable(glob(p, '*', recursive) for p in paths_to_patch):
267 if not path.is_symlink() and path.is_file():
268- dependencies += auto_patchelf_file(path, runtime_deps)
269270 missing = [dep for dep in dependencies if not dep.found]
271···312 parser.add_argument(
313 "--runtime-dependencies", nargs="*", type=Path,
314 help="Paths to prepend to the runtime path of executable binaries.")
000000315316 print("automatically fixing dependencies for ELF files")
317 args = parser.parse_args()
···322 args.libs,
323 args.runtime_dependencies,
324 args.recursive,
325- args.ignore_missing)
0326327328interpreter_path: Path = None # type: ignore
···167 found: bool = False # Whether it was found somewhere
168169170+def auto_patchelf_file(path: Path, runtime_deps: list[Path], append_rpaths: List[Path] = []) -> list[Dependency]:
171 try:
172 with open_elf(path) as elf:
173···235 dependencies.append(Dependency(path, dep, False))
236 print(f" {dep} -> not found!")
237238+ rpath.extend(append_rpaths)
239+240 # Dedup the rpath
241 rpath_str = ":".join(dict.fromkeys(map(Path.as_posix, rpath)))
242···253 paths_to_patch: List[Path],
254 lib_dirs: List[Path],
255 runtime_deps: List[Path],
256+ recursive: bool = True,
257+ ignore_missing: List[str] = [],
258+ append_rpaths: List[Path] = []) -> None:
259260 if not paths_to_patch:
261 sys.exit("No paths to patch, stopping.")
···268 dependencies = []
269 for path in chain.from_iterable(glob(p, '*', recursive) for p in paths_to_patch):
270 if not path.is_symlink() and path.is_file():
271+ dependencies += auto_patchelf_file(path, runtime_deps, append_rpaths)
272273 missing = [dep for dep in dependencies if not dep.found]
274···315 parser.add_argument(
316 "--runtime-dependencies", nargs="*", type=Path,
317 help="Paths to prepend to the runtime path of executable binaries.")
318+ parser.add_argument(
319+ "--append-rpaths",
320+ nargs="*",
321+ type=Path,
322+ help="Paths to append to all runtime paths unconditionally",
323+ )
324325 print("automatically fixing dependencies for ELF files")
326 args = parser.parse_args()
···331 args.libs,
332 args.runtime_dependencies,
333 args.recursive,
334+ args.ignore_missing,
335+ append_rpaths=args.append_rpaths)
336337338interpreter_path: Path = None # type: ignore
+3-1
pkgs/build-support/setup-hooks/auto-patchelf.sh
···61 ignoreMissingDepsArray=( "*" )
62 fi
63064 local runtimeDependenciesArray=($runtimeDependencies)
65 @pythonInterpreter@ @autoPatchelfScript@ \
66 ${norecurse:+--no-recurse} \
···68 --paths "$@" \
69 --libs "${autoPatchelfLibs[@]}" \
70 "${extraAutoPatchelfLibs[@]}" \
71- --runtime-dependencies "${runtimeDependenciesArray[@]/%//lib}"
072}
7374# XXX: This should ultimately use fixupOutputHooks but we currently don't have
···61 ignoreMissingDepsArray=( "*" )
62 fi
6364+ local appendRunpathsArray=($appendRunpaths)
65 local runtimeDependenciesArray=($runtimeDependencies)
66 @pythonInterpreter@ @autoPatchelfScript@ \
67 ${norecurse:+--no-recurse} \
···69 --paths "$@" \
70 --libs "${autoPatchelfLibs[@]}" \
71 "${extraAutoPatchelfLibs[@]}" \
72+ --runtime-dependencies "${runtimeDependenciesArray[@]/%//lib}" \
73+ --append-rpaths "${appendRunpathsArray[@]}"
74}
7576# XXX: This should ultimately use fixupOutputHooks but we currently don't have