Skip to content

Commit

Permalink
Add test for repair --exclude functionality
Browse files Browse the repository at this point in the history
Build numpy from source and when repairing, exclude the gfortran
library. This is only tested in a single manylinux image to avoid
increasing the test time too much, as the functionality is not dependent
on the platform.
  • Loading branch information
lkollar committed Jul 18, 2022
1 parent cb87609 commit b5f3907
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions tests/integration/test_manylinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,65 @@ def test_build_repair_numpy(
# at once in the same Python program:
docker_exec(docker_python, ["python", "-c", "'import numpy; import foo'"])

@pytest.mark.skipif(
PLATFORM != "x86_64", reason="Only needs checking on one platform"
)
def test_repair_exclude(self, io_folder):
"""Test the --exclude argument to avoid grafting certain libraries."""

policy = "manylinux_2_12"
policy_plat = f"{policy}_{PLATFORM}"
base = MANYLINUX_IMAGES[policy]
env = {"PATH": PATH[policy]}

with tmp_docker_image(
base,
[
'git config --global --add safe.directory "/auditwheel_src"',
"pip install -U pip setuptools pytest-cov",
"pip install -U -e /auditwheel_src",
],
env,
) as tmp_img:
with docker_container_ctx(tmp_img, io_folder, env) as container:
platform_tag = ".".join(
[
f"{p}_{PLATFORM}"
for p in [policy] + POLICY_ALIASES.get(policy, [])
]
)

orig_wheel = build_numpy(container, policy_plat, io_folder)
assert orig_wheel == ORIGINAL_NUMPY_WHEEL
assert "manylinux" not in orig_wheel

# Exclude libgfortran from grafting into the wheel
output = docker_exec(
container,
[
"auditwheel",
"repair",
"--plat",
policy_plat,
"--exclude",
"libgfortran.so.5",
"--only-plat",
"-w",
"/io",
f"/io/{orig_wheel}",
],
)

assert "Excluding libgfortran" in output
filenames = os.listdir(io_folder)
assert len(filenames) == 2
repaired_wheel = f"numpy-{NUMPY_VERSION}-{PYTHON_ABI}-{platform_tag}.whl"
assert repaired_wheel in filenames

# Make sure we don't have libatlas in the result
contents = zipfile.ZipFile(os.path.join(io_folder, repaired_wheel)).namelist()
assert not any(x for x in contents if x.startswith("libatlas"))

def test_build_wheel_with_binary_executable(
self, any_manylinux_container, docker_python, io_folder
):
Expand Down

0 comments on commit b5f3907

Please sign in to comment.