From 50f9c55e8bde7935146c009bed07ccb1d6b7561b Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Tue, 23 Jul 2024 10:32:13 -0400 Subject: [PATCH 1/2] Add ability to pass wildcard arguments to --exclude Fixes https://github.com/pypa/auditwheel/issues/500 --- src/auditwheel/lddtree.py | 3 ++- src/auditwheel/main_repair.py | 3 ++- src/auditwheel/repair.py | 3 ++- tests/integration/test_bundled_wheels.py | 7 +++++++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/auditwheel/lddtree.py b/src/auditwheel/lddtree.py index 18064d87..cd529609 100644 --- a/src/auditwheel/lddtree.py +++ b/src/auditwheel/lddtree.py @@ -19,6 +19,7 @@ import glob import logging import os +from fnmatch import fnmatch from pathlib import Path from typing import Any @@ -405,7 +406,7 @@ 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 t.needed in exclude: + if any(fnmatch(t.needed, e) for e in exclude): log.info(f"Excluding {t.needed}") else: libs.append(t.needed) diff --git a/src/auditwheel/main_repair.py b/src/auditwheel/main_repair.py index 4374f208..47ad8be0 100644 --- a/src/auditwheel/main_repair.py +++ b/src/auditwheel/main_repair.py @@ -89,7 +89,8 @@ def configure_parser(sub_parsers): "--exclude", dest="EXCLUDE", help="Exclude SONAME from grafting into the resulting wheel " - "(can be specified multiple times)", + "(can be specified multiple times) " + "(can contain wildcards, for example libfoo.so.*)", action="append", default=[], ) diff --git a/src/auditwheel/repair.py b/src/auditwheel/repair.py index 85e3ca39..05bcf1ce 100644 --- a/src/auditwheel/repair.py +++ b/src/auditwheel/repair.py @@ -7,6 +7,7 @@ import re import shutil import stat +from fnmatch import fnmatch from os.path import abspath, basename, dirname, exists, isabs from os.path import join as pjoin from pathlib import Path @@ -70,7 +71,7 @@ def repair_wheel( ext_libs: dict[str, str] = v[abis[0]]["libs"] replacements: list[tuple[str, str]] = [] for soname, src_path in ext_libs.items(): - assert soname not in exclude + assert not any(fnmatch(soname, e) for e in exclude) if src_path is None: raise ValueError( diff --git a/tests/integration/test_bundled_wheels.py b/tests/integration/test_bundled_wheels.py index e83535b7..a650c093 100644 --- a/tests/integration/test_bundled_wheels.py +++ b/tests/integration/test_bundled_wheels.py @@ -25,6 +25,13 @@ [ ("cffi-1.5.0-cp27-none-linux_x86_64.whl", {"libffi.so.5"}, frozenset()), ("cffi-1.5.0-cp27-none-linux_x86_64.whl", set(), frozenset(["libffi.so.5"])), + ( + "cffi-1.5.0-cp27-none-linux_x86_64.whl", + {"libffi.so.5"}, + frozenset(["libffi.so.noexist", "libnoexist.so.*"]), + ), + ("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(["*"])), ( "python_snappy-0.5.2-pp260-pypy_41-linux_x86_64.whl", {"libsnappy.so.1"}, From 67ef499e802e0cf31d842f212b02b366ae8ef502 Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Mon, 9 Dec 2024 07:44:05 -0500 Subject: [PATCH 2/2] Test sequences --- tests/integration/test_bundled_wheels.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/integration/test_bundled_wheels.py b/tests/integration/test_bundled_wheels.py index a650c093..a63305a3 100644 --- a/tests/integration/test_bundled_wheels.py +++ b/tests/integration/test_bundled_wheels.py @@ -30,6 +30,16 @@ {"libffi.so.5"}, frozenset(["libffi.so.noexist", "libnoexist.so.*"]), ), + ( + "cffi-1.5.0-cp27-none-linux_x86_64.whl", + set(), + frozenset(["libffi.so.[4,5]"]), + ), + ( + "cffi-1.5.0-cp27-none-linux_x86_64.whl", + {"libffi.so.5"}, + frozenset(["libffi.so.[6,7]"]), + ), ("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(["*"])), (