diff --git a/.gitignore b/.gitignore index d88dd7b7..6e53458d 100644 --- a/.gitignore +++ b/.gitignore @@ -68,3 +68,4 @@ tests/integration/sample_extension/src/sample_extension.c # Downloaded by test script tests/integration/patchelf-0.17.2.1-py2.py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.musllinux_1_1_x86_64.whl +tests/integration/cryptography-46.0.3-cp38-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl diff --git a/noxfile.py b/noxfile.py index 2bc2c241..ffc2483c 100644 --- a/noxfile.py +++ b/noxfile.py @@ -59,6 +59,27 @@ def _docker_images(session: nox.Session) -> list[str]: return images_file.read_text().splitlines() +def _download_wheels_for_tests(session: nox.Session) -> None: + wheels = [ + # for tests/integration/test_bundled_wheels.py::test_analyze_wheel_abi_static_exe + ("patchelf==0.17.2.1", "py38", "manylinux1_x86_64"), + # for tests/integration/test_bundled_wheels.py::test_weak_symbols_not_blacklisted + ("cryptography==46.0.3", "cp38", "manylinux_2_17_x86_64"), + ] + for package, python_tag, platform in wheels: + session.run( + "pip", + "download", + "--only-binary=:all:", + "--no-deps", + "--dest=./tests/integration/", + f"--platform={platform}", + f"--implementation={python_tag[:2]}", + f"--python-version={python_tag[2:]}", + package, + ) + + @nox.session(python=PYTHON_ALL_VERSIONS, default=False) def tests(session: nox.Session) -> None: """Run tests.""" @@ -68,19 +89,8 @@ def tests(session: nox.Session) -> None: deps = nox.project.dependency_groups(pyproject, dep_group) session.install("-U", "pip") session.install("-e", ".", *deps) - # for tests/integration/test_bundled_wheels.py::test_analyze_wheel_abi_static_exe - session.run( - "pip", - "download", - "--only-binary", - ":all:", - "--no-deps", - "--platform", - "manylinux1_x86_64", - "-d", - "./tests/integration/", - "patchelf==0.17.2.1", - ) + _download_wheels_for_tests(session) + if RUNNING_CI: posargs.extend(["--cov", "auditwheel", "--cov-config", "pyproject.toml"]) # pull manylinux images that will be used. @@ -135,6 +145,7 @@ def develop(session: nox.Session) -> None: pyproject = nox.project.load_toml("pyproject.toml") deps = nox.project.dependency_groups(pyproject, "dev") session.install("-e", ".", *deps) + _download_wheels_for_tests(session) if __name__ == "__main__": diff --git a/src/auditwheel/elfutils.py b/src/auditwheel/elfutils.py index 142d55a7..f375a20c 100644 --- a/src/auditwheel/elfutils.py +++ b/src/auditwheel/elfutils.py @@ -131,8 +131,9 @@ def get_undefined_symbols(path: Path) -> set[str]: section = elf.get_section_by_name(".dynsym") if section is not None: # look for all undef symbols + # if the symbol is weak don't consider it as undefined, it's "optional" for sym in section.iter_symbols(): - if sym["st_shndx"] == "SHN_UNDEF": + if sym["st_shndx"] == "SHN_UNDEF" and sym["st_info"]["bind"] != "STB_WEAK": undef_symbols.add(sym.name) return undef_symbols diff --git a/tests/integration/test_bundled_wheels.py b/tests/integration/test_bundled_wheels.py index f402a5e9..db440ffa 100644 --- a/tests/integration/test_bundled_wheels.py +++ b/tests/integration/test_bundled_wheels.py @@ -258,3 +258,20 @@ def test_main_lddtree( "libraries": {}, } assert expected_json == actual_json + + +def test_weak_symbols_not_blacklisted() -> None: + # https://github.com/pypa/auditwheel/issues/663 + # the cryptography wheel overall policy was misclassified as manylinux_2_24_x86_64 + # in auditwheel 6.5.1 because it uses the undefined weak symbol '__cxa_thread_atexit_impl' + result = analyze_wheel_abi( + None, + None, + HERE / "cryptography-46.0.3-cp38-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", + frozenset(), + disable_isa_ext_check=False, + allow_graft=False, + ) + assert result.policies.libc == Libc.GLIBC + assert result.policies.architecture == Architecture.x86_64 + assert result.overall_policy.name == "manylinux_2_17_x86_64"