Skip to content

Update libraries later if possible #582

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 28 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
20a249a
determinestic is good
oraluben May 9, 2025
87148d3
fix
oraluben May 9, 2025
e9ade2b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 9, 2025
ef347fc
fmt
oraluben May 9, 2025
40f910f
Merge branch 'update-found-libs' of github.com:oraluben/auditwheel in…
oraluben May 9, 2025
8b5df95
Update lddtree.py
oraluben May 9, 2025
cb6498a
update
oraluben May 9, 2025
78dcfe0
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 9, 2025
70e94a1
Start test
oraluben May 10, 2025
4272b53
fix
oraluben May 10, 2025
315f12a
finish test
oraluben May 10, 2025
a7560b3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 10, 2025
51e3c2e
merge tests and fmt
oraluben May 10, 2025
c8cdf8f
fix result
oraluben May 10, 2025
40c9b98
fix result
oraluben May 10, 2025
806646d
workaround 3.9 failure
oraluben May 10, 2025
3296f33
more cython workaround
oraluben May 10, 2025
7993e1d
revert hard-code cython version and use env as workaround
oraluben May 11, 2025
eb8773a
Also remove excluded libs from `DynamicExecutable.libraries` when exc…
oraluben May 14, 2025
76b78ac
Keep order for libraries
oraluben May 14, 2025
323f9f5
Merge branch 'main' into update-found-libs
auvipy May 18, 2025
0732b99
same order with main
oraluben May 24, 2025
280380d
Merge branch 'main' into update-found-libs
oraluben May 24, 2025
0deaf39
update
oraluben May 25, 2025
719797a
Revert "update"
oraluben May 25, 2025
368b3a1
Merge branch 'main' into update-found-libs
oraluben May 26, 2025
fd10d37
test: revert changed logic
oraluben May 26, 2025
ef63c60
Revert "test: revert changed logic"
oraluben May 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/auditwheel/lddtree.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand Down
23 changes: 18 additions & 5 deletions tests/integration/test_manylinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -597,6 +601,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

Expand All @@ -610,19 +615,27 @@ 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)

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
)
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()))
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/testrpath/a/a.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "b.h"

#include "d.h"

int fa(void) {
return 1 + fb();
return 1 + fb() + fd();
}
4 changes: 3 additions & 1 deletion tests/integration/testrpath/b/b.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "d.h"

int fb(void) {
return 10;
return 10 + fd();
}
3 changes: 3 additions & 0 deletions tests/integration/testrpath/d/d.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
int fd(void) {
return 11;
}
1 change: 1 addition & 0 deletions tests/integration/testrpath/d/d.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
int fd(void);
12 changes: 8 additions & 4 deletions tests/integration/testrpath/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@

class BuildExt(build_ext):
def run(self) -> None:
cmd = "gcc -fPIC -shared -o b/libb.so b/b.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 -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 "
"-Wl,{dtags_flag} -Wl,-rpath=$ORIGIN/../b "
"-Ib a/a.c -Lb -lb"
"gcc -fPIC -shared -o a/liba.so a/a.c "
"-Wl,{dtags_flag} -Wl,-rpath=$ORIGIN/../b -Wl,-rpath=$ORIGIN/../d "
"-Ib -Lb -lb -Id -Ld -ld"
).format(
dtags_flag=(
"--enable-new-dtags"
Expand Down