Merge pull request #234994 from layus/autopatchelf-single-files

autoPatchelfHook: Add support for single files

authored by Guillaume Maudoux and committed by GitHub 9c289b42 7443b1ef

+17 -5
+17 -5
pkgs/build-support/setup-hooks/auto-patchelf.py
··· 109 109 110 110 111 111 def glob(path: Path, pattern: str, recursive: bool) -> Iterator[Path]: 112 - return path.rglob(pattern) if recursive else path.glob(pattern) 112 + if path.is_dir(): 113 + return path.rglob(pattern) if recursive else path.glob(pattern) 114 + else: 115 + # path.glob won't return anything if the path is not a directory. 116 + # We extend that behavior by matching the file name against the pattern. 117 + # This allows to pass single files instead of dirs to auto_patchelf, 118 + # for greater control on the files to consider. 119 + return [path] if path.match(pattern) else [] 113 120 114 121 115 122 cached_paths: Set[Path] = set() ··· 305 312 "--no-recurse", 306 313 dest="recursive", 307 314 action="store_false", 308 - help="Patch only the provided paths, and ignore their children") 315 + help="Disable the recursive traversal of paths to patch.") 309 316 parser.add_argument( 310 317 "--paths", nargs="*", type=Path, 311 - help="Paths whose content needs to be patched.") 318 + help="Paths whose content needs to be patched." 319 + " Single files and directories are accepted." 320 + " Directories are traversed recursively by default.") 312 321 parser.add_argument( 313 322 "--libs", nargs="*", type=Path, 314 - help="Paths where libraries are searched for.") 323 + help="Paths where libraries are searched for." 324 + " Single files and directories are accepted." 325 + " Directories are not searched recursively.") 315 326 parser.add_argument( 316 327 "--runtime-dependencies", nargs="*", type=Path, 317 - help="Paths to prepend to the runtime path of executable binaries.") 328 + help="Paths to prepend to the runtime path of executable binaries." 329 + " Subject to deduplication, which may imply some reordering.") 318 330 parser.add_argument( 319 331 "--append-rpaths", 320 332 nargs="*",