Skip to content

Commit

Permalink
feat:add --no-update-soname flag
Browse files Browse the repository at this point in the history
  • Loading branch information
vimiix committed Jan 5, 2024
1 parent 45a8c00 commit ad64c3d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
8 changes: 8 additions & 0 deletions src/auditwheel/main_repair.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@ def configure_parser(sub_parsers):
help="Do not check for higher policy compatibility",
default=False,
)
p.add_argument(
"--no-update-soname",
dest="UPDATE_SONAME",
action="store_false",
help="Do not update SONAME with content-hash",
default=True,
)
p.set_defaults(func=execute)


Expand Down Expand Up @@ -179,6 +186,7 @@ def execute(args, p):
patcher=patcher,
exclude=args.EXCLUDE,
strip=args.STRIP,
update_soname=args.UPDATE_SONAME,
)

if out_wheel is not None:
Expand Down
23 changes: 15 additions & 8 deletions src/auditwheel/repair.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def repair_wheel(
patcher: ElfPatcher,
exclude: list[str],
strip: bool = False,
update_soname: bool = True,
) -> str | None:
external_refs_by_fn = get_wheel_elfdata(wheel_policy, wheel_path)[1]

Expand Down Expand Up @@ -85,7 +86,9 @@ def repair_wheel(
% soname
)

new_soname, new_path = copylib(src_path, dest_dir, patcher)
new_soname, new_path = copylib(
src_path, dest_dir, patcher, update_soname
)
soname_map[soname] = (new_soname, new_path)
replacements.append((soname, new_soname))
if replacements:
Expand Down Expand Up @@ -126,7 +129,9 @@ def strip_symbols(libraries: Iterable[str]) -> None:
check_call(["strip", "-s", lib])


def copylib(src_path: str, dest_dir: str, patcher: ElfPatcher) -> tuple[str, str]:
def copylib(
src_path: str, dest_dir: str, patcher: ElfPatcher, update_soname: bool = True
) -> tuple[str, str]:
"""Graft a shared library from the system into the wheel and update the
relevant links.
Expand All @@ -139,13 +144,15 @@ def copylib(src_path: str, dest_dir: str, patcher: ElfPatcher) -> tuple[str, str
# if the library has a RUNPATH/RPATH we clear it and set RPATH to point to
# its new location.

with open(src_path, "rb") as f:
shorthash = hashfile(f)[:8]

src_name = os.path.basename(src_path)
base, ext = src_name.split(".", 1)
if not base.endswith("-%s" % shorthash):
new_soname = f"{base}-{shorthash}.{ext}"
if update_soname:
with open(src_path, "rb") as f:
shorthash = hashfile(f)[:8]
base, ext = src_name.split(".", 1)
if not base.endswith("-%s" % shorthash):
new_soname = f"{base}-{shorthash}.{ext}"
else:
new_soname = src_name

Check warning on line 155 in src/auditwheel/repair.py

View check run for this annotation

Codecov / codecov/patch

src/auditwheel/repair.py#L155

Added line #L155 was not covered by tests
else:
new_soname = src_name

Expand Down
1 change: 1 addition & 0 deletions tests/integration/test_bundled_wheels.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def test_wheel_source_date_epoch(tmp_path, monkeypatch):
UPDATE_TAGS=True,
WHEEL_DIR=str(wheel_output_path),
WHEEL_FILE=[str(wheel_path)],
UPDATE_SONAME=True,
EXCLUDE=[],
cmd="repair",
func=Mock(),
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_repair.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from unittest.mock import call, patch

from auditwheel.patcher import Patchelf
from auditwheel.repair import append_rpath_within_wheel
from auditwheel.repair import append_rpath_within_wheel, copylib


@patch("auditwheel.patcher._verify_patchelf")
Expand Down

0 comments on commit ad64c3d

Please sign in to comment.