diff --git a/cibuildwheel/oci_container.py b/cibuildwheel/oci_container.py index 1ea22edd9..71c30f1cd 100644 --- a/cibuildwheel/oci_container.py +++ b/cibuildwheel/oci_container.py @@ -17,7 +17,7 @@ from typing import IO, Dict, Literal from .typing import PathOrStr, PopenBytes -from .util import CIProvider, detect_ci_provider, parse_key_value_string +from .util import CIProvider, call, detect_ci_provider, parse_key_value_string ContainerEngineName = Literal["docker", "podman"] @@ -108,7 +108,16 @@ def __enter__(self) -> OCIContainer: if detect_ci_provider() == CIProvider.travis_ci and platform.machine() == "ppc64le": network_args = ["--network=host"] - shell_args = ["linux32", "/bin/bash"] if self.simulate_32_bit else ["/bin/bash"] + simulate_32_bit = self.simulate_32_bit + container_machine = call( + self.engine.name, "run", "--rm", self.image, "uname", "-m", capture_stdout=True + ).strip() + if container_machine not in {"x86_64", "aarch64"}: + # either the architecture running the image is already the right one + # or the image entrypoint took care of this + simulate_32_bit = False + + shell_args = ["linux32", "/bin/bash"] if simulate_32_bit else ["/bin/bash"] subprocess.run( [