diff --git a/tests/integration/test_bundled_wheels.py b/tests/integration/test_bundled_wheels.py index e7bb52f7..8a47cb5c 100644 --- a/tests/integration/test_bundled_wheels.py +++ b/tests/integration/test_bundled_wheels.py @@ -277,3 +277,44 @@ def test_weak_symbols_not_blacklisted() -> None: assert result.policies.libc == Libc.GLIBC assert result.policies.architecture == Architecture.x86_64 assert result.overall_policy.name == "manylinux_2_17_x86_64" + + +def test_symbol_blacklist( + monkeypatch: pytest.MonkeyPatch, + capsys: pytest.CaptureFixture[str], +) -> None: + # wheel built using main@dda40c214e3db607b6ab31cd4cf9e3e5e1347937 + # AUDITWHEEL_ARCH=x86_64 nox -s tests-3.10 -- \ + # 'tests/integration/test_manylinux.py::TestManylinux::test_zlib_blacklist[manylinux_2_12]' + wheel = HERE / "testzlib-0.0.1-cp310-cp310-linux_x86_64.whl" + result = analyze_wheel_abi( + None, + None, + wheel, + 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 == "linux_x86_64" + assert result.blacklist_policy.name == "linux_x86_64" + assert result.sym_policy.name == "manylinux_2_12_x86_64" + assert result.graft_policy.name == "manylinux_2_5_x86_64" + assert result.machine_policy.name == "manylinux_2_5_x86_64" + assert result.pyfpe_policy.name == "manylinux_2_5_x86_64" + assert result.ref_policy.name == "manylinux_2_5_x86_64" + assert result.ucs_policy.name == "manylinux_2_5_x86_64" + + monkeypatch.setattr(sys, "platform", "linux") + monkeypatch.setattr(Architecture, "detect", lambda: Architecture.x86_64) + monkeypatch.setattr(sys, "argv", ["auditwheel", "repair", str(wheel)]) + with pytest.raises(SystemExit): + main() + captured = capsys.readouterr() + assert " because it depends on black-listed symbols" in captured.err.replace("\n", " ") + + monkeypatch.setattr(sys, "argv", ["auditwheel", "-v", "show", str(wheel)]) + assert main() == 0 + captured = capsys.readouterr() + assert "black-listed symbol dependencies" in captured.out.replace("\n", " ") diff --git a/tests/integration/test_manylinux.py b/tests/integration/test_manylinux.py index b437c65b..78e0ef81 100644 --- a/tests/integration/test_manylinux.py +++ b/tests/integration/test_manylinux.py @@ -1206,32 +1206,6 @@ def test_mvec(self, anylinux: AnyLinuxContainer, python: PythonContainer) -> Non # Test the resulting wheel outside the manylinux container python.install_wheel(repaired_wheel) - def test_zlib_blacklist(self, anylinux: AnyLinuxContainer) -> None: - policy = anylinux.policy - if policy.startswith( - ( - "manylinux_2_17_", - "manylinux_2_28_", - "manylinux_2_31_", - "manylinux_2_34_", - "manylinux_2_35_", - "manylinux_2_39_", - ), - ): - pytest.skip(f"{policy} image has no blacklist symbols in libz.so.1") - - test_path = "/auditwheel_src/tests/integration/testzlib" - orig_wheel = anylinux.build_wheel(test_path) - assert orig_wheel.startswith("testzlib-0.0.1") - - # Repair the wheel using the appropriate manylinux container - with pytest.raises(CalledProcessError): - anylinux.repair(orig_wheel) - - # Check auditwheel show warns about the black listed symbols - output = anylinux.show(orig_wheel, verbose=True) - assert "black-listed symbol dependencies" in output.replace("\n", " ") - @pytest.mark.skipif(PLATFORM != "aarch64", reason="glibc blacklist only for aarch64") def test_glibc_blacklist(self, anylinux: AnyLinuxContainer, python: PythonContainer) -> None: # https://github.com/pypa/auditwheel/issues/647 diff --git a/tests/integration/testzlib-0.0.1-cp310-cp310-linux_x86_64.whl b/tests/integration/testzlib-0.0.1-cp310-cp310-linux_x86_64.whl new file mode 100644 index 00000000..b7bac53f Binary files /dev/null and b/tests/integration/testzlib-0.0.1-cp310-cp310-linux_x86_64.whl differ diff --git a/tests/integration/testzlib/pyproject.toml b/tests/integration/testzlib/pyproject.toml deleted file mode 100644 index fed528d4..00000000 --- a/tests/integration/testzlib/pyproject.toml +++ /dev/null @@ -1,3 +0,0 @@ -[build-system] -requires = ["setuptools"] -build-backend = "setuptools.build_meta" diff --git a/tests/integration/testzlib/setup.py b/tests/integration/testzlib/setup.py deleted file mode 100644 index 02a97865..00000000 --- a/tests/integration/testzlib/setup.py +++ /dev/null @@ -1,19 +0,0 @@ -from __future__ import annotations - -from setuptools import Extension, setup - -define_macros = [("_GNU_SOURCE", None)] -libraries = ["z", "c"] - -setup( - name="testzlib", - version="0.0.1", - ext_modules=[ - Extension( - "testzlib", - sources=["testzlib.c"], - define_macros=define_macros, - libraries=libraries, - ), - ], -) diff --git a/tests/integration/testzlib/testzlib.c b/tests/integration/testzlib/testzlib.c deleted file mode 100644 index a048c50e..00000000 --- a/tests/integration/testzlib/testzlib.c +++ /dev/null @@ -1,46 +0,0 @@ -#include -#include -#include - - -static PyObject * -run(PyObject *self, PyObject *args) -{ - int res; - - (void)self; - (void)args; - -#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 24) - res = gzflags() != 0; -#elif defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 17) - /* blacklist ineffective on manylinux 2014 */ - res = 0; -#elif defined(__GLIBC_PREREQ) - { - void* memory = zcalloc(NULL, 1U, 1U); - res = (memory != NULL); - zcfree(NULL, memory); - } -#else - res = 0; -#endif - return PyLong_FromLong(res); -} - -/* Module initialization */ -PyMODINIT_FUNC PyInit_testzlib(void) -{ - static PyMethodDef module_methods[] = { - {"run", (PyCFunction)run, METH_NOARGS, "run."}, - {NULL} /* Sentinel */ - }; - static struct PyModuleDef moduledef = { - PyModuleDef_HEAD_INIT, - "testzlib", - "testzlib module", - -1, - module_methods, - }; - return PyModule_Create(&moduledef); -}