Skip to content

Commit c84d80e

Browse files
Add ability to pass wildcard arguments to --exclude (#508)
* Add ability to pass wildcard arguments to --exclude Fixes #500 * Test sequences * add comment about wheel metadata --------- Co-authored-by: mayeut <[email protected]>
1 parent 5ba0b78 commit c84d80e

File tree

4 files changed

+25
-3
lines changed

4 files changed

+25
-3
lines changed

src/auditwheel/lddtree.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import glob
2020
import logging
2121
import os
22+
from fnmatch import fnmatch
2223
from pathlib import Path
2324
from typing import Any
2425

@@ -405,7 +406,7 @@ def lddtree(
405406
elif t.entry.d_tag == "DT_RUNPATH":
406407
runpaths = parse_ld_paths(t.runpath, path=path, root=root)
407408
elif t.entry.d_tag == "DT_NEEDED":
408-
if t.needed in exclude:
409+
if any(fnmatch(t.needed, e) for e in exclude):
409410
log.info(f"Excluding {t.needed}")
410411
else:
411412
libs.append(t.needed)

src/auditwheel/main_repair.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,10 @@ def configure_parser(sub_parsers):
8989
"--exclude",
9090
dest="EXCLUDE",
9191
help="Exclude SONAME from grafting into the resulting wheel "
92-
"(can be specified multiple times)",
92+
"Please make sure wheel metadata reflects your dependencies. "
93+
"See https://github.com/pypa/auditwheel/pull/411#issuecomment-1500826281 "
94+
"(can be specified multiple times) "
95+
"(can contain wildcards, for example libfoo.so.*)",
9396
action="append",
9497
default=[],
9598
)

src/auditwheel/repair.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import shutil
99
import stat
1010
from collections.abc import Iterable
11+
from fnmatch import fnmatch
1112
from os.path import abspath, basename, dirname, exists, isabs
1213
from os.path import join as pjoin
1314
from pathlib import Path
@@ -70,7 +71,7 @@ def repair_wheel(
7071
ext_libs: dict[str, str] = v[abis[0]]["libs"]
7172
replacements: list[tuple[str, str]] = []
7273
for soname, src_path in ext_libs.items():
73-
assert soname not in exclude
74+
assert not any(fnmatch(soname, e) for e in exclude)
7475

7576
if src_path is None:
7677
raise ValueError(

tests/integration/test_bundled_wheels.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,23 @@
2525
[
2626
("cffi-1.5.0-cp27-none-linux_x86_64.whl", {"libffi.so.5"}, frozenset()),
2727
("cffi-1.5.0-cp27-none-linux_x86_64.whl", set(), frozenset(["libffi.so.5"])),
28+
(
29+
"cffi-1.5.0-cp27-none-linux_x86_64.whl",
30+
{"libffi.so.5"},
31+
frozenset(["libffi.so.noexist", "libnoexist.so.*"]),
32+
),
33+
(
34+
"cffi-1.5.0-cp27-none-linux_x86_64.whl",
35+
set(),
36+
frozenset(["libffi.so.[4,5]"]),
37+
),
38+
(
39+
"cffi-1.5.0-cp27-none-linux_x86_64.whl",
40+
{"libffi.so.5"},
41+
frozenset(["libffi.so.[6,7]"]),
42+
),
43+
("cffi-1.5.0-cp27-none-linux_x86_64.whl", set(), frozenset(["libffi.so.*"])),
44+
("cffi-1.5.0-cp27-none-linux_x86_64.whl", set(), frozenset(["*"])),
2845
(
2946
"python_snappy-0.5.2-pp260-pypy_41-linux_x86_64.whl",
3047
{"libsnappy.so.1"},

0 commit comments

Comments
 (0)