Skip to content

Commit 37bae34

Browse files
authored
Merge branch 'main' into sboms
2 parents e2660bc + 112180f commit 37bae34

16 files changed

+210
-32
lines changed

.pre-commit-config.yaml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# See https://pre-commit.com for more information
22
# See https://pre-commit.com/hooks.html for more hooks
33

4-
default_language_version:
5-
python: python3.9
6-
74
exclude: ^src/auditwheel/_vendor/
85

96
repos:
@@ -24,16 +21,22 @@ repos:
2421
- id: trailing-whitespace
2522

2623
- repo: https://github.com/astral-sh/ruff-pre-commit
27-
rev: v0.11.9
24+
rev: v0.11.13
2825
hooks:
2926
- id: ruff
3027
args: ["--fix", "--show-fixes"]
3128
- id: ruff-format
3229

3330
- repo: https://github.com/pre-commit/mirrors-mypy
34-
rev: v1.15.0
31+
rev: v1.16.0
3532
hooks:
3633
- id: mypy
37-
exclude: ^tests/integration/.*/.*$|^scripts/calculate_symbol_versions.py$
34+
exclude: tests/integration/.*/.*|tests/integration/quick_check_numpy.py|tests/unit/test_wheel_abi.py|scripts/calculate_symbol_versions.py
35+
args: ["--python-version=3.9"]
3836
additional_dependencies:
37+
- nox
38+
- packaging
39+
- pyelftools
40+
- pytest
41+
- types-docker
3942
- types-requests

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
22

33
## HEAD
44

