Skip to content
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

feat:add --no-update-soname flag #473

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
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 @@
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 @@
% 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 @@
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 @@
# 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