Skip to content

Commit 7d411b2

Browse files
Filter libpythonXY for greater than single digits (#424)
* Add initial tests for lddtree_external_references. * Fix libpython regex. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent d270db8 commit 7d411b2

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

src/auditwheel/policy/external_references.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from . import load_policies
99

1010
log = logging.getLogger(__name__)
11-
LIBPYTHON_RE = re.compile(r"^libpython\d\.\dm?.so(.\d)*$")
11+
LIBPYTHON_RE = re.compile(r"^libpython\d+\.\d+m?.so(.\d)*$")
1212

1313

1414
def lddtree_external_references(lddtree: dict, wheel_path: str) -> dict:

tests/unit/test_policy.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
get_policy_name,
1111
get_priority_by_name,
1212
get_replace_platforms,
13+
lddtree_external_references,
1314
)
1415

1516

@@ -202,3 +203,32 @@ def test_get_by_name_missing(self):
202203
def test_get_by_name_duplicate(self):
203204
with pytest.raises(RuntimeError):
204205
get_priority_by_name("duplicate")
206+
207+
208+
class TestLddTreeExternalReferences:
209+
"""Tests for lddtree_external_references."""
210+
211+
def test_filter_libs(self):
212+
"""Test the nested filter_libs function."""
213+
filtered_libs = [
214+
"ld-linux-x86_64.so.1",
215+
"ld64.so.1",
216+
"ld64.so.2",
217+
"libpython3.7m.so.1.0",
218+
"libpython3.9.so.1.0",
219+
"libpython3.10.so.1.0",
220+
"libpython999.999.so.1.0",
221+
]
222+
unfiltered_libs = ["libfoo.so.1.0", "libbar.so.999.999.999"]
223+
libs = filtered_libs + unfiltered_libs
224+
225+
lddtree = {
226+
"realpath": "/path/to/lib",
227+
"needed": libs,
228+
"libs": {lib: {"needed": [], "realpath": "/path/to/lib"} for lib in libs},
229+
}
230+
full_external_refs = lddtree_external_references(lddtree, "/path/to/wheel")
231+
232+
# Assert that each policy only has the unfiltered libs.
233+
for policy in full_external_refs:
234+
assert set(full_external_refs[policy]["libs"]) == set(unfiltered_libs)

0 commit comments

Comments
 (0)