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
Changes from 3 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
19 changes: 18 additions & 1 deletion cibuildwheel/docker_container.py
@@ -1,6 +1,7 @@
import io
import json
import os
import platform
import shlex
import subprocess
import sys
Expand All @@ -9,6 +10,8 @@
from types import TracebackType
from typing import IO, Dict, List, Optional, Sequence, Type, cast

from cibuildwheel.util import CIProvider, detect_ci_provider

from .typing import PathOrStr, PopenBytes


Expand All @@ -31,7 +34,11 @@ 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,
cwd: Optional[PathOrStr] = None,
mayeut marked this conversation as resolved.
Show resolved Hide resolved
):
if not docker_image:
raise ValueError("Must have a non-empty docker image to run.")
Expand All @@ -44,6 +51,15 @@ def __init__(
def __enter__(self) -> "DockerContainer":
self.name = f"cibuildwheel-{uuid.uuid4()}"
cwd_args = ["-w", str(self.cwd)] if self.cwd else []

# work-around for Travis-CI PPC64le Docker runs since 2021:
# this avoids network splits
# https://github.com/pypa/cibuildwheel/issues/904
# https://github.com/conda-forge/conda-smithy/pull/1520
network_args = []
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"]
subprocess.run(
[
Expand All @@ -53,6 +69,7 @@ def __enter__(self) -> "DockerContainer":
f"--name={self.name}",
"--interactive",
"--volume=/:/host", # ignored on CircleCI
*network_args,
*cwd_args,
self.docker_image,
*shell_args,
Expand Down