Skip to content

Commit

Permalink
Travis PPC64le: Move Docker Work-Around
Browse files Browse the repository at this point in the history
Move the control of the work-around for docker on ppc64le on travis
into the `docker_container` logic and do not expose as interface.
  • Loading branch information
ax3l committed Jan 4, 2022
1 parent ff80e76 commit 1399424
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
17 changes: 13 additions & 4 deletions 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 @@ -35,22 +38,28 @@ def __init__(
*,
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 []

# 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 @@ -60,7 +69,7 @@ def __enter__(self) -> "DockerContainer":
f"--name={self.name}",
"--interactive",
"--volume=/:/host", # ignored on CircleCI
*network_args, # mainly for TravisCI PPC64le
*network_args,
*cwd_args,
self.docker_image,
*shell_args,
Expand Down
1 change: 0 additions & 1 deletion cibuildwheel/linux.py
Expand Up @@ -338,7 +338,6 @@ 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 1399424

Please sign in to comment.