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:
@@ -18,26 +18,23 @@ from .typing import Literal, PathOrStr, PopenBytes
|
||||
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.
|
||||
`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,
|
||||
the command is relayed to the remote shell, and the results are streamed
|
||||
back to cibuildwheel.
|
||||
|
||||
TODO:
|
||||
- [ ] Rename to Container as this now generalizes docker and podman?
|
||||
|
||||
Example:
|
||||
>>> from cibuildwheel.docker_container import * # NOQA
|
||||
>>> from cibuildwheel.options import _get_pinned_docker_images
|
||||
>>> docker_image = _get_pinned_docker_images()['x86_64']['manylinux2014']
|
||||
>>> from cibuildwheel.options import _get_pinned_container_images
|
||||
>>> image = _get_pinned_container_images()['x86_64']['manylinux2014']
|
||||
>>> # 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(["cat", "/proc/1/cgroup"])
|
||||
... print(self.get_environment())
|
||||
@@ -53,21 +50,21 @@ class DockerContainer:
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
docker_image: str,
|
||||
image: str,
|
||||
simulate_32_bit: bool = False,
|
||||
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.")
|
||||
|
||||
self.docker_image = docker_image
|
||||
self.image = image
|
||||
self.simulate_32_bit = simulate_32_bit
|
||||
self.cwd = cwd
|
||||
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()}"
|
||||
|
||||
@@ -83,14 +80,14 @@ class DockerContainer:
|
||||
|
||||
subprocess.run(
|
||||
[
|
||||
self.container_engine,
|
||||
self.engine,
|
||||
"create",
|
||||
"--env=CIBUILDWHEEL",
|
||||
f"--name={self.name}",
|
||||
"--interactive",
|
||||
"--volume=/:/host", # ignored on CircleCI
|
||||
*network_args,
|
||||
self.docker_image,
|
||||
self.image,
|
||||
*shell_args,
|
||||
],
|
||||
check=True,
|
||||
@@ -98,7 +95,7 @@ class DockerContainer:
|
||||
|
||||
self.process = subprocess.Popen(
|
||||
[
|
||||
self.container_engine,
|
||||
self.engine,
|
||||
"start",
|
||||
"--attach",
|
||||
"--interactive",
|
||||
@@ -136,7 +133,7 @@ class DockerContainer:
|
||||
self.bash_stdin.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
|
||||
# backend. The full reason is not understood. See PR #966 for a
|
||||
# discussion on possible causes and attempts to remove this line.
|
||||
@@ -146,7 +143,7 @@ class DockerContainer:
|
||||
assert isinstance(self.name, str)
|
||||
|
||||
subprocess.run(
|
||||
[self.container_engine, "rm", "--force", "-v", self.name],
|
||||
[self.engine, "rm", "--force", "-v", self.name],
|
||||
stdout=subprocess.DEVNULL,
|
||||
check=False,
|
||||
)
|
||||
@@ -161,7 +158,7 @@ class DockerContainer:
|
||||
if from_path.is_dir():
|
||||
self.call(["mkdir", "-p", to_path])
|
||||
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,
|
||||
check=True,
|
||||
cwd=from_path,
|
||||
@@ -169,7 +166,7 @@ class DockerContainer:
|
||||
else:
|
||||
with subprocess.Popen(
|
||||
[
|
||||
self.container_engine,
|
||||
self.engine,
|
||||
"exec",
|
||||
"-i",
|
||||
str(self.name),
|
||||
@@ -194,10 +191,10 @@ class DockerContainer:
|
||||
# note: we assume from_path is a dir
|
||||
to_path.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
if self.container_engine == "podman":
|
||||
if self.engine == "podman":
|
||||
subprocess.run(
|
||||
[
|
||||
self.container_engine,
|
||||
self.engine,
|
||||
"cp",
|
||||
f"{self.name}:{from_path}/.",
|
||||
str(to_path),
|
||||
@@ -205,10 +202,10 @@ class DockerContainer:
|
||||
check=True,
|
||||
cwd=to_path,
|
||||
)
|
||||
elif self.container_engine == "docker":
|
||||
elif self.engine == "docker":
|
||||
# There is a bug in docker that prevents a simple 'cp' invocation
|
||||
# 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(
|
||||
command,
|
||||
shell=True,
|
||||
@@ -216,7 +213,7 @@ class DockerContainer:
|
||||
cwd=to_path,
|
||||
)
|
||||
else:
|
||||
raise KeyError(self.container_engine)
|
||||
raise KeyError(self.engine)
|
||||
|
||||
def glob(self, path: PurePosixPath, pattern: str) -> List[PurePosixPath]:
|
||||
glob_pattern = path.joinpath(pattern)
|
||||
@@ -333,10 +330,10 @@ class DockerContainer:
|
||||
return self.call(command, env=environment, capture_output=True)
|
||||
|
||||
def debug_info(self) -> str:
|
||||
if self.container_engine == "podman":
|
||||
command = f"{self.container_engine} info --debug"
|
||||
if self.engine == "podman":
|
||||
command = f"{self.engine} info --debug"
|
||||
else:
|
||||
command = f"{self.container_engine} info"
|
||||
command = f"{self.engine} info"
|
||||
completed = subprocess.run(
|
||||
command,
|
||||
shell=True,
|
||||
|
||||
+13
-11
@@ -5,7 +5,7 @@ from pathlib import Path, PurePath, PurePosixPath
|
||||
from typing import Iterator, List, NamedTuple, Set, Tuple
|
||||
|
||||
from .architecture import Architecture
|
||||
from .docker_container import DockerContainer
|
||||
from .docker_container import OCIContainer
|
||||
from .logger import log
|
||||
from .options import Options
|
||||
from .typing import OrderedDict, PathOrStr, assert_never
|
||||
@@ -33,7 +33,7 @@ class PythonConfiguration(NamedTuple):
|
||||
class BuildStep(NamedTuple):
|
||||
platform_configs: List[PythonConfiguration]
|
||||
platform_tag: str
|
||||
docker_image: str
|
||||
container_image: str
|
||||
|
||||
|
||||
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)
|
||||
# e.g
|
||||
# identifier is 'cp310-manylinux_x86_64'
|
||||
@@ -87,15 +87,17 @@ def get_build_steps(
|
||||
_, platform_tag = config.identifier.split("-", 1)
|
||||
|
||||
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:
|
||||
steps[step_key].platform_configs.append(config)
|
||||
else:
|
||||
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()
|
||||
@@ -105,7 +107,7 @@ def build_on_docker(
|
||||
*,
|
||||
options: Options,
|
||||
platform_configs: List[PythonConfiguration],
|
||||
docker: DockerContainer,
|
||||
docker: OCIContainer,
|
||||
container_project_path: PurePath,
|
||||
container_package_dir: PurePath,
|
||||
) -> None:
|
||||
@@ -357,14 +359,14 @@ def build(options: Options, tmp_path: Path) -> None: # pylint: disable=unused-a
|
||||
try:
|
||||
ids_to_build = [x.identifier for x in build_step.platform_configs]
|
||||
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(
|
||||
docker_image=build_step.docker_image,
|
||||
with OCIContainer(
|
||||
image=build_step.container_image,
|
||||
simulate_32_bit=build_step.platform_tag.endswith("i686"),
|
||||
cwd=container_project_path,
|
||||
container_engine=options.globals.container_engine,
|
||||
engine=options.globals.container_engine,
|
||||
) as docker:
|
||||
|
||||
build_on_docker(
|
||||
|
||||
@@ -485,10 +485,10 @@ class Options:
|
||||
manylinux_images: Dict[str, str] = {}
|
||||
musllinux_images: Dict[str, str] = {}
|
||||
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:
|
||||
pinned_images = all_pinned_docker_images[build_platform]
|
||||
pinned_images = all_pinned_container_images[build_platform]
|
||||
|
||||
config_value = self.reader.get(
|
||||
f"manylinux-{build_platform}-image", ignore_empty=True
|
||||
@@ -505,7 +505,7 @@ class Options:
|
||||
manylinux_images[build_platform] = image
|
||||
|
||||
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")
|
||||
|
||||
@@ -591,7 +591,7 @@ def compute_options(
|
||||
|
||||
|
||||
@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.
|
||||
{ '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"
|
||||
all_pinned_docker_images = ConfigParser()
|
||||
all_pinned_docker_images.read(pinned_docker_images_file)
|
||||
return all_pinned_docker_images
|
||||
pinned_images_file = resources_dir / "pinned_docker_images.cfg"
|
||||
all_pinned_images = ConfigParser()
|
||||
all_pinned_images.read(pinned_images_file)
|
||||
return all_pinned_images
|
||||
|
||||
|
||||
def deprecated_selectors(name: str, selector: str, *, error: bool = False) -> None:
|
||||
|
||||
@@ -9,7 +9,7 @@ from pathlib import Path, PurePath, PurePosixPath
|
||||
import pytest
|
||||
import toml
|
||||
|
||||
from cibuildwheel.docker_container import DockerContainer
|
||||
from cibuildwheel.docker_container import OCIContainer
|
||||
from cibuildwheel.environment import EnvironmentAssignmentBash
|
||||
|
||||
# Test utilities
|
||||
@@ -42,30 +42,24 @@ def container_engine(request):
|
||||
|
||||
|
||||
def test_simple(container_engine):
|
||||
with DockerContainer(
|
||||
container_engine=container_engine, docker_image=DEFAULT_IMAGE
|
||||
) as container:
|
||||
with OCIContainer(engine=container_engine, image=DEFAULT_IMAGE) as container:
|
||||
assert container.call(["echo", "hello"], capture_output=True) == "hello\n"
|
||||
|
||||
|
||||
def test_no_lf(container_engine):
|
||||
with DockerContainer(
|
||||
container_engine=container_engine, docker_image=DEFAULT_IMAGE
|
||||
) as container:
|
||||
with OCIContainer(engine=container_engine, image=DEFAULT_IMAGE) as container:
|
||||
assert container.call(["printf", "hello"], capture_output=True) == "hello"
|
||||
|
||||
|
||||
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())
|
||||
with container:
|
||||
pass
|
||||
|
||||
|
||||
def test_environment(container_engine):
|
||||
with DockerContainer(
|
||||
container_engine=container_engine, docker_image=DEFAULT_IMAGE
|
||||
) as container:
|
||||
with OCIContainer(engine=container_engine, image=DEFAULT_IMAGE) as container:
|
||||
assert (
|
||||
container.call(
|
||||
["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):
|
||||
with DockerContainer(
|
||||
container_engine=container_engine,
|
||||
docker_image=DEFAULT_IMAGE,
|
||||
cwd="/cibuildwheel/working_directory",
|
||||
with OCIContainer(
|
||||
engine=container_engine, image=DEFAULT_IMAGE, cwd="/cibuildwheel/working_directory"
|
||||
) as container:
|
||||
assert container.call(["pwd"], capture_output=True) == "/cibuildwheel/working_directory\n"
|
||||
assert container.call(["pwd"], capture_output=True, cwd="/opt") == "/opt\n"
|
||||
|
||||
|
||||
def test_container_removed(container_engine):
|
||||
with DockerContainer(
|
||||
container_engine=container_engine, docker_image=DEFAULT_IMAGE
|
||||
) as container:
|
||||
with OCIContainer(engine=container_engine, image=DEFAULT_IMAGE) as container:
|
||||
docker_containers_listing = subprocess.run(
|
||||
f"{container.container_engine} container ls",
|
||||
f"{container.engine} container ls",
|
||||
shell=True,
|
||||
check=True,
|
||||
stdout=subprocess.PIPE,
|
||||
@@ -100,7 +90,7 @@ def test_container_removed(container_engine):
|
||||
old_container_name = container.name
|
||||
|
||||
docker_containers_listing = subprocess.run(
|
||||
f"{container.container_engine} container ls",
|
||||
f"{container.engine} container ls",
|
||||
shell=True,
|
||||
check=True,
|
||||
stdout=subprocess.PIPE,
|
||||
@@ -119,9 +109,7 @@ def test_large_environment(container_engine):
|
||||
"d": "0" * long_env_var_length,
|
||||
}
|
||||
|
||||
with DockerContainer(
|
||||
container_engine=container_engine, docker_image=DEFAULT_IMAGE
|
||||
) as container:
|
||||
with OCIContainer(engine=container_engine, image=DEFAULT_IMAGE) as container:
|
||||
# check the length of d
|
||||
assert (
|
||||
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):
|
||||
with DockerContainer(
|
||||
container_engine=container_engine, docker_image=DEFAULT_IMAGE
|
||||
) as container:
|
||||
with OCIContainer(engine=container_engine, image=DEFAULT_IMAGE) as container:
|
||||
# note: the below embedded snippets are in python2
|
||||
|
||||
# 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):
|
||||
with DockerContainer(
|
||||
container_engine=container_engine, docker_image=DEFAULT_IMAGE
|
||||
) as container:
|
||||
with OCIContainer(engine=container_engine, image=DEFAULT_IMAGE) as container:
|
||||
# test copying a file in
|
||||
test_binary_data = bytes(random.randrange(256) for _ in range(1000))
|
||||
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):
|
||||
with DockerContainer(
|
||||
container_engine=container_engine, docker_image=DEFAULT_IMAGE
|
||||
) as container:
|
||||
with OCIContainer(engine=container_engine, image=DEFAULT_IMAGE) as container:
|
||||
test_binary_data = bytes(random.randrange(256) for _ in range(1000))
|
||||
original_test_file = tmp_path / "test.dat"
|
||||
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):
|
||||
with DockerContainer(
|
||||
container_engine=container_engine, docker_image=DEFAULT_IMAGE
|
||||
) as container:
|
||||
with OCIContainer(engine=container_engine, image=DEFAULT_IMAGE) as container:
|
||||
assignment = EnvironmentAssignmentBash("TEST=$(echo 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_STORAGE_CONF", str(vfs_containers_storage_conf_fpath))
|
||||
|
||||
with DockerContainer(
|
||||
container_engine=container_engine, docker_image=DEFAULT_IMAGE
|
||||
) as container:
|
||||
with OCIContainer(engine=container_engine, image=DEFAULT_IMAGE) as container:
|
||||
# test running a command
|
||||
assert container.call(["echo", "hello"], capture_output=True) == "hello\n"
|
||||
|
||||
|
||||
@@ -21,16 +21,16 @@ def test_linux_container_split(tmp_path: Path, monkeypatch):
|
||||
textwrap.dedent(
|
||||
"""
|
||||
[tool.cibuildwheel]
|
||||
manylinux-x86_64-image = "normal_docker_image"
|
||||
manylinux-i686-image = "normal_docker_image"
|
||||
manylinux-x86_64-image = "normal_container_image"
|
||||
manylinux-i686-image = "normal_container_image"
|
||||
build = "*-manylinux_x86_64"
|
||||
skip = "pp*"
|
||||
archs = "x86_64 i686"
|
||||
|
||||
[[tool.cibuildwheel.overrides]]
|
||||
select = "cp{38,39,310}-*"
|
||||
manylinux-x86_64-image = "other_docker_image"
|
||||
manylinux-i686-image = "other_docker_image"
|
||||
manylinux-x86_64-image = "other_container_image"
|
||||
manylinux-i686-image = "other_container_image"
|
||||
|
||||
[[tool.cibuildwheel.overrides]]
|
||||
select = "cp39-*"
|
||||
@@ -57,14 +57,14 @@ def test_linux_container_split(tmp_path: Path, monkeypatch):
|
||||
|
||||
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 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 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 before_alls(build_steps[2]) == ["echo 'a cp39-only command'"]
|
||||
|
||||
@@ -11,7 +11,7 @@ else:
|
||||
|
||||
from cibuildwheel.__main__ import main
|
||||
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
|
||||
|
||||
# CIBW_PLATFORM is tested in main_platform_test.py
|
||||
@@ -339,6 +339,6 @@ def test_defaults(platform, intercepted_build_args):
|
||||
|
||||
if platform == "linux":
|
||||
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"]]
|
||||
assert build_options.manylinux_images["x86_64"] == default_x86_64_image
|
||||
|
||||
@@ -35,7 +35,7 @@ def mock_build_docker(monkeypatch):
|
||||
monkeypatch.setattr(subprocess, "Popen", fail_on_call)
|
||||
monkeypatch.setattr(subprocess, "run", ignore_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.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
|
||||
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 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}
|
||||
|
||||
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"]["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}
|
||||
|
||||
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 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]
|
||||
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"]["simulate_32_bit"]
|
||||
|
||||
@@ -118,7 +118,7 @@ before-all = "true"
|
||||
assert build_on_docker.call_count == 6
|
||||
|
||||
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 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"
|
||||
|
||||
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 not kwargs["docker"]["simulate_32_bit"]
|
||||
|
||||
@@ -138,7 +138,7 @@ before-all = "true"
|
||||
assert kwargs["options"].build_options("cp37-manylinux_x86_64").before_all == ""
|
||||
|
||||
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 not kwargs["docker"]["simulate_32_bit"]
|
||||
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]
|
||||
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"]["simulate_32_bit"]
|
||||
|
||||
@@ -158,7 +158,7 @@ before-all = "true"
|
||||
assert identifiers == {f"{x}-manylinux_i686" for x in ALL_IDS}
|
||||
|
||||
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 not kwargs["docker"]["simulate_32_bit"]
|
||||
|
||||
@@ -168,7 +168,7 @@ before-all = "true"
|
||||
}
|
||||
|
||||
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"]["simulate_32_bit"]
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import pytest
|
||||
|
||||
from cibuildwheel.__main__ import get_build_identifiers
|
||||
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
|
||||
|
||||
@@ -58,18 +58,18 @@ test_command: 'pyproject'
|
||||
|
||||
assert default_build_options.environment == parse_environment('FOO="BAR"')
|
||||
|
||||
all_pinned_docker_images = _get_pinned_docker_images()
|
||||
pinned_x86_64_docker_image = all_pinned_docker_images["x86_64"]
|
||||
all_pinned_container_images = _get_pinned_container_images()
|
||||
pinned_x86_64_container_image = all_pinned_container_images["x86_64"]
|
||||
|
||||
local = options.build_options("cp38-manylinux_x86_64")
|
||||
assert local.manylinux_images is not None
|
||||
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")
|
||||
assert local.manylinux_images is not None
|
||||
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):
|
||||
|
||||
Reference in New Issue
Block a user