5+
## 6.4.0
6+
7+
Released May 25, 2025
8+
9+
### User-facing changes
10+
- [FEATURE] detect architecture/libc from wheel ([#548](https://github.com/pypa/auditwheel/pull/548))
11+
- [FEATURE] Add libatomic.so.1 to lib_whitelist ([#572](https://github.com/pypa/auditwheel/pull/572))
12+
- [BUGFIX] Respect `DT_NEEDED` entries order in `lddtree` ([#561](https://github.com/pypa/auditwheel/issues/561), [#586](https://github.com/pypa/auditwheel/pull/586))
13+
- [BUGFIX] Resolve path of InTemporaryDirectory name ([#565](https://github.com/pypa/auditwheel/issues/565))
14+
- [BUGFIX] Clip zip timestamp to 1980-01-01 ([#566](https://github.com/pypa/auditwheel/issues/566))
15+
- [BUGFIX] Compressed tag sets are not sorted when rewriting wheel filename ([#583](https://github.com/pypa/auditwheel/issues/583))
16+
- [BUGFIX] Remove libpython linkage instead of ignoring it ([#589](https://github.com/pypa/auditwheel/issues/589))
17+
518
## 6.3.0
619

720
Released March 16, 2025

conftest.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import os
2+
3+
import pytest
4+
5+
6+
@pytest.fixture(autouse=True, scope="session")
7+
def clean_env():
8+
variables = ("AUDITWHEEL_PLAT", "AUDITWHEEL_ZIP_COMPRESSION_LEVEL")
9+
for var in variables:
10+
os.environ.pop(var, None)

noxfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
sdist = ""
2020

2121

22-
@nox.session(python=["3.9"], reuse_venv=True)
22+
@nox.session(reuse_venv=True)
2323
def lint(session: nox.Session) -> None:
2424
"""
2525
Run linters on the codebase.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ warn_redundant_casts = true
7373
warn_unreachable = false
7474
warn_unused_configs = true
7575
warn_unused_ignores = true
76+
untyped_calls_exclude = ["elftools.elf.elffile.ELFFile", "elftools.elf.sections.NoteSection"]
7677

7778
[[tool.mypy.overrides]]
7879
module = "auditwheel.*"

src/auditwheel/lddtree.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import glob
1919
import logging
2020
import os
21+
import re
2122
from dataclasses import dataclass
2223
from fnmatch import fnmatch
2324
from pathlib import Path
@@ -31,7 +32,10 @@
3132
from .libc import Libc
3233

3334
log = logging.getLogger(__name__)
34-
__all__ = ["DynamicExecutable", "DynamicLibrary", "ldd"]
35+
__all__ = ["LIBPYTHON_RE", "DynamicExecutable", "DynamicLibrary", "ldd"]
36+
37+
# Regex to match libpython shared library names
38+
LIBPYTHON_RE = re.compile(r"^libpython\d+\.\d+m?.so(\.\d)*$")
3539

3640

3741
@dataclass(frozen=True)
@@ -563,6 +567,16 @@ def ldd(
563567
log.info("Excluding %s", soname)
564568
_excluded_libs.add(soname)
565569
continue
570+
571+
# special case for libpython, see https://github.com/pypa/auditwheel/issues/589
572+
# we want to return the dependency to be able to remove it later on but
573+
# we don't want to analyze it for symbol versions nor do we want to analyze its
574+
# dependencies as it will be removed.
575+
if LIBPYTHON_RE.match(soname):
576+
log.info("Skip %s resolution", soname)
577+
_all_libs[soname] = DynamicLibrary(soname, None, None)
578+
continue
579+
566580
realpath, fullpath = find_lib(platform, soname, all_ldpaths, root)
567581
if realpath is not None and any(fnmatch(str(realpath), e) for e in exclude):
568582
log.info("Excluding %s", realpath)

src/auditwheel/patcher.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ class ElfPatcher:
1111
def replace_needed(self, file_name: Path, *old_new_pairs: tuple[str, str]) -> None:
1212
raise NotImplementedError()
1313

14+
def remove_needed(self, file_name: Path, *sonames: str) -> None:
15+
raise NotImplementedError()
16+
1417
def set_soname(self, file_name: Path, new_so_name: str) -> None:
1518
raise NotImplementedError()
1619

@@ -57,6 +60,15 @@ def replace_needed(self, file_name: Path, *old_new_pairs: tuple[str, str]) -> No
5760
]
5861
)
5962

63+
def remove_needed(self, file_name: Path, *sonames: str) -> None:
64+
check_call(
65+
[
66+
"patchelf",
67+
*chain.from_iterable(("--remove-needed", soname) for soname in sonames),
68+
file_name,
69+
]
70+
)
71+
6072
def set_soname(self, file_name: Path, new_so_name: str) -> None:
6173
check_call(["patchelf", "--set-soname", new_so_name, file_name])
6274

src/auditwheel/policy/__init__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
from ..tools import is_subdir
1818

1919
_HERE = Path(__file__).parent
20-
LIBPYTHON_RE = re.compile(r"^libpython\d+\.\d+m?.so(.\d)*$")
2120
_MUSL_POLICY_RE = re.compile(r"^musllinux_\d+_\d+$")
2221

2322
logger = logging.getLogger(__name__)
@@ -201,9 +200,6 @@ def filter_libs(
201200
# 'ld64.so.1' on ppc64le
202201
# 'ld-linux*' on other platforms
203202
continue
204-
if LIBPYTHON_RE.match(lib):
205-
# always exclude libpythonXY
206-
continue
207203
if lib in whitelist:
208204
# exclude any libs in the whitelist
209205
continue

src/auditwheel/repair.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919

2020
from .elfutils import elf_read_dt_needed, elf_read_rpaths
2121
from .hashfile import hashfile
22+
from .lddtree import LIBPYTHON_RE
2223
from .policy import get_replace_platforms
2324
from .tools import is_subdir, unique_by_index
2425
from .wheel_abi import WheelAbIInfo
2526
from .wheeltools import InWheelCtx, add_platforms
2627

2728
logger = logging.getLogger(__name__)
2829

29-
3030
# Copied from wheel 0.31.1
3131
WHEEL_INFO_RE = re.compile(
3232
r"""^(?P<namever>(?P<name>.+?)-(?P<ver>\d.*?))(-(?P<build>\d.*?))?
@@ -56,8 +56,9 @@ def repair_wheel(
5656
out_dir = out_dir.resolve(strict=True)
5757
wheel_fname = wheel_path.name
5858

59+
output_wheel = out_dir / wheel_fname
5960
with InWheelCtx(wheel_path) as ctx:
60-
ctx.out_wheel = out_dir / wheel_fname
61+
ctx.out_wheel = output_wheel
6162
ctx.zip_compression_level = zip_compression_level
6263

6364
match = WHEEL_INFO_RE(wheel_fname)
@@ -76,6 +77,16 @@ def repair_wheel(
7677
ext_libs = v[abis[0]].libs
7778
replacements: list[tuple[str, str]] = []
7879
for soname, src_path in ext_libs.items():
80+
# Handle libpython dependencies by removing them
81+
if LIBPYTHON_RE.match(soname):
82+
logger.warning(
83+
"Removing %s dependency from %s. Linking with libpython is forbidden for manylinux/musllinux wheels.",
84+
soname,
85+
str(fn),
86+
)
87+
patcher.remove_needed(fn, soname)
88+
continue
89+
7990
if src_path is None:
8091
msg = (
8192
"Cannot repair wheel, because required "
@@ -134,7 +145,7 @@ def repair_wheel(
134145
sbom_dir.mkdir(exist_ok=True)
135146
(sbom_dir / "auditwheel.cdx.json").write_text(json.dumps(sbom_data))
136147

137-
return ctx.out_wheel
148+
return output_wheel
138149

139150

140151
def strip_symbols(libraries: Iterable[Path]) -> None:

tests/integration/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)