Skip to content

Commit

Permalink
Add --exclude option
Browse files Browse the repository at this point in the history
This allows not including libraries like OpenGL or Vulkan which are
provided by the OS
  • Loading branch information
rossant authored and martinRenou committed Mar 8, 2022
1 parent f3c7691 commit 27939cf
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/auditwheel/main_repair.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ def configure_parser(sub_parsers):
help="Strip symbols in the resulting wheel",
default=False,
)
p.add_argument(
"--exclude",
dest="EXCLUDE",
help="List of excluded sonames as a comma-separated string",
default=''
)
p.add_argument(
"--only-plat",
dest="ONLY_PLAT",
Expand Down Expand Up @@ -166,6 +172,7 @@ def execute(args, p):
update_tags=args.UPDATE_TAGS,
patcher=patcher,
strip=args.STRIP,
exclude=args.EXCLUDE.split(','),
)

if out_wheel is not None:
Expand Down
19 changes: 19 additions & 0 deletions src/auditwheel/repair.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@
).match


def _is_in_list(soname: str, items: Optional[List[str]]) -> Optional[str]:
for item in (items or []):
if item in soname:
return item

return None


def repair_wheel(
wheel_path: str,
abis: List[str],
Expand All @@ -38,6 +46,7 @@ def repair_wheel(
update_tags: bool,
patcher: ElfPatcher,
strip: bool = False,
exclude: List[str] = (),
) -> Optional[str]:

external_refs_by_fn = get_wheel_elfdata(wheel_path)[1]
Expand All @@ -52,6 +61,9 @@ def repair_wheel(

wheel_fname = basename(wheel_path)

# Remove empty strings in exclude list
exclude = [_.strip() for _ in (exclude or []) if _.strip()]

with InWheelCtx(wheel_path) as ctx:
ctx.out_wheel = pjoin(out_dir, wheel_fname)

Expand Down Expand Up @@ -79,6 +91,13 @@ def repair_wheel(
% soname
)

# exclude some libraries
exc = _is_in_list(soname, exclude)
if exc:
logger.info(
f'Excluding {soname} (match exclude string `{exc}`)')
continue

new_soname, new_path = copylib(src_path, dest_dir, patcher)
soname_map[soname] = (new_soname, new_path)
patcher.replace_needed(fn, soname, new_soname)
Expand Down

0 comments on commit 27939cf

Please sign in to comment.