Skip to content

Commit

Permalink
Travis-CI: Fix Container Network
Browse files Browse the repository at this point in the history
Add `--network=host` to Travis-CI PPC64le runners.
  • Loading branch information
ax3l committed Nov 4, 2021
1 parent 5764469 commit 795c100
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cibuildwheel/docker_container.py
Expand Up @@ -31,19 +31,21 @@ class DockerContainer:
bash_stdout: IO[bytes]

def __init__(
self, *, docker_image: str, simulate_32_bit: bool = False, cwd: Optional[PathOrStr] = None
self, *, docker_image: str, simulate_32_bit: bool = False, network_host: bool = False, cwd: Optional[PathOrStr] = None
):
if not docker_image:
raise ValueError("Must have a non-empty docker image to run.")

self.docker_image = docker_image
self.simulate_32_bit = simulate_32_bit
self.network_host = network_host
self.cwd = cwd
self.name: Optional[str] = None

def __enter__(self) -> "DockerContainer":
self.name = f"cibuildwheel-{uuid.uuid4()}"
cwd_args = ["-w", str(self.cwd)] if self.cwd else []
network_args = ["--network=host"] if self.network_host else []
shell_args = ["linux32", "/bin/bash"] if self.simulate_32_bit else ["/bin/bash"]
subprocess.run(
[
Expand All @@ -53,6 +55,7 @@ def __enter__(self) -> "DockerContainer":
f"--name={self.name}",
"--interactive",
"--volume=/:/host", # ignored on CircleCI
*network_args, # mainly for TravisCI PPC64le
*cwd_args,
self.docker_image,
*shell_args,
Expand Down
1 change: 1 addition & 0 deletions cibuildwheel/linux.py
Expand Up @@ -338,6 +338,7 @@ def build(options: Options) -> None:
with DockerContainer(
docker_image=build_step.docker_image,
simulate_32_bit=build_step.platform_tag.endswith("i686"),
network_host=build_step.platform_tag.endswith("ppc64le"),
cwd=container_project_path,
) as docker:

Expand Down

0 comments on commit 795c100

Please sign in to comment.