Skip to content

Commit 1646b08

Browse files
committed
fix: do not use linux32 when unnecessary
1 parent a873dd9 commit 1646b08

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

cibuildwheel/oci_container.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from typing import IO, Dict, Literal
1818

1919
from .typing import PathOrStr, PopenBytes
20-
from .util import CIProvider, detect_ci_provider, parse_key_value_string
20+
from .util import CIProvider, call, detect_ci_provider, parse_key_value_string
2121

2222
ContainerEngineName = Literal["docker", "podman"]
2323

@@ -110,7 +110,16 @@ def __enter__(self) -> OCIContainer:
110110
if detect_ci_provider() == CIProvider.travis_ci and platform.machine() == "ppc64le":
111111
network_args = ["--network=host"]
112112

113-
shell_args = ["linux32", "/bin/bash"] if self.simulate_32_bit else ["/bin/bash"]
113+
simulate_32_bit = self.simulate_32_bit
114+
container_machine = call(
115+
self.engine.name, "run", "--rm", self.image, "uname", "-m", capture_stdout=True
116+
).strip()
117+
if container_machine not in {"x86_64", "aarch64"}:
118+
# either the architecture running the image is already the right one
119+
# or the image entrypoint took care of this
120+
simulate_32_bit = False
121+
122+
shell_args = ["linux32", "/bin/bash"] if simulate_32_bit else ["/bin/bash"]
114123

115124
subprocess.run(
116125
[

0 commit comments

Comments
 (0)