Rename DockerContainer -> OCIContainer, and a few other things

OCIContainer.container_engine -> OCIContainer.engine
OCIContainer.docker_image -> OCIContainer.image

Variables that refer to 'docker_images' have been renamed to
'container_images'
This commit is contained in:
Joe Rickerby
2022-06-27 17:46:22 +01:00
parent 2457006796
commit 1d2e5d5d8f
8 changed files with 89 additions and 112 deletions
+27 -30
View File
@@ -18,26 +18,23 @@ from .typing import Literal, PathOrStr, PopenBytes
ContainerEngine = Literal["docker", "podman"] ContainerEngine = Literal["docker", "podman"]
class DockerContainer: class OCIContainer:
""" """
An object that represents a running Docker container. An object that represents a running OCI (e.g. Docker) container.
Intended for use as a context manager e.g. Intended for use as a context manager e.g.
`with DockerContainer(docker_image = 'ubuntu') as docker:` `with OCIContainer(image = 'ubuntu') as docker:`
A bash shell is running in the remote container. When `call()` is invoked, A bash shell is running in the remote container. When `call()` is invoked,
the command is relayed to the remote shell, and the results are streamed the command is relayed to the remote shell, and the results are streamed
back to cibuildwheel. back to cibuildwheel.
TODO:
- [ ] Rename to Container as this now generalizes docker and podman?
Example: Example:
>>> from cibuildwheel.docker_container import * # NOQA >>> from cibuildwheel.docker_container import * # NOQA
>>> from cibuildwheel.options import _get_pinned_docker_images >>> from cibuildwheel.options import _get_pinned_container_images
>>> docker_image = _get_pinned_docker_images()['x86_64']['manylinux2014'] >>> image = _get_pinned_container_images()['x86_64']['manylinux2014']
>>> # Test the default container >>> # Test the default container
>>> with DockerContainer(docker_image=docker_image) as self: >>> with OCIContainer(image=image) as self:
... self.call(["echo", "hello world"]) ... self.call(["echo", "hello world"])
... self.call(["cat", "/proc/1/cgroup"]) ... self.call(["cat", "/proc/1/cgroup"])
... print(self.get_environment()) ... print(self.get_environment())
@@ -53,21 +50,21 @@ class DockerContainer:
def __init__( def __init__(
self, self,
*, *,
docker_image: str, image: str,
simulate_32_bit: bool = False, simulate_32_bit: bool = False,
cwd: Optional[PathOrStr] = None, cwd: Optional[PathOrStr] = None,
container_engine: ContainerEngine = "docker", engine: ContainerEngine = "docker",
): ):
if not docker_image: if not image:
raise ValueError("Must have a non-empty docker image to run.") raise ValueError("Must have a non-empty docker image to run.")
self.docker_image = docker_image self.image = image
self.simulate_32_bit = simulate_32_bit self.simulate_32_bit = simulate_32_bit
self.cwd = cwd self.cwd = cwd
self.name: Optional[str] = None self.name: Optional[str] = None
self.container_engine = container_engine self.engine = engine
def __enter__(self) -> "DockerContainer": def __enter__(self) -> "OCIContainer":
self.name = f"cibuildwheel-{uuid.uuid4()}" self.name = f"cibuildwheel-{uuid.uuid4()}"
@@ -83,14 +80,14 @@ class DockerContainer:
subprocess.run( subprocess.run(
[ [
self.container_engine, self.engine,
"create", "create",
"--env=CIBUILDWHEEL", "--env=CIBUILDWHEEL",
f"--name={self.name}", f"--name={self.name}",
"--interactive", "--interactive",
"--volume=/:/host", # ignored on CircleCI "--volume=/:/host", # ignored on CircleCI
*network_args, *network_args,
self.docker_image, self.image,
*shell_args, *shell_args,
], ],
check=True, check=True,
@@ -98,7 +95,7 @@ class DockerContainer:
self.process = subprocess.Popen( self.process = subprocess.Popen(
[ [
self.container_engine, self.engine,
"start", "start",
"--attach", "--attach",
"--interactive", "--interactive",
@@ -136,7 +133,7 @@ class DockerContainer:
self.bash_stdin.close() self.bash_stdin.close()
self.bash_stdout.close() self.bash_stdout.close()
if self.container_engine == "podman": if self.engine == "podman":
# This works around what seems to be a race condition in the podman # This works around what seems to be a race condition in the podman
# backend. The full reason is not understood. See PR #966 for a # backend. The full reason is not understood. See PR #966 for a
# discussion on possible causes and attempts to remove this line. # discussion on possible causes and attempts to remove this line.
@@ -146,7 +143,7 @@ class DockerContainer:
assert isinstance(self.name, str) assert isinstance(self.name, str)
subprocess.run( subprocess.run(
[self.container_engine, "rm", "--force", "-v", self.name], [self.engine, "rm", "--force", "-v", self.name],
stdout=subprocess.DEVNULL, stdout=subprocess.DEVNULL,
check=False, check=False,
) )
@@ -161,7 +158,7 @@ class DockerContainer:
if from_path.is_dir(): if from_path.is_dir():
self.call(["mkdir", "-p", to_path]) self.call(["mkdir", "-p", to_path])
subprocess.run( subprocess.run(
f"tar cf - . | {self.container_engine} exec -i {self.name} tar --no-same-owner -xC {shell_quote(to_path)} -f -", f"tar cf - . | {self.engine} exec -i {self.name} tar --no-same-owner -xC {shell_quote(to_path)} -f -",
shell=True, shell=True,
check=True, check=True,
cwd=from_path, cwd=from_path,
@@ -169,7 +166,7 @@ class DockerContainer:
else: else:
with subprocess.Popen( with subprocess.Popen(
[ [
self.container_engine, self.engine,
"exec", "exec",
"-i", "-i",
str(self.name), str(self.name),
@@ -194,10 +191,10 @@ class DockerContainer:
# note: we assume from_path is a dir # note: we assume from_path is a dir
to_path.mkdir(parents=True, exist_ok=True) to_path.mkdir(parents=True, exist_ok=True)
if self.container_engine == "podman": if self.engine == "podman":
subprocess.run( subprocess.run(
[ [
self.container_engine, self.engine,
"cp", "cp",
f"{self.name}:{from_path}/.", f"{self.name}:{from_path}/.",
str(to_path), str(to_path),
@@ -205,10 +202,10 @@ class DockerContainer:
check=True, check=True,
cwd=to_path, cwd=to_path,
) )
elif self.container_engine == "docker": elif self.engine == "docker":
# There is a bug in docker that prevents a simple 'cp' invocation # There is a bug in docker that prevents a simple 'cp' invocation
# from working https://github.com/moby/moby/issues/38995 # from working https://github.com/moby/moby/issues/38995
command = f"{self.container_engine} exec -i {self.name} tar -cC {shell_quote(from_path)} -f - . | tar -xf -" command = f"{self.engine} exec -i {self.name} tar -cC {shell_quote(from_path)} -f - . | tar -xf -"
subprocess.run( subprocess.run(
command, command,
shell=True, shell=True,
@@ -216,7 +213,7 @@ class DockerContainer:
cwd=to_path, cwd=to_path,
) )
else: else:
raise KeyError(self.container_engine) raise KeyError(self.engine)
def glob(self, path: PurePosixPath, pattern: str) -> List[PurePosixPath]: def glob(self, path: PurePosixPath, pattern: str) -> List[PurePosixPath]:
glob_pattern = path.joinpath(pattern) glob_pattern = path.joinpath(pattern)
@@ -333,10 +330,10 @@ class DockerContainer:
return self.call(command, env=environment, capture_output=True) return self.call(command, env=environment, capture_output=True)
def debug_info(self) -> str: def debug_info(self) -> str:
if self.container_engine == "podman": if self.engine == "podman":
command = f"{self.container_engine} info --debug" command = f"{self.engine} info --debug"
else: else:
command = f"{self.container_engine} info" command = f"{self.engine} info"
completed = subprocess.run( completed = subprocess.run(
command, command,
shell=True, shell=True,
+13 -11
View File
@@ -5,7 +5,7 @@ from pathlib import Path, PurePath, PurePosixPath
from typing import Iterator, List, NamedTuple, Set, Tuple from typing import Iterator, List, NamedTuple, Set, Tuple
from .architecture import Architecture from .architecture import Architecture
from .docker_container import DockerContainer from .docker_container import OCIContainer
from .logger import log from .logger import log
from .options import Options from .options import Options
from .typing import OrderedDict, PathOrStr, assert_never from .typing import OrderedDict, PathOrStr, assert_never
@@ -33,7 +33,7 @@ class PythonConfiguration(NamedTuple):
class BuildStep(NamedTuple): class BuildStep(NamedTuple):
platform_configs: List[PythonConfiguration] platform_configs: List[PythonConfiguration]
platform_tag: str platform_tag: str
docker_image: str container_image: str
def get_python_configurations( def get_python_configurations(
@@ -55,7 +55,7 @@ def get_python_configurations(
] ]
def docker_image_for_python_configuration(config: PythonConfiguration, options: Options) -> str: def container_image_for_python_configuration(config: PythonConfiguration, options: Options) -> str:
build_options = options.build_options(config.identifier) build_options = options.build_options(config.identifier)
# e.g # e.g
# identifier is 'cp310-manylinux_x86_64' # identifier is 'cp310-manylinux_x86_64'
@@ -87,15 +87,17 @@ def get_build_steps(
_, platform_tag = config.identifier.split("-", 1) _, platform_tag = config.identifier.split("-", 1)
before_all = options.build_options(config.identifier).before_all before_all = options.build_options(config.identifier).before_all
docker_image = docker_image_for_python_configuration(config, options) container_image = container_image_for_python_configuration(config, options)
step_key = (platform_tag, docker_image, before_all) step_key = (platform_tag, container_image, before_all)
if step_key in steps: if step_key in steps:
steps[step_key].platform_configs.append(config) steps[step_key].platform_configs.append(config)
else: else:
steps[step_key] = BuildStep( steps[step_key] = BuildStep(
platform_configs=[config], platform_tag=platform_tag, docker_image=docker_image platform_configs=[config],
platform_tag=platform_tag,
container_image=container_image,
) )
yield from steps.values() yield from steps.values()
@@ -105,7 +107,7 @@ def build_on_docker(
*, *,
options: Options, options: Options,
platform_configs: List[PythonConfiguration], platform_configs: List[PythonConfiguration],
docker: DockerContainer, docker: OCIContainer,
container_project_path: PurePath, container_project_path: PurePath,
container_package_dir: PurePath, container_package_dir: PurePath,
) -> None: ) -> None:
@@ -357,14 +359,14 @@ def build(options: Options, tmp_path: Path) -> None: # pylint: disable=unused-a
try: try:
ids_to_build = [x.identifier for x in build_step.platform_configs] ids_to_build = [x.identifier for x in build_step.platform_configs]
log.step( log.step(
f"Starting Docker image {build_step.docker_image} for {', '.join(ids_to_build)}..." f"Starting Docker image {build_step.container_image} for {', '.join(ids_to_build)}..."
) )
with DockerContainer( with OCIContainer(
docker_image=build_step.docker_image, image=build_step.container_image,
simulate_32_bit=build_step.platform_tag.endswith("i686"), simulate_32_bit=build_step.platform_tag.endswith("i686"),
cwd=container_project_path, cwd=container_project_path,
container_engine=options.globals.container_engine, engine=options.globals.container_engine,
) as docker: ) as docker:
build_on_docker( build_on_docker(
+8 -8
View File
@@ -485,10 +485,10 @@ class Options:
manylinux_images: Dict[str, str] = {} manylinux_images: Dict[str, str] = {}
musllinux_images: Dict[str, str] = {} musllinux_images: Dict[str, str] = {}
if self.platform == "linux": if self.platform == "linux":
all_pinned_docker_images = _get_pinned_docker_images() all_pinned_container_images = _get_pinned_container_images()
for build_platform in MANYLINUX_ARCHS: for build_platform in MANYLINUX_ARCHS:
pinned_images = all_pinned_docker_images[build_platform] pinned_images = all_pinned_container_images[build_platform]
config_value = self.reader.get( config_value = self.reader.get(
f"manylinux-{build_platform}-image", ignore_empty=True f"manylinux-{build_platform}-image", ignore_empty=True
@@ -505,7 +505,7 @@ class Options:
manylinux_images[build_platform] = image manylinux_images[build_platform] = image
for build_platform in MUSLLINUX_ARCHS: for build_platform in MUSLLINUX_ARCHS:
pinned_images = all_pinned_docker_images[build_platform] pinned_images = all_pinned_container_images[build_platform]
config_value = self.reader.get(f"musllinux-{build_platform}-image") config_value = self.reader.get(f"musllinux-{build_platform}-image")
@@ -591,7 +591,7 @@ def compute_options(
@functools.lru_cache(maxsize=None) @functools.lru_cache(maxsize=None)
def _get_pinned_docker_images() -> Mapping[str, Mapping[str, str]]: def _get_pinned_container_images() -> Mapping[str, Mapping[str, str]]:
""" """
This looks like a dict of dicts, e.g. This looks like a dict of dicts, e.g.
{ 'x86_64': {'manylinux1': '...', 'manylinux2010': '...', 'manylinux2014': '...'}, { 'x86_64': {'manylinux1': '...', 'manylinux2010': '...', 'manylinux2014': '...'},
@@ -600,10 +600,10 @@ def _get_pinned_docker_images() -> Mapping[str, Mapping[str, str]]:
... } ... }
""" """
pinned_docker_images_file = resources_dir / "pinned_docker_images.cfg" pinned_images_file = resources_dir / "pinned_docker_images.cfg"
all_pinned_docker_images = ConfigParser() all_pinned_images = ConfigParser()
all_pinned_docker_images.read(pinned_docker_images_file) all_pinned_images.read(pinned_images_file)
return all_pinned_docker_images return all_pinned_images
def deprecated_selectors(name: str, selector: str, *, error: bool = False) -> None: def deprecated_selectors(name: str, selector: str, *, error: bool = False) -> None:
+16 -38
View File
@@ -9,7 +9,7 @@ from pathlib import Path, PurePath, PurePosixPath
import pytest import pytest
import toml import toml
from cibuildwheel.docker_container import DockerContainer from cibuildwheel.docker_container import OCIContainer
from cibuildwheel.environment import EnvironmentAssignmentBash from cibuildwheel.environment import EnvironmentAssignmentBash
# Test utilities # Test utilities
@@ -42,30 +42,24 @@ def container_engine(request):
def test_simple(container_engine): def test_simple(container_engine):
with DockerContainer( with OCIContainer(engine=container_engine, image=DEFAULT_IMAGE) as container:
container_engine=container_engine, docker_image=DEFAULT_IMAGE
) as container:
assert container.call(["echo", "hello"], capture_output=True) == "hello\n" assert container.call(["echo", "hello"], capture_output=True) == "hello\n"
def test_no_lf(container_engine): def test_no_lf(container_engine):
with DockerContainer( with OCIContainer(engine=container_engine, image=DEFAULT_IMAGE) as container:
container_engine=container_engine, docker_image=DEFAULT_IMAGE
) as container:
assert container.call(["printf", "hello"], capture_output=True) == "hello" assert container.call(["printf", "hello"], capture_output=True) == "hello"
def test_debug_info(container_engine): def test_debug_info(container_engine):
container = DockerContainer(container_engine=container_engine, docker_image=DEFAULT_IMAGE) container = OCIContainer(engine=container_engine, image=DEFAULT_IMAGE)
print(container.debug_info()) print(container.debug_info())
with container: with container:
pass pass
def test_environment(container_engine): def test_environment(container_engine):
with DockerContainer( with OCIContainer(engine=container_engine, image=DEFAULT_IMAGE) as container:
container_engine=container_engine, docker_image=DEFAULT_IMAGE
) as container:
assert ( assert (
container.call( container.call(
["sh", "-c", "echo $TEST_VAR"], env={"TEST_VAR": "1"}, capture_output=True ["sh", "-c", "echo $TEST_VAR"], env={"TEST_VAR": "1"}, capture_output=True
@@ -75,21 +69,17 @@ def test_environment(container_engine):
def test_cwd(container_engine): def test_cwd(container_engine):
with DockerContainer( with OCIContainer(
container_engine=container_engine, engine=container_engine, image=DEFAULT_IMAGE, cwd="/cibuildwheel/working_directory"
docker_image=DEFAULT_IMAGE,
cwd="/cibuildwheel/working_directory",
) as container: ) as container:
assert container.call(["pwd"], capture_output=True) == "/cibuildwheel/working_directory\n" assert container.call(["pwd"], capture_output=True) == "/cibuildwheel/working_directory\n"
assert container.call(["pwd"], capture_output=True, cwd="/opt") == "/opt\n" assert container.call(["pwd"], capture_output=True, cwd="/opt") == "/opt\n"
def test_container_removed(container_engine): def test_container_removed(container_engine):
with DockerContainer( with OCIContainer(engine=container_engine, image=DEFAULT_IMAGE) as container:
container_engine=container_engine, docker_image=DEFAULT_IMAGE
) as container:
docker_containers_listing = subprocess.run( docker_containers_listing = subprocess.run(
f"{container.container_engine} container ls", f"{container.engine} container ls",
shell=True, shell=True,
check=True, check=True,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
@@ -100,7 +90,7 @@ def test_container_removed(container_engine):
old_container_name = container.name old_container_name = container.name
docker_containers_listing = subprocess.run( docker_containers_listing = subprocess.run(
f"{container.container_engine} container ls", f"{container.engine} container ls",
shell=True, shell=True,
check=True, check=True,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
@@ -119,9 +109,7 @@ def test_large_environment(container_engine):
"d": "0" * long_env_var_length, "d": "0" * long_env_var_length,
} }
with DockerContainer( with OCIContainer(engine=container_engine, image=DEFAULT_IMAGE) as container:
container_engine=container_engine, docker_image=DEFAULT_IMAGE
) as container:
# check the length of d # check the length of d
assert ( assert (
container.call(["sh", "-c", "echo ${#d}"], env=large_environment, capture_output=True) container.call(["sh", "-c", "echo ${#d}"], env=large_environment, capture_output=True)
@@ -130,9 +118,7 @@ def test_large_environment(container_engine):
def test_binary_output(container_engine): def test_binary_output(container_engine):
with DockerContainer( with OCIContainer(engine=container_engine, image=DEFAULT_IMAGE) as container:
container_engine=container_engine, docker_image=DEFAULT_IMAGE
) as container:
# note: the below embedded snippets are in python2 # note: the below embedded snippets are in python2
# check that we can pass though arbitrary binary data without erroring # check that we can pass though arbitrary binary data without erroring
@@ -182,9 +168,7 @@ def test_binary_output(container_engine):
def test_file_operation(tmp_path: Path, container_engine): def test_file_operation(tmp_path: Path, container_engine):
with DockerContainer( with OCIContainer(engine=container_engine, image=DEFAULT_IMAGE) as container:
container_engine=container_engine, docker_image=DEFAULT_IMAGE
) as container:
# test copying a file in # test copying a file in
test_binary_data = bytes(random.randrange(256) for _ in range(1000)) test_binary_data = bytes(random.randrange(256) for _ in range(1000))
original_test_file = tmp_path / "test.dat" original_test_file = tmp_path / "test.dat"
@@ -199,9 +183,7 @@ def test_file_operation(tmp_path: Path, container_engine):
def test_dir_operations(tmp_path: Path, container_engine): def test_dir_operations(tmp_path: Path, container_engine):
with DockerContainer( with OCIContainer(engine=container_engine, image=DEFAULT_IMAGE) as container:
container_engine=container_engine, docker_image=DEFAULT_IMAGE
) as container:
test_binary_data = bytes(random.randrange(256) for _ in range(1000)) test_binary_data = bytes(random.randrange(256) for _ in range(1000))
original_test_file = tmp_path / "test.dat" original_test_file = tmp_path / "test.dat"
original_test_file.write_bytes(test_binary_data) original_test_file.write_bytes(test_binary_data)
@@ -230,9 +212,7 @@ def test_dir_operations(tmp_path: Path, container_engine):
def test_environment_executor(container_engine): def test_environment_executor(container_engine):
with DockerContainer( with OCIContainer(engine=container_engine, image=DEFAULT_IMAGE) as container:
container_engine=container_engine, docker_image=DEFAULT_IMAGE
) as container:
assignment = EnvironmentAssignmentBash("TEST=$(echo 42)") assignment = EnvironmentAssignmentBash("TEST=$(echo 42)")
assert assignment.evaluated_value({}, container.environment_executor) == "42" assert assignment.evaluated_value({}, container.environment_executor) == "42"
@@ -298,9 +278,7 @@ def test_podman_vfs(container_engine, tmp_path: Path, monkeypatch):
monkeypatch.setenv("CONTAINERS_CONF", str(vfs_containers_conf_fpath)) monkeypatch.setenv("CONTAINERS_CONF", str(vfs_containers_conf_fpath))
monkeypatch.setenv("CONTAINERS_STORAGE_CONF", str(vfs_containers_storage_conf_fpath)) monkeypatch.setenv("CONTAINERS_STORAGE_CONF", str(vfs_containers_storage_conf_fpath))
with DockerContainer( with OCIContainer(engine=container_engine, image=DEFAULT_IMAGE) as container:
container_engine=container_engine, docker_image=DEFAULT_IMAGE
) as container:
# test running a command # test running a command
assert container.call(["echo", "hello"], capture_output=True) == "hello\n" assert container.call(["echo", "hello"], capture_output=True) == "hello\n"
+7 -7
View File
@@ -21,16 +21,16 @@ def test_linux_container_split(tmp_path: Path, monkeypatch):
textwrap.dedent( textwrap.dedent(
""" """
[tool.cibuildwheel] [tool.cibuildwheel]
manylinux-x86_64-image = "normal_docker_image" manylinux-x86_64-image = "normal_container_image"
manylinux-i686-image = "normal_docker_image" manylinux-i686-image = "normal_container_image"
build = "*-manylinux_x86_64" build = "*-manylinux_x86_64"
skip = "pp*" skip = "pp*"
archs = "x86_64 i686" archs = "x86_64 i686"
[[tool.cibuildwheel.overrides]] [[tool.cibuildwheel.overrides]]
select = "cp{38,39,310}-*" select = "cp{38,39,310}-*"
manylinux-x86_64-image = "other_docker_image" manylinux-x86_64-image = "other_container_image"
manylinux-i686-image = "other_docker_image" manylinux-i686-image = "other_container_image"
[[tool.cibuildwheel.overrides]] [[tool.cibuildwheel.overrides]]
select = "cp39-*" select = "cp39-*"
@@ -57,14 +57,14 @@ def test_linux_container_split(tmp_path: Path, monkeypatch):
pprint(build_steps) pprint(build_steps)
assert build_steps[0].docker_image == "normal_docker_image" assert build_steps[0].container_image == "normal_container_image"
assert identifiers(build_steps[0]) == ["cp36-manylinux_x86_64", "cp37-manylinux_x86_64"] assert identifiers(build_steps[0]) == ["cp36-manylinux_x86_64", "cp37-manylinux_x86_64"]
assert before_alls(build_steps[0]) == ["", ""] assert before_alls(build_steps[0]) == ["", ""]
assert build_steps[1].docker_image == "other_docker_image" assert build_steps[1].container_image == "other_container_image"
assert identifiers(build_steps[1]) == ["cp38-manylinux_x86_64", "cp310-manylinux_x86_64"] assert identifiers(build_steps[1]) == ["cp38-manylinux_x86_64", "cp310-manylinux_x86_64"]
assert before_alls(build_steps[1]) == ["", ""] assert before_alls(build_steps[1]) == ["", ""]
assert build_steps[2].docker_image == "other_docker_image" assert build_steps[2].container_image == "other_container_image"
assert identifiers(build_steps[2]) == ["cp39-manylinux_x86_64"] assert identifiers(build_steps[2]) == ["cp39-manylinux_x86_64"]
assert before_alls(build_steps[2]) == ["echo 'a cp39-only command'"] assert before_alls(build_steps[2]) == ["echo 'a cp39-only command'"]
+2 -2
View File
@@ -11,7 +11,7 @@ else:
from cibuildwheel.__main__ import main from cibuildwheel.__main__ import main
from cibuildwheel.environment import ParsedEnvironment from cibuildwheel.environment import ParsedEnvironment
from cibuildwheel.options import BuildOptions, _get_pinned_docker_images from cibuildwheel.options import BuildOptions, _get_pinned_container_images
from cibuildwheel.util import BuildSelector, resources_dir from cibuildwheel.util import BuildSelector, resources_dir
# CIBW_PLATFORM is tested in main_platform_test.py # CIBW_PLATFORM is tested in main_platform_test.py
@@ -339,6 +339,6 @@ def test_defaults(platform, intercepted_build_args):
if platform == "linux": if platform == "linux":
assert build_options.manylinux_images assert build_options.manylinux_images
pinned_images = _get_pinned_docker_images() pinned_images = _get_pinned_container_images()
default_x86_64_image = pinned_images["x86_64"][defaults["manylinux-x86_64-image"]] default_x86_64_image = pinned_images["x86_64"][defaults["manylinux-x86_64-image"]]
assert build_options.manylinux_images["x86_64"] == default_x86_64_image assert build_options.manylinux_images["x86_64"] == default_x86_64_image
+11 -11
View File
@@ -35,7 +35,7 @@ def mock_build_docker(monkeypatch):
monkeypatch.setattr(subprocess, "Popen", fail_on_call) monkeypatch.setattr(subprocess, "Popen", fail_on_call)
monkeypatch.setattr(subprocess, "run", ignore_call) monkeypatch.setattr(subprocess, "run", ignore_call)
monkeypatch.setattr(util, "download", fail_on_call) monkeypatch.setattr(util, "download", fail_on_call)
monkeypatch.setattr("cibuildwheel.linux.DockerContainer", ignore_context_call) monkeypatch.setattr("cibuildwheel.linux.OCIContainer", ignore_context_call)
monkeypatch.setattr("cibuildwheel.linux.build_on_docker", mock.Mock(spec=linux.build_on_docker)) monkeypatch.setattr("cibuildwheel.linux.build_on_docker", mock.Mock(spec=linux.build_on_docker))
monkeypatch.setattr("cibuildwheel.util.print_new_wheels", ignore_context_call) monkeypatch.setattr("cibuildwheel.util.print_new_wheels", ignore_context_call)
@@ -52,7 +52,7 @@ def test_build_default_launches(mock_build_docker, fake_package_dir, monkeypatch
# In Python 3.8+, this can be simplified to [0].kwargs # In Python 3.8+, this can be simplified to [0].kwargs
kwargs = build_on_docker.call_args_list[0][1] kwargs = build_on_docker.call_args_list[0][1]
assert "quay.io/pypa/manylinux2014_x86_64" in kwargs["docker"]["docker_image"] assert "quay.io/pypa/manylinux2014_x86_64" in kwargs["docker"]["image"]
assert kwargs["docker"]["cwd"] == PurePosixPath("/project") assert kwargs["docker"]["cwd"] == PurePosixPath("/project")
assert not kwargs["docker"]["simulate_32_bit"] assert not kwargs["docker"]["simulate_32_bit"]
@@ -60,7 +60,7 @@ def test_build_default_launches(mock_build_docker, fake_package_dir, monkeypatch
assert identifiers == {f"{x}-manylinux_x86_64" for x in ALL_IDS} assert identifiers == {f"{x}-manylinux_x86_64" for x in ALL_IDS}
kwargs = build_on_docker.call_args_list[1][1] kwargs = build_on_docker.call_args_list[1][1]
assert "quay.io/pypa/manylinux2014_i686" in kwargs["docker"]["docker_image"] assert "quay.io/pypa/manylinux2014_i686" in kwargs["docker"]["image"]
assert kwargs["docker"]["cwd"] == PurePosixPath("/project") assert kwargs["docker"]["cwd"] == PurePosixPath("/project")
assert kwargs["docker"]["simulate_32_bit"] assert kwargs["docker"]["simulate_32_bit"]
@@ -68,7 +68,7 @@ def test_build_default_launches(mock_build_docker, fake_package_dir, monkeypatch
assert identifiers == {f"{x}-manylinux_i686" for x in ALL_IDS} assert identifiers == {f"{x}-manylinux_i686" for x in ALL_IDS}
kwargs = build_on_docker.call_args_list[2][1] kwargs = build_on_docker.call_args_list[2][1]
assert "quay.io/pypa/musllinux_1_1_x86_64" in kwargs["docker"]["docker_image"] assert "quay.io/pypa/musllinux_1_1_x86_64" in kwargs["docker"]["image"]
assert kwargs["docker"]["cwd"] == PurePosixPath("/project") assert kwargs["docker"]["cwd"] == PurePosixPath("/project")
assert not kwargs["docker"]["simulate_32_bit"] assert not kwargs["docker"]["simulate_32_bit"]
@@ -78,7 +78,7 @@ def test_build_default_launches(mock_build_docker, fake_package_dir, monkeypatch
} }
kwargs = build_on_docker.call_args_list[3][1] kwargs = build_on_docker.call_args_list[3][1]
assert "quay.io/pypa/musllinux_1_1_i686" in kwargs["docker"]["docker_image"] assert "quay.io/pypa/musllinux_1_1_i686" in kwargs["docker"]["image"]
assert kwargs["docker"]["cwd"] == PurePosixPath("/project") assert kwargs["docker"]["cwd"] == PurePosixPath("/project")
assert kwargs["docker"]["simulate_32_bit"] assert kwargs["docker"]["simulate_32_bit"]
@@ -118,7 +118,7 @@ before-all = "true"
assert build_on_docker.call_count == 6 assert build_on_docker.call_count == 6
kwargs = build_on_docker.call_args_list[0][1] kwargs = build_on_docker.call_args_list[0][1]
assert "quay.io/pypa/manylinux2014_x86_64" in kwargs["docker"]["docker_image"] assert "quay.io/pypa/manylinux2014_x86_64" in kwargs["docker"]["image"]
assert kwargs["docker"]["cwd"] == PurePosixPath("/project") assert kwargs["docker"]["cwd"] == PurePosixPath("/project")
assert not kwargs["docker"]["simulate_32_bit"] assert not kwargs["docker"]["simulate_32_bit"]
@@ -127,7 +127,7 @@ before-all = "true"
assert kwargs["options"].build_options("cp36-manylinux_x86_64").before_all == "true" assert kwargs["options"].build_options("cp36-manylinux_x86_64").before_all == "true"
kwargs = build_on_docker.call_args_list[1][1] kwargs = build_on_docker.call_args_list[1][1]
assert "quay.io/pypa/manylinux2014_x86_64" in kwargs["docker"]["docker_image"] assert "quay.io/pypa/manylinux2014_x86_64" in kwargs["docker"]["image"]
assert kwargs["docker"]["cwd"] == PurePosixPath("/project") assert kwargs["docker"]["cwd"] == PurePosixPath("/project")
assert not kwargs["docker"]["simulate_32_bit"] assert not kwargs["docker"]["simulate_32_bit"]
@@ -138,7 +138,7 @@ before-all = "true"
assert kwargs["options"].build_options("cp37-manylinux_x86_64").before_all == "" assert kwargs["options"].build_options("cp37-manylinux_x86_64").before_all == ""
kwargs = build_on_docker.call_args_list[2][1] kwargs = build_on_docker.call_args_list[2][1]
assert "quay.io/pypa/manylinux_2_24_x86_64" in kwargs["docker"]["docker_image"] assert "quay.io/pypa/manylinux_2_24_x86_64" in kwargs["docker"]["image"]
assert kwargs["docker"]["cwd"] == PurePosixPath("/project") assert kwargs["docker"]["cwd"] == PurePosixPath("/project")
assert not kwargs["docker"]["simulate_32_bit"] assert not kwargs["docker"]["simulate_32_bit"]
identifiers = {x.identifier for x in kwargs["platform_configs"]} identifiers = {x.identifier for x in kwargs["platform_configs"]}
@@ -150,7 +150,7 @@ before-all = "true"
} }
kwargs = build_on_docker.call_args_list[3][1] kwargs = build_on_docker.call_args_list[3][1]
assert "quay.io/pypa/manylinux2014_i686" in kwargs["docker"]["docker_image"] assert "quay.io/pypa/manylinux2014_i686" in kwargs["docker"]["image"]
assert kwargs["docker"]["cwd"] == PurePosixPath("/project") assert kwargs["docker"]["cwd"] == PurePosixPath("/project")
assert kwargs["docker"]["simulate_32_bit"] assert kwargs["docker"]["simulate_32_bit"]
@@ -158,7 +158,7 @@ before-all = "true"
assert identifiers == {f"{x}-manylinux_i686" for x in ALL_IDS} assert identifiers == {f"{x}-manylinux_i686" for x in ALL_IDS}
kwargs = build_on_docker.call_args_list[4][1] kwargs = build_on_docker.call_args_list[4][1]
assert "quay.io/pypa/musllinux_1_1_x86_64" in kwargs["docker"]["docker_image"] assert "quay.io/pypa/musllinux_1_1_x86_64" in kwargs["docker"]["image"]
assert kwargs["docker"]["cwd"] == PurePosixPath("/project") assert kwargs["docker"]["cwd"] == PurePosixPath("/project")
assert not kwargs["docker"]["simulate_32_bit"] assert not kwargs["docker"]["simulate_32_bit"]
@@ -168,7 +168,7 @@ before-all = "true"
} }
kwargs = build_on_docker.call_args_list[5][1] kwargs = build_on_docker.call_args_list[5][1]
assert "quay.io/pypa/musllinux_1_1_i686" in kwargs["docker"]["docker_image"] assert "quay.io/pypa/musllinux_1_1_i686" in kwargs["docker"]["image"]
assert kwargs["docker"]["cwd"] == PurePosixPath("/project") assert kwargs["docker"]["cwd"] == PurePosixPath("/project")
assert kwargs["docker"]["simulate_32_bit"] assert kwargs["docker"]["simulate_32_bit"]
+5 -5
View File
@@ -4,7 +4,7 @@ import pytest
from cibuildwheel.__main__ import get_build_identifiers from cibuildwheel.__main__ import get_build_identifiers
from cibuildwheel.environment import parse_environment from cibuildwheel.environment import parse_environment
from cibuildwheel.options import Options, _get_pinned_docker_images from cibuildwheel.options import Options, _get_pinned_container_images
from .utils import get_default_command_line_arguments from .utils import get_default_command_line_arguments
@@ -58,18 +58,18 @@ test_command: 'pyproject'
assert default_build_options.environment == parse_environment('FOO="BAR"') assert default_build_options.environment == parse_environment('FOO="BAR"')
all_pinned_docker_images = _get_pinned_docker_images() all_pinned_container_images = _get_pinned_container_images()
pinned_x86_64_docker_image = all_pinned_docker_images["x86_64"] pinned_x86_64_container_image = all_pinned_container_images["x86_64"]
local = options.build_options("cp38-manylinux_x86_64") local = options.build_options("cp38-manylinux_x86_64")
assert local.manylinux_images is not None assert local.manylinux_images is not None
assert local.test_command == "pyproject" assert local.test_command == "pyproject"
assert local.manylinux_images["x86_64"] == pinned_x86_64_docker_image["manylinux1"] assert local.manylinux_images["x86_64"] == pinned_x86_64_container_image["manylinux1"]
local = options.build_options("cp37-manylinux_x86_64") local = options.build_options("cp37-manylinux_x86_64")
assert local.manylinux_images is not None assert local.manylinux_images is not None
assert local.test_command == "pyproject-override" assert local.test_command == "pyproject-override"
assert local.manylinux_images["x86_64"] == pinned_x86_64_docker_image["manylinux2014"] assert local.manylinux_images["x86_64"] == pinned_x86_64_container_image["manylinux2014"]
def test_passthrough(tmp_path, monkeypatch): def test_passthrough(tmp_path, monkeypatch):