Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support to wildcard a path with --exclude #528

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/auditwheel/lddtree.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ def lddtree(
libs: list[str] = []
rpaths: list[str] = []
runpaths: list[str] = []
_excluded_libs: set[str] = set()
for segment in elf.iter_segments():
if segment.header.p_type != "PT_DYNAMIC":
continue
Expand All @@ -396,8 +397,11 @@ def lddtree(
elif t.entry.d_tag == "DT_RUNPATH":
runpaths = parse_ld_paths(t.runpath, path=path, root=root)
elif t.entry.d_tag == "DT_NEEDED":
if any(fnmatch(t.needed, e) for e in exclude):
if t.needed in _excluded_libs or any(
fnmatch(t.needed, e) for e in exclude
):
log.info("Excluding %s", t.needed)
_excluded_libs.add(t.needed)
else:
libs.append(t.needed)
if runpaths:
Expand All @@ -416,7 +420,6 @@ def lddtree(
log.debug(" ldpaths[runpath] = %s", runpaths)
ret["rpath"] = rpaths
ret["runpath"] = runpaths
ret["needed"] = libs

# Search for the libs this ELF uses.
all_ldpaths: list[str] | None = None
Expand All @@ -434,6 +437,10 @@ def lddtree(
+ ldpaths["interp"]
)
realpath, fullpath = find_lib(elf, lib, all_ldpaths, root)
if lib in _excluded_libs or any(fnmatch(realpath, e) for e in exclude):
log.info("Excluding %s", realpath)
_excluded_libs.add(lib)
continue
_all_libs[lib] = {
"realpath": realpath,
"path": fullpath,
Expand All @@ -453,4 +460,6 @@ def lddtree(

del elf

ret["needed"] = [lib for lib in libs if lib not in _excluded_libs]

return ret
5 changes: 5 additions & 0 deletions tests/integration/test_bundled_wheels.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
{"libffi.so.5"},
frozenset(["libffi.so.[6,7]"]),
),
(
"cffi-1.5.0-cp27-none-linux_x86_64.whl",
set(),
frozenset(["*/lib/libffi.so.5"]),
),
("cffi-1.5.0-cp27-none-linux_x86_64.whl", set(), frozenset(["libffi.so.*"])),
("cffi-1.5.0-cp27-none-linux_x86_64.whl", set(), frozenset(["*"])),
(
Expand Down