From 20a249a428d0f980e2e9503daa8b46df97076824 Mon Sep 17 00:00:00 2001 From: Yichen Yan Date: Fri, 9 May 2025 17:18:11 +0800 Subject: [PATCH 01/24] determinestic is good --- src/auditwheel/lddtree.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/auditwheel/lddtree.py b/src/auditwheel/lddtree.py index 07326341..ba5f9c12 100644 --- a/src/auditwheel/lddtree.py +++ b/src/auditwheel/lddtree.py @@ -13,6 +13,7 @@ from __future__ import annotations +from collections import OrderedDict import errno import functools import glob @@ -441,7 +442,7 @@ def ldd( """ _first = _all_libs is None if _all_libs is None: - _all_libs = {} + _all_libs = OrderedDict() log.debug("ldd(%s)", path) @@ -554,7 +555,7 @@ def ldd( + ldpaths["interp"] ) _excluded_libs: set[str] = set() - for soname in needed: + for soname in sorted(needed): if soname in _all_libs: continue if soname in _excluded_libs: From 87148d310af9714939a9e09bb3371feca596e9af Mon Sep 17 00:00:00 2001 From: Yichen Yan Date: Fri, 9 May 2025 17:38:27 +0800 Subject: [PATCH 02/24] fix --- src/auditwheel/lddtree.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/auditwheel/lddtree.py b/src/auditwheel/lddtree.py index ba5f9c12..66aeb9fb 100644 --- a/src/auditwheel/lddtree.py +++ b/src/auditwheel/lddtree.py @@ -556,7 +556,7 @@ def ldd( ) _excluded_libs: set[str] = set() for soname in sorted(needed): - if soname in _all_libs: + if soname in _all_libs and _all_libs[soname].realpath is not None: continue if soname in _excluded_libs: continue @@ -565,13 +565,15 @@ def ldd( _excluded_libs.add(soname) continue realpath, fullpath = find_lib(platform, soname, all_ldpaths, root) + if realpath is None: + log.info("Could not locate %s, skipping.", soname) + continue if realpath is not None and any(fnmatch(str(realpath), e) for e in exclude): log.info("Excluding %s", realpath) _excluded_libs.add(soname) continue - _all_libs[soname] = DynamicLibrary(soname, fullpath, realpath) - if realpath is None or fullpath is None: - continue + if soname not in _all_libs: + _all_libs[soname] = DynamicLibrary(soname, fullpath, realpath) dependency = ldd(realpath, root, prefix, ldpaths, fullpath, exclude, _all_libs) _all_libs[soname] = DynamicLibrary( soname, From e9ade2be5f19cf09e18eb95bda60425b145b761c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 9 May 2025 09:40:03 +0000 Subject: [PATCH 03/24] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/auditwheel/lddtree.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/auditwheel/lddtree.py b/src/auditwheel/lddtree.py index 66aeb9fb..4664fd60 100644 --- a/src/auditwheel/lddtree.py +++ b/src/auditwheel/lddtree.py @@ -13,12 +13,12 @@ from __future__ import annotations -from collections import OrderedDict import errno import functools import glob import logging import os +from collections import OrderedDict from dataclasses import dataclass from fnmatch import fnmatch from pathlib import Path From ef347fcdf92ce39d0a51bc7112bee361ecf5e15c Mon Sep 17 00:00:00 2001 From: Yichen Yan Date: Fri, 9 May 2025 17:43:29 +0800 Subject: [PATCH 04/24] fmt --- src/auditwheel/lddtree.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/auditwheel/lddtree.py b/src/auditwheel/lddtree.py index 66aeb9fb..cc8b1049 100644 --- a/src/auditwheel/lddtree.py +++ b/src/auditwheel/lddtree.py @@ -13,12 +13,12 @@ from __future__ import annotations -from collections import OrderedDict import errno import functools import glob import logging import os +from collections import OrderedDict from dataclasses import dataclass from fnmatch import fnmatch from pathlib import Path @@ -568,7 +568,7 @@ def ldd( if realpath is None: log.info("Could not locate %s, skipping.", soname) continue - if realpath is not None and any(fnmatch(str(realpath), e) for e in exclude): + if any(fnmatch(str(realpath), e) for e in exclude): log.info("Excluding %s", realpath) _excluded_libs.add(soname) continue From 8b5df9525520403e780f16bdb3d72f77dc90deda Mon Sep 17 00:00:00 2001 From: Yichen Yan Date: Fri, 9 May 2025 18:46:58 +0800 Subject: [PATCH 05/24] Update lddtree.py --- src/auditwheel/lddtree.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/auditwheel/lddtree.py b/src/auditwheel/lddtree.py index cc8b1049..291905b3 100644 --- a/src/auditwheel/lddtree.py +++ b/src/auditwheel/lddtree.py @@ -565,6 +565,8 @@ def ldd( _excluded_libs.add(soname) continue realpath, fullpath = find_lib(platform, soname, all_ldpaths, root) + if soname not in _all_libs: + _all_libs[soname] = DynamicLibrary(soname, fullpath, realpath) if realpath is None: log.info("Could not locate %s, skipping.", soname) continue @@ -572,8 +574,6 @@ def ldd( log.info("Excluding %s", realpath) _excluded_libs.add(soname) continue - if soname not in _all_libs: - _all_libs[soname] = DynamicLibrary(soname, fullpath, realpath) dependency = ldd(realpath, root, prefix, ldpaths, fullpath, exclude, _all_libs) _all_libs[soname] = DynamicLibrary( soname, From cb6498a1d13af41b3b8a8c681ebe7dba9dce4dd5 Mon Sep 17 00:00:00 2001 From: Yichen Yan Date: Sat, 10 May 2025 07:27:13 +0800 Subject: [PATCH 06/24] update --- src/auditwheel/lddtree.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/auditwheel/lddtree.py b/src/auditwheel/lddtree.py index 291905b3..b9053a68 100644 --- a/src/auditwheel/lddtree.py +++ b/src/auditwheel/lddtree.py @@ -570,7 +570,7 @@ def ldd( if realpath is None: log.info("Could not locate %s, skipping.", soname) continue - if any(fnmatch(str(realpath), e) for e in exclude): + elif any(fnmatch(str(realpath), e) for e in exclude): log.info("Excluding %s", realpath) _excluded_libs.add(soname) continue From 78dcfe02975eb5cd4659c56e003befb8572f3d82 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 9 May 2025 23:27:27 +0000 Subject: [PATCH 07/24] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/auditwheel/lddtree.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/auditwheel/lddtree.py b/src/auditwheel/lddtree.py index b9053a68..291905b3 100644 --- a/src/auditwheel/lddtree.py +++ b/src/auditwheel/lddtree.py @@ -570,7 +570,7 @@ def ldd( if realpath is None: log.info("Could not locate %s, skipping.", soname) continue - elif any(fnmatch(str(realpath), e) for e in exclude): + if any(fnmatch(str(realpath), e) for e in exclude): log.info("Excluding %s", realpath) _excluded_libs.add(soname) continue From 70e94a1b710e9b104ba8af913c0d73b2f1ed3df8 Mon Sep 17 00:00:00 2001 From: Yichen Yan Date: Sat, 10 May 2025 20:38:13 +0800 Subject: [PATCH 08/24] Start test --- tests/integration/test_manylinux.py | 7 +++++++ tests/integration/testrpath/a/a.c | 4 ++-- tests/integration/testrpath/c/c.c | 3 +++ tests/integration/testrpath/c/c.h | 1 + tests/integration/testrpath/setup.py | 8 +++++--- 5 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 tests/integration/testrpath/c/c.c create mode 100644 tests/integration/testrpath/c/c.h diff --git a/tests/integration/test_manylinux.py b/tests/integration/test_manylinux.py index e3097db4..0ce64b16 100644 --- a/tests/integration/test_manylinux.py +++ b/tests/integration/test_manylinux.py @@ -636,6 +636,13 @@ def test_rpath( ] assert len(rpath_tags) == 1 assert rpath_tags[0].rpath == "$ORIGIN" + + def test_dependency_order(self, anylinux: AnyLinuxContainer, python: PythonContainer) -> None: + policy = anylinux.policy + + test_path = "/auditwheel_src/tests/integration/testrpath" + + pass def test_multiple_top_level( self, anylinux: AnyLinuxContainer, python: PythonContainer diff --git a/tests/integration/testrpath/a/a.c b/tests/integration/testrpath/a/a.c index 0a4ec831..0d0a0923 100644 --- a/tests/integration/testrpath/a/a.c +++ b/tests/integration/testrpath/a/a.c @@ -1,6 +1,6 @@ #include "b.h" - +#include "c.h" int fa(void) { - return 1 + fb(); + return 1 + fb() + fc(); } diff --git a/tests/integration/testrpath/c/c.c b/tests/integration/testrpath/c/c.c new file mode 100644 index 00000000..97968f2d --- /dev/null +++ b/tests/integration/testrpath/c/c.c @@ -0,0 +1,3 @@ +int fc(void) { + return 11; +} diff --git a/tests/integration/testrpath/c/c.h b/tests/integration/testrpath/c/c.h new file mode 100644 index 00000000..9593d7d5 --- /dev/null +++ b/tests/integration/testrpath/c/c.h @@ -0,0 +1 @@ +int fb(void); diff --git a/tests/integration/testrpath/setup.py b/tests/integration/testrpath/setup.py index 75b92674..ea32d218 100644 --- a/tests/integration/testrpath/setup.py +++ b/tests/integration/testrpath/setup.py @@ -9,12 +9,14 @@ class BuildExt(build_ext): def run(self) -> None: - cmd = "gcc -fPIC -shared -o b/libb.so b/b.c" + cmd = "gcc -fPIC -shared -o c/libc.so c/c.c" + subprocess.check_call(cmd.split()) + cmd = "gcc -fPIC -shared -o b/libb.so b/b.c -Wl,-rpath=$ORIGIN/../c -Ic -Lc -lc" subprocess.check_call(cmd.split()) cmd = ( - "gcc -fPIC -shared -o a/liba.so " + "gcc -fPIC -shared -o a/liba.so a/a.c " "-Wl,{dtags_flag} -Wl,-rpath=$ORIGIN/../b " - "-Ib a/a.c -Lb -lb" + "-Ib -Lb -lb -Ic -Lc -lc" ).format( dtags_flag=( "--enable-new-dtags" From 4272b5303f518b1c232a3fb25fcf328aeb0850fd Mon Sep 17 00:00:00 2001 From: Yichen Yan Date: Sat, 10 May 2025 20:40:27 +0800 Subject: [PATCH 09/24] fix --- tests/integration/test_manylinux.py | 8 ++++---- tests/integration/testrpath/c/c.h | 2 +- tests/integration/testrpath/setup.py | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/integration/test_manylinux.py b/tests/integration/test_manylinux.py index 0ce64b16..1ff09f54 100644 --- a/tests/integration/test_manylinux.py +++ b/tests/integration/test_manylinux.py @@ -636,14 +636,14 @@ def test_rpath( ] assert len(rpath_tags) == 1 assert rpath_tags[0].rpath == "$ORIGIN" - - def test_dependency_order(self, anylinux: AnyLinuxContainer, python: PythonContainer) -> None: + + def test_dependency_order( + self, anylinux: AnyLinuxContainer, python: PythonContainer + ) -> None: policy = anylinux.policy test_path = "/auditwheel_src/tests/integration/testrpath" - pass - def test_multiple_top_level( self, anylinux: AnyLinuxContainer, python: PythonContainer ) -> None: diff --git a/tests/integration/testrpath/c/c.h b/tests/integration/testrpath/c/c.h index 9593d7d5..018d9d29 100644 --- a/tests/integration/testrpath/c/c.h +++ b/tests/integration/testrpath/c/c.h @@ -1 +1 @@ -int fb(void); +int fc(void); diff --git a/tests/integration/testrpath/setup.py b/tests/integration/testrpath/setup.py index ea32d218..fd0aec05 100644 --- a/tests/integration/testrpath/setup.py +++ b/tests/integration/testrpath/setup.py @@ -11,11 +11,11 @@ class BuildExt(build_ext): def run(self) -> None: cmd = "gcc -fPIC -shared -o c/libc.so c/c.c" subprocess.check_call(cmd.split()) - cmd = "gcc -fPIC -shared -o b/libb.so b/b.c -Wl,-rpath=$ORIGIN/../c -Ic -Lc -lc" + cmd = "gcc -fPIC -shared -o b/libb.so b/b.c -Ic -Lc -lc" subprocess.check_call(cmd.split()) cmd = ( "gcc -fPIC -shared -o a/liba.so a/a.c " - "-Wl,{dtags_flag} -Wl,-rpath=$ORIGIN/../b " + "-Wl,{dtags_flag} -Wl,-rpath=$ORIGIN/../b -Wl,-rpath=$ORIGIN/../c " "-Ib -Lb -lb -Ic -Lc -lc" ).format( dtags_flag=( From 315f12a6f0128506e388e3fa87afd17309d23992 Mon Sep 17 00:00:00 2001 From: Yichen Yan Date: Sat, 10 May 2025 22:03:26 +0800 Subject: [PATCH 10/24] finish test --- src/auditwheel/lddtree.py | 2 +- tests/integration/test_manylinux.py | 10 +++++++++- tests/integration/testrpath/a/a.c | 4 ++-- tests/integration/testrpath/b/b.c | 4 +++- tests/integration/testrpath/c/c.h | 1 - tests/integration/testrpath/{c/c.c => d/d.c} | 2 +- tests/integration/testrpath/d/d.h | 1 + tests/integration/testrpath/setup.py | 10 ++++++---- 8 files changed, 23 insertions(+), 11 deletions(-) delete mode 100644 tests/integration/testrpath/c/c.h rename tests/integration/testrpath/{c/c.c => d/d.c} (53%) create mode 100644 tests/integration/testrpath/d/d.h diff --git a/src/auditwheel/lddtree.py b/src/auditwheel/lddtree.py index 291905b3..edf6e2e3 100644 --- a/src/auditwheel/lddtree.py +++ b/src/auditwheel/lddtree.py @@ -568,7 +568,7 @@ def ldd( if soname not in _all_libs: _all_libs[soname] = DynamicLibrary(soname, fullpath, realpath) if realpath is None: - log.info("Could not locate %s, skipping.", soname) + log.debug("Could not locate %s, skipping.", soname) continue if any(fnmatch(str(realpath), e) for e in exclude): log.info("Excluding %s", realpath) diff --git a/tests/integration/test_manylinux.py b/tests/integration/test_manylinux.py index 1ff09f54..500e5cfa 100644 --- a/tests/integration/test_manylinux.py +++ b/tests/integration/test_manylinux.py @@ -161,13 +161,17 @@ def repair( strip: bool = False, library_paths: list[str] | None = None, excludes: list[str] | None = None, + verbose: int = 0, ) -> str: plat = plat or self._policy args = [] if library_paths: ld_library_path = ":".join([*library_paths, "$LD_LIBRARY_PATH"]) args.append(f"LD_LIBRARY_PATH={ld_library_path}") - args.extend(["auditwheel", "repair", "-w", "/io", "--plat", plat]) + args.append("auditwheel") + if verbose: + args.append(f"-{'v' * verbose}") + args.extend(["repair", "-w", "/io", "--plat", plat]) if only_plat: args.append("--only-plat") if not isa_ext_check: @@ -643,6 +647,10 @@ def test_dependency_order( policy = anylinux.policy test_path = "/auditwheel_src/tests/integration/testrpath" + orig_wheel = anylinux.build_wheel(test_path) + + repair_output = anylinux.repair(orig_wheel, library_paths=[f"{test_path}/a"], verbose=3) + assert 'lddtree:Could not locate libd.so, skipping' in repair_output def test_multiple_top_level( self, anylinux: AnyLinuxContainer, python: PythonContainer diff --git a/tests/integration/testrpath/a/a.c b/tests/integration/testrpath/a/a.c index 0d0a0923..2dd8e414 100644 --- a/tests/integration/testrpath/a/a.c +++ b/tests/integration/testrpath/a/a.c @@ -1,6 +1,6 @@ #include "b.h" -#include "c.h" +#include "d.h" int fa(void) { - return 1 + fb() + fc(); + return 1 + fb() + fd(); } diff --git a/tests/integration/testrpath/b/b.c b/tests/integration/testrpath/b/b.c index d1b58fac..15202ee3 100644 --- a/tests/integration/testrpath/b/b.c +++ b/tests/integration/testrpath/b/b.c @@ -1,3 +1,5 @@ +#include "d.h" + int fb(void) { - return 10; + return 10 + fd(); } diff --git a/tests/integration/testrpath/c/c.h b/tests/integration/testrpath/c/c.h deleted file mode 100644 index 018d9d29..00000000 --- a/tests/integration/testrpath/c/c.h +++ /dev/null @@ -1 +0,0 @@ -int fc(void); diff --git a/tests/integration/testrpath/c/c.c b/tests/integration/testrpath/d/d.c similarity index 53% rename from tests/integration/testrpath/c/c.c rename to tests/integration/testrpath/d/d.c index 97968f2d..2647917e 100644 --- a/tests/integration/testrpath/c/c.c +++ b/tests/integration/testrpath/d/d.c @@ -1,3 +1,3 @@ -int fc(void) { +int fd(void) { return 11; } diff --git a/tests/integration/testrpath/d/d.h b/tests/integration/testrpath/d/d.h new file mode 100644 index 00000000..15aace72 --- /dev/null +++ b/tests/integration/testrpath/d/d.h @@ -0,0 +1 @@ +int fd(void); diff --git a/tests/integration/testrpath/setup.py b/tests/integration/testrpath/setup.py index fd0aec05..9ebe7ec9 100644 --- a/tests/integration/testrpath/setup.py +++ b/tests/integration/testrpath/setup.py @@ -9,14 +9,16 @@ class BuildExt(build_ext): def run(self) -> None: - cmd = "gcc -fPIC -shared -o c/libc.so c/c.c" + cmd = "gcc -fPIC -shared -o d/libd.so d/d.c" subprocess.check_call(cmd.split()) - cmd = "gcc -fPIC -shared -o b/libb.so b/b.c -Ic -Lc -lc" + cmd = "gcc -fPIC -shared -o b/libb.so b/b.c -Id" + subprocess.check_call(cmd.split()) + cmd = "patchelf --add-needed libd.so b/libb.so" subprocess.check_call(cmd.split()) cmd = ( "gcc -fPIC -shared -o a/liba.so a/a.c " - "-Wl,{dtags_flag} -Wl,-rpath=$ORIGIN/../b -Wl,-rpath=$ORIGIN/../c " - "-Ib -Lb -lb -Ic -Lc -lc" + "-Wl,{dtags_flag} -Wl,-rpath=$ORIGIN/../b -Wl,-rpath=$ORIGIN/../d " + "-Ib -Lb -lb -Id -Ld -ld" ).format( dtags_flag=( "--enable-new-dtags" From a7560b383045ae1c184c78fb78804a2ce076d392 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 10 May 2025 14:03:46 +0000 Subject: [PATCH 11/24] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/integration/test_manylinux.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/integration/test_manylinux.py b/tests/integration/test_manylinux.py index 500e5cfa..23dd6a8c 100644 --- a/tests/integration/test_manylinux.py +++ b/tests/integration/test_manylinux.py @@ -649,8 +649,10 @@ def test_dependency_order( test_path = "/auditwheel_src/tests/integration/testrpath" orig_wheel = anylinux.build_wheel(test_path) - repair_output = anylinux.repair(orig_wheel, library_paths=[f"{test_path}/a"], verbose=3) - assert 'lddtree:Could not locate libd.so, skipping' in repair_output + repair_output = anylinux.repair( + orig_wheel, library_paths=[f"{test_path}/a"], verbose=3 + ) + assert "lddtree:Could not locate libd.so, skipping" in repair_output def test_multiple_top_level( self, anylinux: AnyLinuxContainer, python: PythonContainer From 51e3c2e30e8de0039b01e1f50966d77ab533b424 Mon Sep 17 00:00:00 2001 From: Yichen Yan Date: Sat, 10 May 2025 22:08:51 +0800 Subject: [PATCH 12/24] merge tests and fmt --- tests/integration/test_manylinux.py | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/tests/integration/test_manylinux.py b/tests/integration/test_manylinux.py index 23dd6a8c..7e7b5135 100644 --- a/tests/integration/test_manylinux.py +++ b/tests/integration/test_manylinux.py @@ -592,6 +592,7 @@ def test_rpath( # - check if RUNPATH is replaced by RPATH # - check if RPATH location is correct, i.e. it is inside .libs directory # where all gathered libraries are put + # - check if the order of dependencies affects if library is found policy = anylinux.policy @@ -605,7 +606,12 @@ def test_rpath( assert f"DT_{dtag.upper()}" in tags # Repair the wheel using the appropriate manylinux container - anylinux.repair(orig_wheel, library_paths=[f"{test_path}/a"]) + repair_output = anylinux.repair( + orig_wheel, library_paths=[f"{test_path}/a"], verbose=3 + ) + assert "lddtree:Could not locate libd.so, skipping" in repair_output, ( + repair_output + ) repaired_wheel = anylinux.check_wheel("testrpath") assert_show_output(anylinux, repaired_wheel, policy, False) @@ -641,19 +647,6 @@ def test_rpath( assert len(rpath_tags) == 1 assert rpath_tags[0].rpath == "$ORIGIN" - def test_dependency_order( - self, anylinux: AnyLinuxContainer, python: PythonContainer - ) -> None: - policy = anylinux.policy - - test_path = "/auditwheel_src/tests/integration/testrpath" - orig_wheel = anylinux.build_wheel(test_path) - - repair_output = anylinux.repair( - orig_wheel, library_paths=[f"{test_path}/a"], verbose=3 - ) - assert "lddtree:Could not locate libd.so, skipping" in repair_output - def test_multiple_top_level( self, anylinux: AnyLinuxContainer, python: PythonContainer ) -> None: From c8cdf8f1d37bc541d3974617d6f3700f7b77a512 Mon Sep 17 00:00:00 2001 From: Yichen Yan Date: Sat, 10 May 2025 22:21:36 +0800 Subject: [PATCH 13/24] fix result --- tests/integration/test_manylinux.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/test_manylinux.py b/tests/integration/test_manylinux.py index 7e7b5135..affe1c4a 100644 --- a/tests/integration/test_manylinux.py +++ b/tests/integration/test_manylinux.py @@ -617,7 +617,7 @@ def test_rpath( python.install_wheel(repaired_wheel) output = python.run("from testrpath import testrpath; print(testrpath.func())") - assert output.strip() == "11" + assert output.strip() == "33" with zipfile.ZipFile(anylinux.io_folder / repaired_wheel) as w: libraries = tuple( name for name in w.namelist() if "testrpath.libs/lib" in name From 40c9b98eda6a7e38c4ebc3230628e67c986a1396 Mon Sep 17 00:00:00 2001 From: Yichen Yan Date: Sat, 10 May 2025 22:49:56 +0800 Subject: [PATCH 14/24] fix result --- tests/integration/test_manylinux.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/integration/test_manylinux.py b/tests/integration/test_manylinux.py index affe1c4a..0b3f5f22 100644 --- a/tests/integration/test_manylinux.py +++ b/tests/integration/test_manylinux.py @@ -622,8 +622,11 @@ def test_rpath( libraries = tuple( name for name in w.namelist() if "testrpath.libs/lib" in name ) - assert len(libraries) == 2 - assert any(".libs/liba" in name for name in libraries) + assert len(libraries) == 3 + assert all( + (any(f".libs/lib{lib}" in name for name in libraries)) + for lib in ["a", "b", "d"] + ) for name in libraries: with w.open(name) as f: elf = ELFFile(io.BytesIO(f.read())) From 806646dcdf80394c5efa5dbd79fcea702ab75056 Mon Sep 17 00:00:00 2001 From: Yichen Yan Date: Sat, 10 May 2025 23:32:01 +0800 Subject: [PATCH 15/24] workaround 3.9 failure --- tests/integration/sample_extension/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/sample_extension/pyproject.toml b/tests/integration/sample_extension/pyproject.toml index 9307927e..5cc7636a 100644 --- a/tests/integration/sample_extension/pyproject.toml +++ b/tests/integration/sample_extension/pyproject.toml @@ -1,3 +1,3 @@ [build-system] -requires = ["setuptools >= 45.0.0", "cython"] +requires = ["setuptools >= 45.0.0", "cython < 3.1.0"] build-backend = "setuptools.build_meta" From 3296f332883743aff55ec020add103f9b8223808 Mon Sep 17 00:00:00 2001 From: Yichen Yan Date: Sun, 11 May 2025 00:04:12 +0800 Subject: [PATCH 16/24] more cython workaround --- tests/integration/internal_rpath/pyproject.toml | 2 +- tests/integration/multiple_top_level/pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration/internal_rpath/pyproject.toml b/tests/integration/internal_rpath/pyproject.toml index 745445f4..6b494fb1 100644 --- a/tests/integration/internal_rpath/pyproject.toml +++ b/tests/integration/internal_rpath/pyproject.toml @@ -1,3 +1,3 @@ [build-system] -requires = ["cython", "setuptools"] +requires = ["cython < 3.1.0", "setuptools"] build-backend = "setuptools.build_meta" diff --git a/tests/integration/multiple_top_level/pyproject.toml b/tests/integration/multiple_top_level/pyproject.toml index 745445f4..6b494fb1 100644 --- a/tests/integration/multiple_top_level/pyproject.toml +++ b/tests/integration/multiple_top_level/pyproject.toml @@ -1,3 +1,3 @@ [build-system] -requires = ["cython", "setuptools"] +requires = ["cython < 3.1.0", "setuptools"] build-backend = "setuptools.build_meta" From 7993e1d950b403c3b680879e0a0a79f94b5f393d Mon Sep 17 00:00:00 2001 From: Yichen Yan Date: Sun, 11 May 2025 09:29:07 +0800 Subject: [PATCH 17/24] revert hard-code cython version and use env as workaround --- tests/integration/internal_rpath/pyproject.toml | 2 +- tests/integration/multiple_top_level/pyproject.toml | 2 +- tests/integration/sample_extension/pyproject.toml | 2 +- tests/integration/test_manylinux.py | 4 ++++ 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/integration/internal_rpath/pyproject.toml b/tests/integration/internal_rpath/pyproject.toml index 6b494fb1..745445f4 100644 --- a/tests/integration/internal_rpath/pyproject.toml +++ b/tests/integration/internal_rpath/pyproject.toml @@ -1,3 +1,3 @@ [build-system] -requires = ["cython < 3.1.0", "setuptools"] +requires = ["cython", "setuptools"] build-backend = "setuptools.build_meta" diff --git a/tests/integration/multiple_top_level/pyproject.toml b/tests/integration/multiple_top_level/pyproject.toml index 6b494fb1..745445f4 100644 --- a/tests/integration/multiple_top_level/pyproject.toml +++ b/tests/integration/multiple_top_level/pyproject.toml @@ -1,3 +1,3 @@ [build-system] -requires = ["cython < 3.1.0", "setuptools"] +requires = ["cython", "setuptools"] build-backend = "setuptools.build_meta" diff --git a/tests/integration/sample_extension/pyproject.toml b/tests/integration/sample_extension/pyproject.toml index 5cc7636a..9307927e 100644 --- a/tests/integration/sample_extension/pyproject.toml +++ b/tests/integration/sample_extension/pyproject.toml @@ -1,3 +1,3 @@ [build-system] -requires = ["setuptools >= 45.0.0", "cython < 3.1.0"] +requires = ["setuptools >= 45.0.0", "cython"] build-backend = "setuptools.build_meta" diff --git a/tests/integration/test_manylinux.py b/tests/integration/test_manylinux.py index 0b3f5f22..c6321079 100644 --- a/tests/integration/test_manylinux.py +++ b/tests/integration/test_manylinux.py @@ -458,6 +458,10 @@ def anylinux( for key in os.environ: if key.startswith("COV_CORE_"): env[key] = os.environ[key] + # cython 3.1.0+ requires a C99 compiler, + # where manylinux_2_5 uses gcc 4.8 which is not C99 compliant by default. + if policy == "manylinux_2_5": + env["CFLAGS"] = "-std=c99" with docker_container_ctx(manylinux_img, io_folder, env) as container: platform_tag = ".".join( From eb8773aa97ba5fa676390502c7b8c128ae2e7273 Mon Sep 17 00:00:00 2001 From: Yichen Yan Date: Wed, 14 May 2025 11:07:14 +0800 Subject: [PATCH 18/24] Also remove excluded libs from `DynamicExecutable.libraries` when exclude based on path --- src/auditwheel/lddtree.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/auditwheel/lddtree.py b/src/auditwheel/lddtree.py index edf6e2e3..c6ba704d 100644 --- a/src/auditwheel/lddtree.py +++ b/src/auditwheel/lddtree.py @@ -592,5 +592,5 @@ def ldd( frozenset(needed - _excluded_libs), tuple(rpaths), tuple(runpaths), - _all_libs, + {k: v for k, v in _all_libs.items() if k not in _excluded_libs}, ) From 76b78ac041dbfeb9293a3a27a99fc5497d26319e Mon Sep 17 00:00:00 2001 From: Yichen Yan Date: Wed, 14 May 2025 15:38:46 +0800 Subject: [PATCH 19/24] Keep order for libraries --- src/auditwheel/lddtree.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/auditwheel/lddtree.py b/src/auditwheel/lddtree.py index c6ba704d..c934943b 100644 --- a/src/auditwheel/lddtree.py +++ b/src/auditwheel/lddtree.py @@ -573,6 +573,7 @@ def ldd( if any(fnmatch(str(realpath), e) for e in exclude): log.info("Excluding %s", realpath) _excluded_libs.add(soname) + _all_libs.pop(soname) continue dependency = ldd(realpath, root, prefix, ldpaths, fullpath, exclude, _all_libs) _all_libs[soname] = DynamicLibrary( @@ -592,5 +593,5 @@ def ldd( frozenset(needed - _excluded_libs), tuple(rpaths), tuple(runpaths), - {k: v for k, v in _all_libs.items() if k not in _excluded_libs}, + _all_libs, ) From 0732b99fe2615f200fe71e30717972f1b7ad8699 Mon Sep 17 00:00:00 2001 From: Yichen Yan Date: Sat, 24 May 2025 08:49:07 +0800 Subject: [PATCH 20/24] same order with main --- src/auditwheel/lddtree.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/auditwheel/lddtree.py b/src/auditwheel/lddtree.py index 930f8129..f9439aaa 100644 --- a/src/auditwheel/lddtree.py +++ b/src/auditwheel/lddtree.py @@ -18,7 +18,6 @@ import glob import logging import os -from collections import OrderedDict from dataclasses import dataclass from fnmatch import fnmatch from pathlib import Path @@ -442,7 +441,7 @@ def ldd( """ _first = _all_libs is None if _all_libs is None: - _all_libs = OrderedDict() + _all_libs = {} log.debug("ldd(%s)", path) @@ -555,7 +554,7 @@ def ldd( + ldpaths["interp"] ) _excluded_libs: set[str] = set() - for soname in sorted(needed): + for soname in needed: if soname in _all_libs and _all_libs[soname].realpath is not None: continue if soname in _excluded_libs: From 0deaf39687e2cc839f73e30cb4386da77ff00d25 Mon Sep 17 00:00:00 2001 From: Yichen Yan Date: Sun, 25 May 2025 13:04:48 +0800 Subject: [PATCH 21/24] update --- src/auditwheel/lddtree.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/auditwheel/lddtree.py b/src/auditwheel/lddtree.py index f9439aaa..0a7679e1 100644 --- a/src/auditwheel/lddtree.py +++ b/src/auditwheel/lddtree.py @@ -572,7 +572,6 @@ def ldd( if any(fnmatch(str(realpath), e) for e in exclude): log.info("Excluding %s", realpath) _excluded_libs.add(soname) - _all_libs.pop(soname) continue dependency = ldd(realpath, root, prefix, ldpaths, fullpath, exclude, _all_libs) _all_libs[soname] = DynamicLibrary( @@ -592,5 +591,9 @@ def ldd( tuple(soname for soname in needed if soname not in _excluded_libs), tuple(rpaths), tuple(runpaths), - _all_libs, + { + soname: lib + for soname, lib in _all_libs.items() + if soname not in _excluded_libs + }, ) From 719797a4e3a56539e2d8091b86b09f4a6f6e828a Mon Sep 17 00:00:00 2001 From: Yichen Yan Date: Sun, 25 May 2025 14:09:31 +0800 Subject: [PATCH 22/24] Revert "update" This reverts commit 0deaf39687e2cc839f73e30cb4386da77ff00d25. --- src/auditwheel/lddtree.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/auditwheel/lddtree.py b/src/auditwheel/lddtree.py index 0a7679e1..f9439aaa 100644 --- a/src/auditwheel/lddtree.py +++ b/src/auditwheel/lddtree.py @@ -572,6 +572,7 @@ def ldd( if any(fnmatch(str(realpath), e) for e in exclude): log.info("Excluding %s", realpath) _excluded_libs.add(soname) + _all_libs.pop(soname) continue dependency = ldd(realpath, root, prefix, ldpaths, fullpath, exclude, _all_libs) _all_libs[soname] = DynamicLibrary( @@ -591,9 +592,5 @@ def ldd( tuple(soname for soname in needed if soname not in _excluded_libs), tuple(rpaths), tuple(runpaths), - { - soname: lib - for soname, lib in _all_libs.items() - if soname not in _excluded_libs - }, + _all_libs, ) From fd10d3721af22a4bec3cd23f53037a4d1781feb1 Mon Sep 17 00:00:00 2001 From: Yichen Yan Date: Tue, 27 May 2025 06:58:31 +0800 Subject: [PATCH 23/24] test: revert changed logic --- src/auditwheel/lddtree.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/auditwheel/lddtree.py b/src/auditwheel/lddtree.py index 87a97148..44785791 100644 --- a/src/auditwheel/lddtree.py +++ b/src/auditwheel/lddtree.py @@ -559,7 +559,7 @@ def ldd( ) _excluded_libs: set[str] = set() for soname in needed: - if soname in _all_libs and _all_libs[soname].realpath is not None: + if soname in _all_libs: continue if soname in _excluded_libs: continue @@ -578,15 +578,12 @@ def ldd( continue realpath, fullpath = find_lib(platform, soname, all_ldpaths, root) - if soname not in _all_libs: - _all_libs[soname] = DynamicLibrary(soname, fullpath, realpath) - if realpath is None: - log.debug("Could not locate %s, skipping.", soname) - continue - if any(fnmatch(str(realpath), e) for e in exclude): + if realpath is not None and any(fnmatch(str(realpath), e) for e in exclude): log.info("Excluding %s", realpath) _excluded_libs.add(soname) - _all_libs.pop(soname) + continue + _all_libs[soname] = DynamicLibrary(soname, fullpath, realpath) + if realpath is None or fullpath is None: continue dependency = ldd(realpath, root, prefix, ldpaths, fullpath, exclude, _all_libs) _all_libs[soname] = DynamicLibrary( From ef63c60af5ea7e4f50564669de596128717aea70 Mon Sep 17 00:00:00 2001 From: Yichen Yan Date: Tue, 27 May 2025 07:46:36 +0800 Subject: [PATCH 24/24] Revert "test: revert changed logic" This reverts commit fd10d3721af22a4bec3cd23f53037a4d1781feb1. --- src/auditwheel/lddtree.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/auditwheel/lddtree.py b/src/auditwheel/lddtree.py index 44785791..87a97148 100644 --- a/src/auditwheel/lddtree.py +++ b/src/auditwheel/lddtree.py @@ -559,7 +559,7 @@ def ldd( ) _excluded_libs: set[str] = set() for soname in needed: - if soname in _all_libs: + if soname in _all_libs and _all_libs[soname].realpath is not None: continue if soname in _excluded_libs: continue @@ -578,12 +578,15 @@ def ldd( continue realpath, fullpath = find_lib(platform, soname, all_ldpaths, root) - if realpath is not None and any(fnmatch(str(realpath), e) for e in exclude): + if soname not in _all_libs: + _all_libs[soname] = DynamicLibrary(soname, fullpath, realpath) + if realpath is None: + log.debug("Could not locate %s, skipping.", soname) + continue + if any(fnmatch(str(realpath), e) for e in exclude): log.info("Excluding %s", realpath) _excluded_libs.add(soname) - continue - _all_libs[soname] = DynamicLibrary(soname, fullpath, realpath) - if realpath is None or fullpath is None: + _all_libs.pop(soname) continue dependency = ldd(realpath, root, prefix, ldpaths, fullpath, exclude, _all_libs) _all_libs[soname] = DynamicLibrary(