Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Travis-CI: Fix Container Network #906

Merged
merged 4 commits into from Jan 6, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion cibuildwheel/docker_container.py
Expand Up @@ -31,19 +31,26 @@ 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 []
mayeut marked this conversation as resolved.
Show resolved Hide resolved
shell_args = ["linux32", "/bin/bash"] if self.simulate_32_bit else ["/bin/bash"]
subprocess.run(
[
Expand All @@ -53,6 +60,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