Skip to content

Commit

Permalink
fix: replace RPATH on copied libs to the folder where they're copied …
Browse files Browse the repository at this point in the history
…($ORIGIN) (#478)

* Set RPATH on copied libs to the folder where they're copied ($ORIGIN)

* fix RPATH test on external libraries

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: Alex Lopez <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Feb 3, 2024
1 parent ef36a56 commit 5de39f7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/auditwheel/repair.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def copylib(src_path: str, dest_dir: str, patcher: ElfPatcher) -> tuple[str, str
patcher.set_soname(dest_path, new_soname)

if any(itertools.chain(rpaths["rpaths"], rpaths["runpaths"])):
patcher.set_rpath(dest_path, dest_dir)
patcher.set_rpath(dest_path, "$ORIGIN")

return new_soname, dest_path

Expand Down
44 changes: 24 additions & 20 deletions tests/integration/test_manylinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,29 +498,33 @@ def test_build_wheel_depending_on_library_with_rpath(
)
assert output.strip() == "11"
with zipfile.ZipFile(os.path.join(io_folder, repaired_wheel)) as w:
for name in w.namelist():
if "testrpath/.libs/lib" in name:
with w.open(name) as f:
elf = ELFFile(io.BytesIO(f.read()))
dynamic = elf.get_section_by_name(".dynamic")
assert (
len(
[
t
for t in dynamic.iter_tags()
if t.entry.d_tag == "DT_RUNPATH"
]
)
== 0
)
if ".libs/liba" in name:
rpath_tags = [
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)
for name in libraries:
with w.open(name) as f:
elf = ELFFile(io.BytesIO(f.read()))
dynamic = elf.get_section_by_name(".dynamic")
assert (
len(
[
t
for t in dynamic.iter_tags()
if t.entry.d_tag == "DT_RPATH"
if t.entry.d_tag == "DT_RUNPATH"
]
assert len(rpath_tags) == 1
assert rpath_tags[0].rpath == "$ORIGIN/."
)
== 0
)
if ".libs/liba" in name:
rpath_tags = [
t
for t in dynamic.iter_tags()
if t.entry.d_tag == "DT_RPATH"
]
assert len(rpath_tags) == 1
assert rpath_tags[0].rpath == "$ORIGIN"

def test_build_repair_multiple_top_level_modules_wheel(
self, any_manylinux_container, docker_python, io_folder
Expand Down

0 comments on commit 5de39f7

Please sign in to comment.