From 98fedb7e5142c9d4f591c65dffb6b21a276fb67c Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 28 Apr 2022 09:19:27 -0400 Subject: [PATCH 01/86] refactor: use dataclasses vs. NamedTuples --- .pre-commit-config.yaml | 4 ++-- bin/update_docker.py | 5 +++-- bin/update_virtualenv.py | 5 +++-- cibuildwheel/__main__.py | 2 +- cibuildwheel/bashlex_eval.py | 6 ++++-- cibuildwheel/linux.py | 9 ++++++--- cibuildwheel/macos.py | 6 ++++-- cibuildwheel/options.py | 31 +++++++++++++------------------ cibuildwheel/util.py | 19 ++++++++++--------- cibuildwheel/windows.py | 6 ++++-- unit_test/utils.py | 20 ++++++++++---------- 11 files changed, 60 insertions(+), 53 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c64525ee..da8b94a2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -27,7 +27,7 @@ repos: # Autoremoves unused imports - repo: https://github.com/hadialqattan/pycln - rev: v1.3.1 + rev: v1.3.2 hooks: - id: pycln args: [--all] @@ -49,7 +49,7 @@ repos: - id: setup-cfg-fmt - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.942 + rev: v0.950 hooks: - id: mypy name: mypy 3.6 on cibuildwheel/ diff --git a/bin/update_docker.py b/bin/update_docker.py index 73da5a1b..105a3267 100755 --- a/bin/update_docker.py +++ b/bin/update_docker.py @@ -2,8 +2,8 @@ from __future__ import annotations import configparser +from dataclasses import dataclass from pathlib import Path -from typing import NamedTuple import requests @@ -11,7 +11,8 @@ DIR = Path(__file__).parent.resolve() RESOURCES = DIR.parent / "cibuildwheel/resources" -class Image(NamedTuple): +@dataclass(frozen=True) +class Image: manylinux_version: str platform: str image_name: str diff --git a/bin/update_virtualenv.py b/bin/update_virtualenv.py index 2e67007e..8dd9c5ef 100755 --- a/bin/update_virtualenv.py +++ b/bin/update_virtualenv.py @@ -6,8 +6,8 @@ import difflib import logging import subprocess import sys +from dataclasses import dataclass from pathlib import Path -from typing import NamedTuple import click import rich @@ -36,7 +36,8 @@ GET_VIRTUALENV_URL_TEMPLATE: Final[ ] = f"{GET_VIRTUALENV_GITHUB}/blob/{{version}}/public/virtualenv.pyz?raw=true" -class VersionTuple(NamedTuple): +@dataclass(frozen=True) +class VersionTuple: version: Version version_string: str diff --git a/cibuildwheel/__main__.py b/cibuildwheel/__main__.py index 306e73ab..9f24f000 100644 --- a/cibuildwheel/__main__.py +++ b/cibuildwheel/__main__.py @@ -107,7 +107,7 @@ def main() -> None: help="Enable pre-release Python versions if available.", ) - args = parser.parse_args(namespace=CommandLineArguments()) + args = CommandLineArguments(**vars(parser.parse_args())) if args.platform != "auto": platform = args.platform diff --git a/cibuildwheel/bashlex_eval.py b/cibuildwheel/bashlex_eval.py index 9eb5eac3..a8b4691c 100644 --- a/cibuildwheel/bashlex_eval.py +++ b/cibuildwheel/bashlex_eval.py @@ -1,5 +1,6 @@ import subprocess -from typing import Callable, Dict, List, NamedTuple, Optional, Sequence +from dataclasses import dataclass +from typing import Callable, Dict, List, Optional, Sequence import bashlex @@ -13,7 +14,8 @@ def local_environment_executor(command: List[str], env: Dict[str, str]) -> str: ).stdout -class NodeExecutionContext(NamedTuple): +@dataclass(frozen=True) +class NodeExecutionContext: environment: Dict[str, str] input: str executor: EnvironmentExecutor diff --git a/cibuildwheel/linux.py b/cibuildwheel/linux.py index 8478bf09..a1862d77 100644 --- a/cibuildwheel/linux.py +++ b/cibuildwheel/linux.py @@ -1,8 +1,9 @@ import subprocess import sys import textwrap +from dataclasses import dataclass from pathlib import Path, PurePath -from typing import Iterator, List, NamedTuple, Set, Tuple +from typing import Iterator, List, Set, Tuple from .architecture import Architecture from .docker_container import DockerContainer @@ -18,7 +19,8 @@ from .util import ( ) -class PythonConfiguration(NamedTuple): +@dataclass(frozen=True) +class PythonConfiguration: version: str identifier: str path_str: str @@ -28,7 +30,8 @@ class PythonConfiguration(NamedTuple): return PurePath(self.path_str) -class BuildStep(NamedTuple): +@dataclass(frozen=True) +class BuildStep: platform_configs: List[PythonConfiguration] platform_tag: str docker_image: str diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index d2770315..cf9adba1 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -5,8 +5,9 @@ import re import shutil import subprocess import sys +from dataclasses import dataclass from pathlib import Path -from typing import Dict, List, NamedTuple, Sequence, Set, Tuple, cast +from typing import Dict, List, Sequence, Set, Tuple, cast from filelock import FileLock @@ -53,7 +54,8 @@ def get_macos_sdks() -> List[str]: return [m.group(1) for m in re.finditer(r"-sdk (macosx\S+)", output)] -class PythonConfiguration(NamedTuple): +@dataclass(frozen=True) +class PythonConfiguration: version: str identifier: str url: str diff --git a/cibuildwheel/options.py b/cibuildwheel/options.py index ce4f5a77..0385fc3e 100644 --- a/cibuildwheel/options.py +++ b/cibuildwheel/options.py @@ -4,24 +4,15 @@ import sys import traceback from configparser import ConfigParser from contextlib import contextmanager +from dataclasses import asdict, dataclass from pathlib import Path -from typing import ( - Any, - Dict, - Iterator, - List, - Mapping, - NamedTuple, - Optional, - Set, - Tuple, - Union, -) +from typing import Any, Dict, Iterator, List, Mapping, Optional, Set, Tuple, Union if sys.version_info >= (3, 11): import tomllib else: import tomli as tomllib + from packaging.specifiers import SpecifierSet from .architecture import Architecture @@ -43,6 +34,7 @@ from .util import ( ) +@dataclass class CommandLineArguments: platform: Literal["auto", "linux", "macos", "windows"] archs: Optional[str] @@ -54,7 +46,8 @@ class CommandLineArguments: prerelease_pythons: bool -class GlobalOptions(NamedTuple): +@dataclass(frozen=True) +class GlobalOptions: package_dir: Path output_dir: Path build_selector: BuildSelector @@ -62,7 +55,8 @@ class GlobalOptions(NamedTuple): architectures: Set[Architecture] -class BuildOptions(NamedTuple): +@dataclass(frozen=True) +class BuildOptions: globals: GlobalOptions environment: ParsedEnvironment before_all: str @@ -102,7 +96,8 @@ class BuildOptions(NamedTuple): Setting = Union[Dict[str, str], List[str], str, int] -class Override(NamedTuple): +@dataclass(frozen=True) +class Override: select_pattern: str options: Dict[str, Setting] @@ -550,12 +545,12 @@ class Options: def summary(self, identifiers: List[str]) -> str: lines = [ f"{option_name}: {option_value!r}" - for option_name, option_value in sorted(self.globals._asdict().items()) + for option_name, option_value in sorted(asdict(self.globals).items()) ] build_option_defaults = self.build_options(identifier=None) - for option_name, default_value in sorted(build_option_defaults._asdict().items()): + for option_name, default_value in sorted(asdict(build_option_defaults).items()): if option_name == "globals": continue @@ -563,7 +558,7 @@ class Options: # if any identifiers have an overridden value, print that too for identifier in identifiers: - option_value = self.build_options(identifier=identifier)._asdict()[option_name] + option_value = getattr(self.build_options(identifier=identifier), option_name) if option_value != default_value: lines.append(f" {identifier}: {option_value!r}") diff --git a/cibuildwheel/util.py b/cibuildwheel/util.py index 5015d348..5ce85bf8 100644 --- a/cibuildwheel/util.py +++ b/cibuildwheel/util.py @@ -1,5 +1,4 @@ import contextlib -import dataclasses import fnmatch import itertools import os @@ -11,6 +10,7 @@ import sys import textwrap import time import urllib.request +from dataclasses import dataclass from enum import Enum from functools import lru_cache from pathlib import Path @@ -22,7 +22,6 @@ from typing import ( Iterable, Iterator, List, - NamedTuple, Optional, Sequence, TextIO, @@ -228,7 +227,7 @@ def selector_matches(patterns: str, string: str) -> bool: # Once we require Python 3.10+, we can add kw_only=True -@dataclasses.dataclass +@dataclass(frozen=True) class IdentifierSelector: """ This class holds a set of build/skip patterns. You call an instance with a @@ -266,14 +265,14 @@ class IdentifierSelector: return should_build and not should_skip -@dataclasses.dataclass +@dataclass(frozen=True) class BuildSelector(IdentifierSelector): pass # Note that requires-python is not needed for TestSelector, as you can't test # what you can't build. -@dataclasses.dataclass +@dataclass(frozen=True) class TestSelector(IdentifierSelector): build_config: str = "*" @@ -413,6 +412,12 @@ def unwrap(text: str) -> str: return re.sub(r"\s+", " ", text) +@dataclass(frozen=True) +class FileReport: + name: str + size: str + + @contextlib.contextmanager def print_new_wheels(msg: str, output_dir: Path) -> Iterator[None]: """ @@ -427,10 +432,6 @@ def print_new_wheels(msg: str, output_dir: Path) -> Iterator[None]: yield final_contents = set(output_dir.iterdir()) - class FileReport(NamedTuple): - name: str - size: str - new_contents = [ FileReport(wheel.name, f"{(wheel.stat().st_size + 1023) // 1024:,d}") for wheel in final_contents - existing_contents diff --git a/cibuildwheel/windows.py b/cibuildwheel/windows.py index 13b5c0c3..ef9742ee 100644 --- a/cibuildwheel/windows.py +++ b/cibuildwheel/windows.py @@ -2,9 +2,10 @@ import os import shutil import subprocess import sys +from dataclasses import dataclass from functools import lru_cache from pathlib import Path -from typing import Dict, List, NamedTuple, Optional, Sequence, Set +from typing import Dict, List, Optional, Sequence, Set from zipfile import ZipFile from filelock import FileLock @@ -45,7 +46,8 @@ def get_nuget_args(version: str, arch: str, output_directory: Path) -> List[str] ] -class PythonConfiguration(NamedTuple): +@dataclass(frozen=True) +class PythonConfiguration: version: str arch: str identifier: str diff --git a/unit_test/utils.py b/unit_test/utils.py index 61833fa2..32e9331f 100644 --- a/unit_test/utils.py +++ b/unit_test/utils.py @@ -2,15 +2,15 @@ from cibuildwheel.options import CommandLineArguments def get_default_command_line_arguments() -> CommandLineArguments: - defaults = CommandLineArguments() - - defaults.platform = "auto" - defaults.allow_empty = False - defaults.archs = None - defaults.config_file = "" - defaults.output_dir = None - defaults.package_dir = "." - defaults.prerelease_pythons = False - defaults.print_build_identifiers = False + defaults = CommandLineArguments( + platform="auto", + allow_empty=False, + archs=None, + config_file="", + output_dir=None, + package_dir=".", + prerelease_pythons=False, + print_build_identifiers=False, + ) return defaults From 9ab89f92c04fb9aa49ee096093e7098f05969951 Mon Sep 17 00:00:00 2001 From: Robert Martin Date: Tue, 24 May 2022 17:35:46 -0600 Subject: [PATCH 02/86] Fix Linux builds on Windows --- cibuildwheel/docker_container.py | 37 ++++++++++++++++++++++-------- cibuildwheel/linux.py | 18 +++++++-------- unit_test/docker_container_test.py | 4 ++-- unit_test/option_prepare_test.py | 22 +++++++++--------- 4 files changed, 49 insertions(+), 32 deletions(-) diff --git a/cibuildwheel/docker_container.py b/cibuildwheel/docker_container.py index 8ee8e573..583eb3d5 100644 --- a/cibuildwheel/docker_container.py +++ b/cibuildwheel/docker_container.py @@ -1,12 +1,12 @@ import io import json -import os import platform import shlex +import shutil import subprocess import sys import uuid -from pathlib import Path, PurePath +from pathlib import Path, PurePath, PurePosixPath from types import TracebackType from typing import IO, Dict, List, Optional, Sequence, Type, cast @@ -128,11 +128,28 @@ class DockerContainer: cwd=from_path, ) else: - subprocess.run( - f'cat {shell_quote(from_path)} | docker exec -i {self.name} sh -c "cat > {shell_quote(to_path)}"', - shell=True, - check=True, + docker = subprocess.Popen( + [ + "docker", + "exec", + "-i", + str(self.name), + "sh", + "-c", + f"cat > {shell_quote(to_path)}", + ], + stdin=subprocess.PIPE, ) + docker.stdin = cast(IO[bytes], docker.stdin) + + with open(from_path, "rb") as from_file: + shutil.copyfileobj(from_file, docker.stdin) + + docker.stdin.close() + docker.wait() + + if docker.returncode: + raise subprocess.CalledProcessError(docker.returncode, docker.args, None, None) def copy_out(self, from_path: PurePath, to_path: Path) -> None: # note: we assume from_path is a dir @@ -145,21 +162,21 @@ class DockerContainer: cwd=to_path, ) - def glob(self, path: PurePath, pattern: str) -> List[PurePath]: - glob_pattern = os.path.join(str(path), pattern) + def glob(self, path: PurePosixPath, pattern: str) -> List[PurePosixPath]: + glob_pattern = path.joinpath(pattern) path_strings = json.loads( self.call( [ self.UTILITY_PYTHON, "-c", - f"import sys, json, glob; json.dump(glob.glob({glob_pattern!r}), sys.stdout)", + f"import sys, json, glob; json.dump(glob.glob({str(glob_pattern)!r}), sys.stdout)", ], capture_output=True, ) ) - return [PurePath(p) for p in path_strings] + return [PurePosixPath(p) for p in path_strings] def call( self, diff --git a/cibuildwheel/linux.py b/cibuildwheel/linux.py index 036eb36f..93225c21 100644 --- a/cibuildwheel/linux.py +++ b/cibuildwheel/linux.py @@ -1,7 +1,7 @@ import subprocess import sys import textwrap -from pathlib import Path, PurePath +from pathlib import Path, PurePath, PurePosixPath from typing import Iterator, List, NamedTuple, Set, Tuple from .architecture import Architecture @@ -25,8 +25,8 @@ class PythonConfiguration(NamedTuple): path_str: str @property - def path(self) -> PurePath: - return PurePath(self.path_str) + def path(self) -> PurePosixPath: + return PurePosixPath(self.path_str) class BuildStep(NamedTuple): @@ -108,7 +108,7 @@ def build_on_docker( container_project_path: PurePath, container_package_dir: PurePath, ) -> None: - container_output_dir = PurePath("/output") + container_output_dir = PurePosixPath("/output") log.step("Copying project into Docker...") docker.copy_into(Path.cwd(), container_project_path) @@ -133,7 +133,7 @@ def build_on_docker( ) docker.call(["sh", "-c", before_all_prepared], env=env) - built_wheels: List[PurePath] = [] + built_wheels: List[PurePosixPath] = [] for config in platform_configs: log.build_start(config.identifier) @@ -162,7 +162,7 @@ def build_on_docker( # check config python is still on PATH which_python = docker.call(["which", "python"], env=env, capture_output=True).strip() - if PurePath(which_python) != python_bin / "python": + if PurePosixPath(which_python) != python_bin / "python": print( "cibuildwheel: python available on PATH doesn't match our installed instance. If you have modified PATH, ensure that you don't overwrite cibuildwheel's entry or insert python above it.", file=sys.stderr, @@ -170,7 +170,7 @@ def build_on_docker( sys.exit(1) which_pip = docker.call(["which", "pip"], env=env, capture_output=True).strip() - if PurePath(which_pip) != python_bin / "pip": + if PurePosixPath(which_pip) != python_bin / "pip": print( "cibuildwheel: pip available on PATH doesn't match our installed instance. If you have modified PATH, ensure that you don't overwrite cibuildwheel's entry or insert pip above it.", file=sys.stderr, @@ -197,7 +197,7 @@ def build_on_docker( log.step("Building wheel...") - temp_dir = PurePath("/tmp/cibuildwheel") + temp_dir = PurePosixPath("/tmp/cibuildwheel") built_wheel_dir = temp_dir / "built_wheel" docker.call(["rm", "-rf", built_wheel_dir]) docker.call(["mkdir", "-p", built_wheel_dir]) @@ -341,7 +341,7 @@ def build(options: Options, tmp_path: Path) -> None: # pylint: disable=unused-a if cwd != abs_package_dir and cwd not in abs_package_dir.parents: raise Exception("package_dir must be inside the working directory") - container_project_path = PurePath("/project") + container_project_path = PurePosixPath("/project") container_package_dir = container_project_path / abs_package_dir.relative_to(cwd) for build_step in get_build_steps(options, python_configurations): diff --git a/unit_test/docker_container_test.py b/unit_test/docker_container_test.py index 3b250ad3..e9c43e77 100644 --- a/unit_test/docker_container_test.py +++ b/unit_test/docker_container_test.py @@ -3,7 +3,7 @@ import random import shutil import subprocess import textwrap -from pathlib import Path, PurePath +from pathlib import Path, PurePath, PurePosixPath import pytest @@ -178,7 +178,7 @@ def test_dir_operations(tmp_path: Path): test_file = test_dir / "test.dat" shutil.copyfile(original_test_file, test_file) - dst_dir = PurePath("/tmp/test_dir") + dst_dir = PurePosixPath("/tmp/test_dir") dst_file = dst_dir / "test.dat" container.copy_into(test_dir, dst_dir) diff --git a/unit_test/option_prepare_test.py b/unit_test/option_prepare_test.py index 354cda4a..5f2fecfd 100644 --- a/unit_test/option_prepare_test.py +++ b/unit_test/option_prepare_test.py @@ -2,7 +2,7 @@ import platform as platform_module import subprocess import sys from contextlib import contextmanager -from pathlib import Path +from pathlib import PurePosixPath from typing import cast from unittest import mock @@ -53,7 +53,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 kwargs["docker"]["cwd"] == Path("/project") + assert kwargs["docker"]["cwd"] == PurePosixPath("/project") assert not kwargs["docker"]["simulate_32_bit"] identifiers = {x.identifier for x in kwargs["platform_configs"]} @@ -61,7 +61,7 @@ def test_build_default_launches(mock_build_docker, fake_package_dir, monkeypatch kwargs = build_on_docker.call_args_list[1][1] assert "quay.io/pypa/manylinux2014_i686" in kwargs["docker"]["docker_image"] - assert kwargs["docker"]["cwd"] == Path("/project") + assert kwargs["docker"]["cwd"] == PurePosixPath("/project") assert kwargs["docker"]["simulate_32_bit"] identifiers = {x.identifier for x in kwargs["platform_configs"]} @@ -69,7 +69,7 @@ def test_build_default_launches(mock_build_docker, fake_package_dir, monkeypatch kwargs = build_on_docker.call_args_list[2][1] assert "quay.io/pypa/musllinux_1_1_x86_64" in kwargs["docker"]["docker_image"] - assert kwargs["docker"]["cwd"] == Path("/project") + assert kwargs["docker"]["cwd"] == PurePosixPath("/project") assert not kwargs["docker"]["simulate_32_bit"] identifiers = {x.identifier for x in kwargs["platform_configs"]} @@ -79,7 +79,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 kwargs["docker"]["cwd"] == Path("/project") + assert kwargs["docker"]["cwd"] == PurePosixPath("/project") assert kwargs["docker"]["simulate_32_bit"] identifiers = {x.identifier for x in kwargs["platform_configs"]} @@ -119,7 +119,7 @@ before-all = "true" kwargs = build_on_docker.call_args_list[0][1] assert "quay.io/pypa/manylinux2014_x86_64" in kwargs["docker"]["docker_image"] - assert kwargs["docker"]["cwd"] == Path("/project") + assert kwargs["docker"]["cwd"] == PurePosixPath("/project") assert not kwargs["docker"]["simulate_32_bit"] identifiers = {x.identifier for x in kwargs["platform_configs"]} @@ -128,7 +128,7 @@ 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 kwargs["docker"]["cwd"] == Path("/project") + assert kwargs["docker"]["cwd"] == PurePosixPath("/project") assert not kwargs["docker"]["simulate_32_bit"] identifiers = {x.identifier for x in kwargs["platform_configs"]} @@ -139,7 +139,7 @@ before-all = "true" kwargs = build_on_docker.call_args_list[2][1] assert "quay.io/pypa/manylinux_2_24_x86_64" in kwargs["docker"]["docker_image"] - assert kwargs["docker"]["cwd"] == Path("/project") + assert kwargs["docker"]["cwd"] == PurePosixPath("/project") assert not kwargs["docker"]["simulate_32_bit"] identifiers = {x.identifier for x in kwargs["platform_configs"]} assert identifiers == { @@ -151,7 +151,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 kwargs["docker"]["cwd"] == Path("/project") + assert kwargs["docker"]["cwd"] == PurePosixPath("/project") assert kwargs["docker"]["simulate_32_bit"] identifiers = {x.identifier for x in kwargs["platform_configs"]} @@ -159,7 +159,7 @@ before-all = "true" kwargs = build_on_docker.call_args_list[4][1] assert "quay.io/pypa/musllinux_1_1_x86_64" in kwargs["docker"]["docker_image"] - assert kwargs["docker"]["cwd"] == Path("/project") + assert kwargs["docker"]["cwd"] == PurePosixPath("/project") assert not kwargs["docker"]["simulate_32_bit"] identifiers = {x.identifier for x in kwargs["platform_configs"]} @@ -169,7 +169,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 kwargs["docker"]["cwd"] == Path("/project") + assert kwargs["docker"]["cwd"] == PurePosixPath("/project") assert kwargs["docker"]["simulate_32_bit"] identifiers = {x.identifier for x in kwargs["platform_configs"]} From 5d439c0f3820bbd8bd997640bdf70bcbb6512294 Mon Sep 17 00:00:00 2001 From: Robert Martin Date: Wed, 25 May 2022 18:04:54 -0600 Subject: [PATCH 03/86] Fix a Pylint warning --- cibuildwheel/docker_container.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/cibuildwheel/docker_container.py b/cibuildwheel/docker_container.py index 583eb3d5..9dc3ab70 100644 --- a/cibuildwheel/docker_container.py +++ b/cibuildwheel/docker_container.py @@ -128,7 +128,7 @@ class DockerContainer: cwd=from_path, ) else: - docker = subprocess.Popen( + with subprocess.Popen( [ "docker", "exec", @@ -139,17 +139,17 @@ class DockerContainer: f"cat > {shell_quote(to_path)}", ], stdin=subprocess.PIPE, - ) - docker.stdin = cast(IO[bytes], docker.stdin) + ) as docker: + docker.stdin = cast(IO[bytes], docker.stdin) - with open(from_path, "rb") as from_file: - shutil.copyfileobj(from_file, docker.stdin) + with open(from_path, "rb") as from_file: + shutil.copyfileobj(from_file, docker.stdin) - docker.stdin.close() - docker.wait() + docker.stdin.close() + docker.wait() - if docker.returncode: - raise subprocess.CalledProcessError(docker.returncode, docker.args, None, None) + if docker.returncode: + raise subprocess.CalledProcessError(docker.returncode, docker.args, None, None) def copy_out(self, from_path: PurePath, to_path: Path) -> None: # note: we assume from_path is a dir From 526c5543e525eba2f55fb60da5e90dd6b5d308b9 Mon Sep 17 00:00:00 2001 From: David Lechner Date: Thu, 9 Jun 2022 12:21:42 -0500 Subject: [PATCH 04/86] fix overwriting wheel on macos When I run on macOS, I get the following error: ``` Traceback (most recent call last): File "/Users/david/.local/pipx/.cache/fd54e06d50697e7/bin/cibuildwheel", line 8, in sys.exit(main()) File "/Users/david/.local/pipx/.cache/fd54e06d50697e7/lib/python3.10/site-packages/cibuildwheel/__main__.py", line 128, in main build_in_directory(args) File "/Users/david/.local/pipx/.cache/fd54e06d50697e7/lib/python3.10/site-packages/cibuildwheel/__main__.py", line 252, in build_in_directory cibuildwheel.macos.build(options, tmp_path) File "/Users/david/.local/pipx/.cache/fd54e06d50697e7/lib/python3.10/site-packages/cibuildwheel/macos.py", line 538, in build shutil.move(str(repaired_wheel), build_options.output_dir) File "/opt/homebrew/Cellar/python@3.10/3.10.4/Frameworks/Python.framework/Versions/3.10/lib/python3.10/shutil.py", line 811, in move raise Error("Destination path '%s' already exists" % real_dst) shutil.Error: Destination path '/Users/david/Documents/GitHub/python-mpy-cross/wheelhouse/mpy_cross_v5-1.0.0-py3-none-macosx_11_0_arm64.whl' already exists ``` The comment in the code says that it should overwrite the file, so this removes the file if it exists first before trying to move the file. --- cibuildwheel/macos.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index 7100cd05..3ae2d204 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -535,6 +535,11 @@ def build(options: Options, tmp_path: Path) -> None: # we're all done here; move it to output (overwrite existing) if abi3_wheel is None: + try: + os.remove(build_options.output_dir / repaired_wheel.name) + except OSError: + pass + shutil.move(str(repaired_wheel), build_options.output_dir) built_wheels.append(build_options.output_dir / repaired_wheel.name) From e6513a9b281fbdb12c0c2b82b263f47c135af66e Mon Sep 17 00:00:00 2001 From: David Lechner Date: Thu, 16 Jun 2022 10:39:05 -0500 Subject: [PATCH 05/86] use Path.unlink() instead of os.unlink() --- cibuildwheel/macos.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index 3ae2d204..18ccb04b 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -536,7 +536,7 @@ def build(options: Options, tmp_path: Path) -> None: # we're all done here; move it to output (overwrite existing) if abi3_wheel is None: try: - os.remove(build_options.output_dir / repaired_wheel.name) + (build_options.output_dir / repaired_wheel.name).unlink() except OSError: pass From 9f4303ba2ccaf3f6ae7ed7593b5067b491f113af Mon Sep 17 00:00:00 2001 From: David Lechner Date: Thu, 16 Jun 2022 10:40:48 -0500 Subject: [PATCH 06/86] use FileNotFoundError instead of OSError --- cibuildwheel/macos.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index 18ccb04b..91ba3f8e 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -537,7 +537,7 @@ def build(options: Options, tmp_path: Path) -> None: if abi3_wheel is None: try: (build_options.output_dir / repaired_wheel.name).unlink() - except OSError: + except FileNotFoundError: pass shutil.move(str(repaired_wheel), build_options.output_dir) From 6458604c994f5dd2cb3f9a16565001414e504152 Mon Sep 17 00:00:00 2001 From: mayeut Date: Sun, 13 Feb 2022 16:57:35 +0100 Subject: [PATCH 07/86] feature: add manylinux_2_28 support --- bin/update_docker.py | 6 ++++ .../resources/pinned_docker_images.cfg | 5 ++++ docs/options.md | 6 ++-- test/test_manylinuxXXXX_only.py | 29 ++++++++++++++++--- unit_test/main_tests/main_options_test.py | 2 ++ 5 files changed, 41 insertions(+), 7 deletions(-) diff --git a/bin/update_docker.py b/bin/update_docker.py index 73da5a1b..32d98e75 100755 --- a/bin/update_docker.py +++ b/bin/update_docker.py @@ -45,6 +45,12 @@ images = [ Image("manylinux_2_24", "pypy_x86_64", "quay.io/pypa/manylinux_2_24_x86_64", None), Image("manylinux_2_24", "pypy_i686", "quay.io/pypa/manylinux_2_24_i686", None), Image("manylinux_2_24", "pypy_aarch64", "quay.io/pypa/manylinux_2_24_aarch64", None), + # manylinux_2_28 images + Image("manylinux_2_28", "x86_64", "quay.io/pypa/manylinux_2_28_x86_64", None), + Image("manylinux_2_28", "aarch64", "quay.io/pypa/manylinux_2_28_aarch64", None), + Image("manylinux_2_28", "ppc64le", "quay.io/pypa/manylinux_2_28_ppc64le", None), + Image("manylinux_2_28", "pypy_x86_64", "quay.io/pypa/manylinux_2_28_x86_64", None), + Image("manylinux_2_28", "pypy_aarch64", "quay.io/pypa/manylinux_2_28_aarch64", None), # musllinux_1_1 images Image("musllinux_1_1", "x86_64", "quay.io/pypa/musllinux_1_1_x86_64", None), Image("musllinux_1_1", "i686", "quay.io/pypa/musllinux_1_1_i686", None), diff --git a/cibuildwheel/resources/pinned_docker_images.cfg b/cibuildwheel/resources/pinned_docker_images.cfg index c4f81a5d..0a7c6592 100644 --- a/cibuildwheel/resources/pinned_docker_images.cfg +++ b/cibuildwheel/resources/pinned_docker_images.cfg @@ -3,6 +3,7 @@ manylinux1 = quay.io/pypa/manylinux1_x86_64:2022-06-12-a846b05 manylinux2010 = quay.io/pypa/manylinux2010_x86_64:2022-06-13-c365205 manylinux2014 = quay.io/pypa/manylinux2014_x86_64:2022-06-13-c365205 manylinux_2_24 = quay.io/pypa/manylinux_2_24_x86_64:2022-06-13-c365205 +manylinux_2_28 = quay.io/pypa/manylinux_2_28_x86_64:2022-06-13-c365205 musllinux_1_1 = quay.io/pypa/musllinux_1_1_x86_64:2022-06-13-c365205 [i686] @@ -16,6 +17,7 @@ musllinux_1_1 = quay.io/pypa/musllinux_1_1_i686:2022-06-13-c365205 manylinux2010 = quay.io/pypa/manylinux2010_x86_64:2022-06-13-c365205 manylinux2014 = quay.io/pypa/manylinux2014_x86_64:2022-06-13-c365205 manylinux_2_24 = quay.io/pypa/manylinux_2_24_x86_64:2022-06-13-c365205 +manylinux_2_28 = quay.io/pypa/manylinux_2_28_x86_64:2022-06-13-c365205 [pypy_i686] manylinux2010 = quay.io/pypa/manylinux2010_i686:2022-06-13-c365205 @@ -25,11 +27,13 @@ manylinux_2_24 = quay.io/pypa/manylinux_2_24_i686:2022-06-13-c365205 [aarch64] manylinux2014 = quay.io/pypa/manylinux2014_aarch64:2022-06-13-c365205 manylinux_2_24 = quay.io/pypa/manylinux_2_24_aarch64:2022-06-13-c365205 +manylinux_2_28 = quay.io/pypa/manylinux_2_28_aarch64:2022-06-13-c365205 musllinux_1_1 = quay.io/pypa/musllinux_1_1_aarch64:2022-06-13-c365205 [ppc64le] manylinux2014 = quay.io/pypa/manylinux2014_ppc64le:2022-06-13-c365205 manylinux_2_24 = quay.io/pypa/manylinux_2_24_ppc64le:2022-06-13-c365205 +manylinux_2_28 = quay.io/pypa/manylinux_2_28_ppc64le:2022-06-13-c365205 musllinux_1_1 = quay.io/pypa/musllinux_1_1_ppc64le:2022-06-13-c365205 [s390x] @@ -40,4 +44,5 @@ musllinux_1_1 = quay.io/pypa/musllinux_1_1_s390x:2022-06-13-c365205 [pypy_aarch64] manylinux2014 = quay.io/pypa/manylinux2014_aarch64:2022-06-13-c365205 manylinux_2_24 = quay.io/pypa/manylinux_2_24_aarch64:2022-06-13-c365205 +manylinux_2_28 = quay.io/pypa/manylinux_2_28_aarch64:2022-06-13-c365205 diff --git a/docs/options.md b/docs/options.md index eee6cd1c..f72b388a 100644 --- a/docs/options.md +++ b/docs/options.md @@ -886,14 +886,14 @@ The available options are (default value): Set an alternative Docker image to be used for building [manylinux / musllinux](https://github.com/pypa/manylinux) wheels. -For `CIBW_MANYLINUX_*_IMAGE`, the value of this option can either be set to `manylinux1`, `manylinux2010`, `manylinux2014` or `manylinux_2_24` to use a pinned version of the [official manylinux images](https://github.com/pypa/manylinux). Alternatively, set these options to any other valid Docker image name. For PyPy, the `manylinux1` image is not available. For architectures other -than x86 (x86\_64 and i686) `manylinux2014` or `manylinux_2_24` must be used, because the first version of the manylinux specification that supports additional architectures is `manylinux2014`. +For `CIBW_MANYLINUX_*_IMAGE`, the value of this option can either be set to `manylinux1`, `manylinux2010`, `manylinux2014`, `manylinux_2_24` or `manylinux_2_28` to use a pinned version of the [official manylinux images](https://github.com/pypa/manylinux). Alternatively, set these options to any other valid Docker image name. For PyPy, the `manylinux1` image is not available. For architectures other +than x86 (x86\_64 and i686) `manylinux2014`, `manylinux_2_24` or `manylinux_2_28` must be used, because the first version of the manylinux specification that supports additional architectures is `manylinux2014`. `manylinux_2_28` is not supported for `i686` & `s390x` architectures. For `CIBW_MUSLLINUX_*_IMAGE`, the value of this option can either be set to `musllinux_1_1` to use a pinned version of the [official musllinux images](https://github.com/pypa/musllinux). Alternatively, set these options to any other valid Docker image name. If this option is blank, it will fall though to the next available definition (environment variable -> pyproject.toml -> default). -If setting a custom Docker image, you'll need to make sure it can be used in the same way as the official, default Docker images: all necessary Python and pip versions need to be present in `/opt/python/`, and the auditwheel tool needs to be present for cibuildwheel to work. Apart from that, the architecture and relevant shared system libraries need to be compatible to the relevant standard to produce valid manylinux1/manylinux2010/manylinux2014/manylinux_2_24/musllinux_1_1 wheels (see [pypa/manylinux on GitHub](https://github.com/pypa/manylinux), [PEP 513](https://www.python.org/dev/peps/pep-0513/), [PEP 571](https://www.python.org/dev/peps/pep-0571/), [PEP 599](https://www.python.org/dev/peps/pep-0599/), [PEP 600](https://www.python.org/dev/peps/pep-0600/) and [PEP 656](https://www.python.org/dev/peps/pep-0656/) for more details). +If setting a custom Docker image, you'll need to make sure it can be used in the same way as the official, default Docker images: all necessary Python and pip versions need to be present in `/opt/python/`, and the auditwheel tool needs to be present for cibuildwheel to work. Apart from that, the architecture and relevant shared system libraries need to be compatible to the relevant standard to produce valid manylinux1/manylinux2010/manylinux2014/manylinux_2_24/manylinux_2_28/musllinux_1_1 wheels (see [pypa/manylinux on GitHub](https://github.com/pypa/manylinux), [PEP 513](https://www.python.org/dev/peps/pep-0513/), [PEP 571](https://www.python.org/dev/peps/pep-0571/), [PEP 599](https://www.python.org/dev/peps/pep-0599/), [PEP 600](https://www.python.org/dev/peps/pep-0600/) and [PEP 656](https://www.python.org/dev/peps/pep-0656/) for more details). Auditwheel detects the version of the manylinux / musllinux standard in the Docker image through the `AUDITWHEEL_PLAT` environment variable, as cibuildwheel has no way of detecting the correct `--plat` command line argument to pass to auditwheel for a custom image. If a Docker image does not correctly set this `AUDITWHEEL_PLAT` environment variable, the `CIBW_ENVIRONMENT` option can be used to do so (e.g., `CIBW_ENVIRONMENT='AUDITWHEEL_PLAT="manylinux2010_$(uname -m)"'`). diff --git a/test/test_manylinuxXXXX_only.py b/test/test_manylinuxXXXX_only.py index 1c75f9b1..2a80cbb3 100644 --- a/test/test_manylinuxXXXX_only.py +++ b/test/test_manylinuxXXXX_only.py @@ -21,17 +21,24 @@ project_with_manylinux_symbols = test_projects.new_c_project( #if !__GLIBC_PREREQ(2, 5) /* manylinux1 is glibc 2.5 */ #error "Must run on a glibc >= 2.5 linux environment" #endif + + #if __GLIBC_PREREQ(2, 28) + #include + #endif """ ), spam_c_function_add=textwrap.dedent( r""" - #if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 24) + #if __GLIBC_PREREQ(2, 28) + // thrd_equal & thrd_current are only available in manylinux_2_28+ + sts = thrd_equal(thrd_current(), thrd_current()) ? 0 : 1;; + #elif __GLIBC_PREREQ(2, 24) // nextupf is only available in manylinux_2_24+ sts = (int)nextupf(0.0F); - #elif defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 17) /* manylinux2014 is glibc 2.17 */ + #elif __GLIBC_PREREQ(2, 17) /* manylinux2014 is glibc 2.17 */ // secure_getenv is only available in manylinux2014+ sts = (int)(intptr_t)secure_getenv("NON_EXISTING_ENV_VARIABLE"); - #elif defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 10) /* manylinux2010 is glibc 2.12 */ + #elif __GLIBC_PREREQ(2, 10) /* manylinux2010 is glibc 2.12 */ // malloc_info is only available on manylinux2010+ sts = malloc_info(0, stdout); #endif @@ -41,7 +48,8 @@ project_with_manylinux_symbols = test_projects.new_c_project( @pytest.mark.parametrize( - "manylinux_image", ["manylinux1", "manylinux2010", "manylinux2014", "manylinux_2_24"] + "manylinux_image", + ["manylinux1", "manylinux2010", "manylinux2014", "manylinux_2_24", "manylinux_2_28"], ) def test(manylinux_image, tmp_path): if utils.platform != "linux": @@ -49,6 +57,10 @@ def test(manylinux_image, tmp_path): elif platform.machine() not in ["x86_64", "i686"]: if manylinux_image in ["manylinux1", "manylinux2010"]: pytest.skip("manylinux1 and 2010 doesn't exist for non-x86 architectures") + elif manylinux_image == "manylinux_2_28" and platform.machine() == "s390x": + pytest.skip("manylinux_2_28 doesn't exist for s390x architecture") + elif manylinux_image == "manylinux_2_28" and platform.machine() == "i686": + pytest.skip("manylinux_2_28 doesn't exist for i686 architecture") project_dir = tmp_path / "project" project_with_manylinux_symbols.generate(project_dir) @@ -74,6 +86,9 @@ def test(manylinux_image, tmp_path): if manylinux_image in {"manylinux2010"}: # We don't have a manylinux2010 image for PyPy 3.9, CPython 3.11 add_env["CIBW_SKIP"] = "pp39* cp311*" + if manylinux_image == "manylinux_2_28" and platform.machine() == "x86_64": + # We don't have a manylinux_2_28 image for i686 + add_env["CIBW_ARCHS"] = "x86_64" actual_wheels = utils.cibuildwheel_run(project_dir, add_env=add_env) @@ -91,7 +106,13 @@ def test(manylinux_image, tmp_path): if manylinux_image in {"manylinux1"}: # remove PyPy & CPython 3.10 and above expected_wheels = [w for w in expected_wheels if "-pp" not in w and "-cp31" not in w] + if manylinux_image in {"manylinux2010"}: # remove PyPy 3.9 & CPython 3.11 expected_wheels = [w for w in expected_wheels if "-pp39" not in w and "-cp311" not in w] + + if manylinux_image == "manylinux_2_28" and platform.machine() == "x86_64": + # We don't have a manylinux_2_28 image for i686 + expected_wheels = [w for w in expected_wheels if "i686" not in w] + assert set(actual_wheels) == set(expected_wheels) diff --git a/unit_test/main_tests/main_options_test.py b/unit_test/main_tests/main_options_test.py index 977fc378..27a97a2e 100644 --- a/unit_test/main_tests/main_options_test.py +++ b/unit_test/main_tests/main_options_test.py @@ -80,6 +80,7 @@ def test_empty_selector(platform, intercepted_build_args, monkeypatch): ("x86_64", "manylinux2010", "quay.io/pypa/manylinux2010_x86_64:*"), ("x86_64", "manylinux2014", "quay.io/pypa/manylinux2014_x86_64:*"), ("x86_64", "manylinux_2_24", "quay.io/pypa/manylinux_2_24_x86_64:*"), + ("x86_64", "manylinux_2_28", "quay.io/pypa/manylinux_2_28_x86_64:*"), ("x86_64", "custom_image", "custom_image"), ("i686", None, "quay.io/pypa/manylinux2014_i686:*"), ("i686", "manylinux1", "quay.io/pypa/manylinux1_i686:*"), @@ -92,6 +93,7 @@ def test_empty_selector(platform, intercepted_build_args, monkeypatch): ("pypy_x86_64", "manylinux2010", "quay.io/pypa/manylinux2010_x86_64:*"), ("pypy_x86_64", "manylinux2014", "quay.io/pypa/manylinux2014_x86_64:*"), ("pypy_x86_64", "manylinux_2_24", "quay.io/pypa/manylinux_2_24_x86_64:*"), + ("pypy_x86_64", "manylinux_2_28", "quay.io/pypa/manylinux_2_28_x86_64:*"), ("pypy_x86_64", "custom_image", "custom_image"), ], ) From cc56a140d2e514e2a46bdf6640b035917ee53b77 Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Fri, 17 Jun 2022 19:33:39 +0100 Subject: [PATCH 08/86] Bump version: v2.7.0 --- README.md | 18 ++++++++++-------- cibuildwheel/__init__.py | 2 +- docs/changelog.md | 9 +++++++++ docs/faq.md | 4 ++-- docs/setup.md | 4 ++-- examples/appveyor-minimal.yml | 2 +- examples/azure-pipelines-minimal.yml | 6 +++--- examples/circleci-minimal.yml | 4 ++-- examples/github-apple-silicon.yml | 2 +- examples/github-deploy.yml | 2 +- examples/github-minimal.yml | 2 +- examples/github-with-qemu.yml | 2 +- examples/gitlab-minimal.yml | 2 +- examples/travis-ci-deploy.yml | 2 +- examples/travis-ci-minimal.yml | 2 +- examples/travis-ci-test-and-deploy.yml | 4 ++-- setup.cfg | 2 +- 17 files changed, 40 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index e66a835e..165fa028 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,7 @@ jobs: - uses: actions/setup-python@v2 - name: Install cibuildwheel - run: python -m pip install cibuildwheel==2.6.1 + run: python -m pip install cibuildwheel==2.7.0 - name: Build wheels run: python -m cibuildwheel --output-dir wheelhouse @@ -203,6 +203,15 @@ Changelog +### v2.7.0 + +_17 June 2022_ + +- 🌟 Added support for the new `manylinux_2_28` images. These new images are based on AlmaLinux, the community-driven successor to CentOS, unlike manylinux_2_24, which was based on Debian. To build on these images, set your [`CIBW_MANYLINUX_*_IMAGE`](https://cibuildwheel.readthedocs.io/en/stable/options/#linux-image) option to `manylinux_2_28`. (#1026) +- 🐛 Fix a bug where tests were not being run on CPython 3.11 (when CIBW_PRERELEASE_PYTHONS was set) (#1138) +- ✨ You can now build Linux wheels on Windows, as long as you have Docker installed and set to 'Linux containers' (#1117) +- 🐛 Fix a bug on macOS that caused cibuildwheel to crash trying to overwrite a previously-built wheel of the same name. (#1129) + ### v2.6.1 _7 June 2022_ @@ -239,13 +248,6 @@ _2 April 2022_ - 🛠 Many other dependency updates. - 📚 Minor docs improvements -### v2.3.1 - -_14 December 2021_ - -- 🐛 Setting pip options like `PIP_USE_DEPRECATED` in `CIBW_ENVIRONMENT` no longer adversely affects cibuildwheel's ability to set up a Python environment (#956) -- 📚 Docs fixes and improvements - --- diff --git a/cibuildwheel/__init__.py b/cibuildwheel/__init__.py index fab833f3..2614ce9d 100644 --- a/cibuildwheel/__init__.py +++ b/cibuildwheel/__init__.py @@ -1 +1 @@ -__version__ = "2.6.1" +__version__ = "2.7.0" diff --git a/docs/changelog.md b/docs/changelog.md index 7f6f2101..29928223 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -2,6 +2,15 @@ title: Changelog --- +### v2.7.0 + +_17 June 2022_ + +- 🌟 Added support for the new `manylinux_2_28` images. These new images are based on AlmaLinux, the community-driven successor to CentOS, unlike manylinux_2_24, which was based on Debian. To build on these images, set your [`CIBW_MANYLINUX_*_IMAGE`](https://cibuildwheel.readthedocs.io/en/stable/options/#linux-image) option to `manylinux_2_28`. (#1026) +- 🐛 Fix a bug where tests were not being run on CPython 3.11 (when CIBW_PRERELEASE_PYTHONS was set) (#1138) +- ✨ You can now build Linux wheels on Windows, as long as you have Docker installed and set to 'Linux containers' (#1117) +- 🐛 Fix a bug on macOS that caused cibuildwheel to crash trying to overwrite a previously-built wheel of the same name. (#1129) + ### v2.6.1 _7 June 2022_ diff --git a/docs/faq.md b/docs/faq.md index 34a64e6e..66c05618 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -133,7 +133,7 @@ There are two suggested methods for keeping cibuildwheel up to date that instead If you use GitHub Actions for builds, you can use cibuildwheel as an action: ```yaml -uses: pypa/cibuildwheel@v2.6.1 +uses: pypa/cibuildwheel@v2.7.0 ``` This is a composite step that just runs cibuildwheel using pipx. You can set command-line options as `with:` parameters, and use `env:` as normal. @@ -159,7 +159,7 @@ The second option, and the only one that supports other CI systems, is using a ` ```bash # requirements-cibw.txt -cibuildwheel==2.6.1 +cibuildwheel==2.7.0 ``` Then your install step would have `python -m pip install -r requirements-cibw.txt` in it. Your `.github/dependabot.yml` file could look like this: diff --git a/docs/setup.md b/docs/setup.md index 3871425b..d6dc7c50 100644 --- a/docs/setup.md +++ b/docs/setup.md @@ -183,7 +183,7 @@ To build Linux, Mac, and Windows wheels using GitHub Actions, create a `.github/ - uses: actions/checkout@v2 - name: Build wheels - run: pipx run cibuildwheel==2.6.1 + run: pipx run cibuildwheel==2.7.0 - uses: actions/upload-artifact@v2 with: @@ -218,7 +218,7 @@ To build Linux, Mac, and Windows wheels using GitHub Actions, create a `.github/ - uses: actions/setup-python@v2 - name: Install cibuildwheel - run: python -m pip install cibuildwheel==2.6.1 + run: python -m pip install cibuildwheel==2.7.0 - name: Build wheels run: python -m cibuildwheel --output-dir wheelhouse diff --git a/examples/appveyor-minimal.yml b/examples/appveyor-minimal.yml index 50d5e51e..a943ac36 100644 --- a/examples/appveyor-minimal.yml +++ b/examples/appveyor-minimal.yml @@ -12,7 +12,7 @@ stack: python 3.7 init: - cmd: set PATH=C:\Python37;C:\Python37\Scripts;%PATH% -install: python -m pip install cibuildwheel==2.6.1 +install: python -m pip install cibuildwheel==2.7.0 build_script: python -m cibuildwheel --output-dir wheelhouse diff --git a/examples/azure-pipelines-minimal.yml b/examples/azure-pipelines-minimal.yml index 926c338a..4a275835 100644 --- a/examples/azure-pipelines-minimal.yml +++ b/examples/azure-pipelines-minimal.yml @@ -6,7 +6,7 @@ jobs: - bash: | set -o errexit python3 -m pip install --upgrade pip - pip3 install cibuildwheel==2.6.1 + pip3 install cibuildwheel==2.7.0 displayName: Install dependencies - bash: cibuildwheel --output-dir wheelhouse . displayName: Build wheels @@ -20,7 +20,7 @@ jobs: - bash: | set -o errexit python3 -m pip install --upgrade pip - python3 -m pip install cibuildwheel==2.6.1 + python3 -m pip install cibuildwheel==2.7.0 displayName: Install dependencies - bash: cibuildwheel --output-dir wheelhouse . displayName: Build wheels @@ -34,7 +34,7 @@ jobs: - bash: | set -o errexit python -m pip install --upgrade pip - pip install cibuildwheel==2.6.1 + pip install cibuildwheel==2.7.0 displayName: Install dependencies - bash: cibuildwheel --output-dir wheelhouse . displayName: Build wheels diff --git a/examples/circleci-minimal.yml b/examples/circleci-minimal.yml index 559367df..95eb1bcc 100644 --- a/examples/circleci-minimal.yml +++ b/examples/circleci-minimal.yml @@ -11,7 +11,7 @@ jobs: - run: name: Build the Linux wheels. command: | - pip3 install --user cibuildwheel==2.6.1 + pip3 install --user cibuildwheel==2.7.0 cibuildwheel --output-dir wheelhouse - store_artifacts: path: wheelhouse/ @@ -25,7 +25,7 @@ jobs: - run: name: Build the OS X wheels. command: | - pip3 install cibuildwheel==2.6.1 + pip3 install cibuildwheel==2.7.0 cibuildwheel --output-dir wheelhouse - store_artifacts: path: wheelhouse/ diff --git a/examples/github-apple-silicon.yml b/examples/github-apple-silicon.yml index b5d4e859..21416754 100644 --- a/examples/github-apple-silicon.yml +++ b/examples/github-apple-silicon.yml @@ -10,7 +10,7 @@ jobs: - uses: actions/checkout@v2 - name: Build wheels - uses: pypa/cibuildwheel@v2.6.1 + uses: pypa/cibuildwheel@v2.7.0 env: CIBW_ARCHS_MACOS: x86_64 universal2 diff --git a/examples/github-deploy.yml b/examples/github-deploy.yml index 8605cd41..024336f6 100644 --- a/examples/github-deploy.yml +++ b/examples/github-deploy.yml @@ -22,7 +22,7 @@ jobs: - uses: actions/checkout@v2 - name: Build wheels - uses: pypa/cibuildwheel@v2.6.1 + uses: pypa/cibuildwheel@v2.7.0 - uses: actions/upload-artifact@v2 with: diff --git a/examples/github-minimal.yml b/examples/github-minimal.yml index a12f5f02..ef57e242 100644 --- a/examples/github-minimal.yml +++ b/examples/github-minimal.yml @@ -14,7 +14,7 @@ jobs: - uses: actions/checkout@v2 - name: Build wheels - uses: pypa/cibuildwheel@v2.6.1 + uses: pypa/cibuildwheel@v2.7.0 # to supply options, put them in 'env', like: # env: # CIBW_SOME_OPTION: value diff --git a/examples/github-with-qemu.yml b/examples/github-with-qemu.yml index 54ecc3e8..585ffc0a 100644 --- a/examples/github-with-qemu.yml +++ b/examples/github-with-qemu.yml @@ -25,7 +25,7 @@ jobs: platforms: all - name: Build wheels - uses: pypa/cibuildwheel@v2.6.1 + uses: pypa/cibuildwheel@v2.7.0 env: # configure cibuildwheel to build native archs ('auto'), and some # emulated ones diff --git a/examples/gitlab-minimal.yml b/examples/gitlab-minimal.yml index f3969944..1a3d3b6b 100644 --- a/examples/gitlab-minimal.yml +++ b/examples/gitlab-minimal.yml @@ -12,7 +12,7 @@ linux: DOCKER_TLS_CERTDIR: "" script: - curl -sSL https://get.docker.com/ | sh - - python -m pip install cibuildwheel==2.6.1 + - python -m pip install cibuildwheel==2.7.0 - cibuildwheel --output-dir wheelhouse artifacts: paths: diff --git a/examples/travis-ci-deploy.yml b/examples/travis-ci-deploy.yml index faae9dc2..9ad49bc6 100644 --- a/examples/travis-ci-deploy.yml +++ b/examples/travis-ci-deploy.yml @@ -19,7 +19,7 @@ jobs: - ln -s /c/Python38/python.exe /c/Python38/python3.exe install: - - python3 -m pip install cibuildwheel==2.6.1 + - python3 -m pip install cibuildwheel==2.7.0 script: # build the wheels, put them into './dist' diff --git a/examples/travis-ci-minimal.yml b/examples/travis-ci-minimal.yml index 5fc1fc16..4ff2971f 100644 --- a/examples/travis-ci-minimal.yml +++ b/examples/travis-ci-minimal.yml @@ -25,7 +25,7 @@ jobs: - ln -s /c/Python38/python.exe /c/Python38/python3.exe install: - - python3 -m pip install cibuildwheel==2.6.1 + - python3 -m pip install cibuildwheel==2.7.0 script: # build the wheels, put them into './wheelhouse' diff --git a/examples/travis-ci-test-and-deploy.yml b/examples/travis-ci-test-and-deploy.yml index 310df31a..db739623 100644 --- a/examples/travis-ci-test-and-deploy.yml +++ b/examples/travis-ci-test-and-deploy.yml @@ -55,7 +55,7 @@ jobs: - stage: deploy name: Build and deploy Linux wheels services: docker - install: python3 -m pip install cibuildwheel==2.6.1 twine + install: python3 -m pip install cibuildwheel==2.7.0 twine script: python3 -m cibuildwheel --output-dir wheelhouse after_success: python3 -m twine upload --skip-existing wheelhouse/*.whl # Deploy on windows @@ -63,7 +63,7 @@ jobs: name: Build and deploy Windows wheels os: windows language: shell - install: python3 -m pip install cibuildwheel==2.6.1 twine + install: python3 -m pip install cibuildwheel==2.7.0 twine script: python3 -m cibuildwheel --output-dir wheelhouse after_success: python3 -m twine upload --skip-existing wheelhouse/*.whl diff --git a/setup.cfg b/setup.cfg index cd162b98..4f91bf92 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = cibuildwheel -version = 2.6.1 +version = 2.7.0 description = Build Python wheels on CI with minimal configuration. long_description = file: README.md long_description_content_type = text/markdown From 52945e1668857066912df9ea209e8a7d9cb0b8b9 Mon Sep 17 00:00:00 2001 From: Anatoli Babenia Date: Sat, 18 Jun 2022 14:11:42 +0300 Subject: [PATCH 09/86] Update to latest GitHub Action versions checkout@v2 -> v3 upload/download-artifact@v2 -> v3 python-setup@v2 -> v3 pypa/gh-action-pypi-publish@1.4.2 -> v1.5.0 Python latest is v4, but it breaks working with default Python version https://github.com/actions/setup-python/issues/421 --- README.md | 6 +++--- docs/deliver-to-pypi.md | 8 ++++---- docs/setup.md | 10 +++++----- examples/github-apple-silicon.yml | 4 ++-- examples/github-deploy.yml | 12 ++++++------ examples/github-minimal.yml | 4 ++-- examples/github-with-qemu.yml | 6 +++--- 7 files changed, 25 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 165fa028..74f2adf4 100644 --- a/README.md +++ b/README.md @@ -83,10 +83,10 @@ jobs: os: [ubuntu-20.04, windows-2019, macOS-10.15] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 # Used to host cibuildwheel - - uses: actions/setup-python@v2 + - uses: actions/setup-python@v3 - name: Install cibuildwheel run: python -m pip install cibuildwheel==2.7.0 @@ -97,7 +97,7 @@ jobs: # env: # CIBW_SOME_OPTION: value - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v3 with: path: ./wheelhouse/*.whl ``` diff --git a/docs/deliver-to-pypi.md b/docs/deliver-to-pypi.md index 610fe6e5..a81abb4e 100644 --- a/docs/deliver-to-pypi.md +++ b/docs/deliver-to-pypi.md @@ -46,7 +46,7 @@ well as several useful actions. Alongside your existing job(s) that runs cibuild name: Make SDist runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: fetch-depth: 0 # Optional, use if you use setuptools_scm submodules: true # Optional, use if you have submodules @@ -54,7 +54,7 @@ well as several useful actions. Alongside your existing job(s) that runs cibuild - name: Build SDist run: pipx run build --sdist - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v3 with: path: dist/*.tar.gz ``` @@ -69,12 +69,12 @@ This requires a [PyPI upload token](https://pypi.org/manage/account/token/), sto runs-on: ubuntu-latest if: github.event_name == 'release' && github.event.action == 'published' steps: - - uses: actions/download-artifact@v2 + - uses: actions/download-artifact@v3 with: name: artifact path: dist - - uses: pypa/gh-action-pypi-publish@v1.4.2 + - uses: pypa/gh-action-pypi-publish@v1.5.0 with: user: __token__ password: ${{ secrets.pypi_password }} diff --git a/docs/setup.md b/docs/setup.md index d6dc7c50..14070f38 100644 --- a/docs/setup.md +++ b/docs/setup.md @@ -180,12 +180,12 @@ To build Linux, Mac, and Windows wheels using GitHub Actions, create a `.github/ os: [ubuntu-20.04, windows-2019, macos-10.15] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Build wheels run: pipx run cibuildwheel==2.7.0 - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v3 with: path: ./wheelhouse/*.whl ``` @@ -212,10 +212,10 @@ To build Linux, Mac, and Windows wheels using GitHub Actions, create a `.github/ os: [ubuntu-20.04, windows-2019, macos-10.15] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 # Used to host cibuildwheel - - uses: actions/setup-python@v2 + - uses: actions/setup-python@v3 - name: Install cibuildwheel run: python -m pip install cibuildwheel==2.7.0 @@ -223,7 +223,7 @@ To build Linux, Mac, and Windows wheels using GitHub Actions, create a `.github/ - name: Build wheels run: python -m cibuildwheel --output-dir wheelhouse - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v3 with: path: ./wheelhouse/*.whl ``` diff --git a/examples/github-apple-silicon.yml b/examples/github-apple-silicon.yml index 21416754..dd695220 100644 --- a/examples/github-apple-silicon.yml +++ b/examples/github-apple-silicon.yml @@ -7,13 +7,13 @@ jobs: name: Build wheels on macos-10.15 runs-on: macos-10.15 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Build wheels uses: pypa/cibuildwheel@v2.7.0 env: CIBW_ARCHS_MACOS: x86_64 universal2 - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v3 with: path: ./wheelhouse/*.whl diff --git a/examples/github-deploy.yml b/examples/github-deploy.yml index 024336f6..e5929fc9 100644 --- a/examples/github-deploy.yml +++ b/examples/github-deploy.yml @@ -19,12 +19,12 @@ jobs: os: [ubuntu-20.04, windows-2019, macos-10.15] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Build wheels uses: pypa/cibuildwheel@v2.7.0 - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v3 with: path: ./wheelhouse/*.whl @@ -32,12 +32,12 @@ jobs: name: Build source distribution runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Build sdist run: pipx run build --sdist - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v3 with: path: dist/*.tar.gz @@ -49,12 +49,12 @@ jobs: # alternatively, to publish when a GitHub Release is created, use the following rule: # if: github.event_name == 'release' && github.event.action == 'published' steps: - - uses: actions/download-artifact@v2 + - uses: actions/download-artifact@v3 with: name: artifact path: dist - - uses: pypa/gh-action-pypi-publish@v1.4.2 + - uses: pypa/gh-action-pypi-publish@v1.5.0 with: user: __token__ password: ${{ secrets.pypi_password }} diff --git a/examples/github-minimal.yml b/examples/github-minimal.yml index ef57e242..fae40fc9 100644 --- a/examples/github-minimal.yml +++ b/examples/github-minimal.yml @@ -11,7 +11,7 @@ jobs: os: [ubuntu-20.04, windows-2019, macos-10.15] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Build wheels uses: pypa/cibuildwheel@v2.7.0 @@ -19,6 +19,6 @@ jobs: # env: # CIBW_SOME_OPTION: value - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v3 with: path: ./wheelhouse/*.whl diff --git a/examples/github-with-qemu.yml b/examples/github-with-qemu.yml index 585ffc0a..38fe7248 100644 --- a/examples/github-with-qemu.yml +++ b/examples/github-with-qemu.yml @@ -11,9 +11,9 @@ jobs: os: [ubuntu-20.04, windows-2019, macos-10.15] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - - uses: actions/setup-python@v2 + - uses: actions/setup-python@v3 name: Install Python with: python-version: '3.7' @@ -31,6 +31,6 @@ jobs: # emulated ones CIBW_ARCHS_LINUX: auto aarch64 ppc64le s390x - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v3 with: path: ./wheelhouse/*.whl From 6994d9be4f1ab8837ec4369c2f1d1fb2244b3ef6 Mon Sep 17 00:00:00 2001 From: Anatoli Babenia Date: Mon, 13 Jun 2022 20:25:55 +0300 Subject: [PATCH 10/86] Document `config-file`, and add `with:` into example https://github.com/pypa/cibuildwheel/blob/main/action.yml --- docs/setup.md | 7 +++---- examples/github-minimal.yml | 6 +++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/setup.md b/docs/setup.md index 14070f38..5af62a5f 100644 --- a/docs/setup.md +++ b/docs/setup.md @@ -154,10 +154,9 @@ To build Linux, Mac, and Windows wheels using GitHub Actions, create a `.github/ {% include "../examples/github-minimal.yml" %} ``` - - You can use `env:` with the action just like you would with `run:`; you can - also use `with:` to set the command line options: `package-dir: .` and - `output-dir: wheelhouse` (those values are the defaults). + Use `env:` to pass [build options](options.md) and `with:` to set + `package-dir: .`, `output-dir: wheelhouse` and `config-file: ''` + locations (those values are the defaults). !!! tab "pipx" The GitHub Actions runners have pipx installed, so you can easily build in diff --git a/examples/github-minimal.yml b/examples/github-minimal.yml index fae40fc9..a4c4a13b 100644 --- a/examples/github-minimal.yml +++ b/examples/github-minimal.yml @@ -15,9 +15,13 @@ jobs: - name: Build wheels uses: pypa/cibuildwheel@v2.7.0 - # to supply options, put them in 'env', like: # env: # CIBW_SOME_OPTION: value + # ... + # with: + # package-dir: . + # output-dir: wheelhouse + # config-file: {package}/pyproject.toml - uses: actions/upload-artifact@v3 with: From c4bfbe2ef1e6f39f1f575d6b573e96998b5d687b Mon Sep 17 00:00:00 2001 From: Anatoli Babenia Date: Sat, 18 Jun 2022 15:39:13 +0300 Subject: [PATCH 11/86] Clarify download action and why `name: artifact` is required https://github.com/pypa/cibuildwheel/pull/1135#pullrequestreview-1007698747 --- examples/github-deploy.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/github-deploy.yml b/examples/github-deploy.yml index e5929fc9..df2e846c 100644 --- a/examples/github-deploy.yml +++ b/examples/github-deploy.yml @@ -51,6 +51,8 @@ jobs: steps: - uses: actions/download-artifact@v3 with: + # unpacks default artifact into dist/ + # if `name: artifact` is omitted, the action will create extra parent dir name: artifact path: dist From 8afef342830d34f12f4380dc1f748922c6bc0131 Mon Sep 17 00:00:00 2001 From: Anatoli Babenia Date: Sun, 19 Jun 2022 07:15:36 +0300 Subject: [PATCH 12/86] Clear up that BEFORE_ALL runs outside of Python env --- docs/options.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/options.md b/docs/options.md index f72b388a..d3b4c107 100644 --- a/docs/options.md +++ b/docs/options.md @@ -635,7 +635,7 @@ To specify more than one environment variable, separate the variable names by sp ### `CIBW_BEFORE_ALL` {: #before-all} > Execute a shell command on the build system before any wheels are built. -Shell command to prepare a common part of the project (e.g. build or install libraries which does not depend on the specific version of Python). +Shell command that runs before creating Python environment, to build or install parts that do not depend on the specific version of Python. This option is very useful for the Linux build, where builds take place in isolated Docker containers managed by cibuildwheel. This command will run inside the container before the wheel builds start. Note, if you're building both `x86_64` and `i686` wheels (the default), your build uses two different Docker images. In that case, this command will execute twice - once per build container. From c3750edebb7e37a73571088cd93ff6032348863f Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Sun, 19 Jun 2022 10:45:07 +0100 Subject: [PATCH 13/86] Document use of pip options through environment variables --- docs/options.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/options.md b/docs/options.md index f72b388a..3f12ed8e 100644 --- a/docs/options.md +++ b/docs/options.md @@ -553,6 +553,10 @@ Platform-specific environment variables are also available:
# Supply options to `pip` to affect how it downloads dependencies CIBW_ENVIRONMENT: PIP_EXTRA_INDEX_URL=https://pypi.myorg.com/simple + # Any pip command-line options can be set using the PIP_ prefix + # https://pip.pypa.io/en/stable/topics/configuration/#environment-variables + CIBW_ENVIRONMENT: PIP_GLOBAL_OPTION="build_ext -j4" + # Set two flags on linux only CIBW_ENVIRONMENT_LINUX: BUILD_TIME="$(date)" SAMPLE_TEXT="sample text" ``` @@ -582,6 +586,10 @@ Platform-specific environment variables are also available:
# Supply options to `pip` to affect how it downloads dependencies environment = { PIP_EXTRA_INDEX_URL="https://pypi.myorg.com/simple" } + # Any pip command-line option can be set using the PIP_ prefix + # https://pip.pypa.io/en/stable/topics/configuration/#environment-variables + environment = { PIP_GLOBAL_OPTION="build_ext -j4" } + # Set two flags on linux only [tool.cibuildwheel.linux] environment = { BUILD_TIME="$(date)", SAMPLE_TEXT="sample text" } From 68aef79a9b67e546f8770e3aad5f147918af7129 Mon Sep 17 00:00:00 2001 From: "cibuildwheel-bot[bot]" <83877280+cibuildwheel-bot[bot]@users.noreply.github.com> Date: Mon, 20 Jun 2022 06:59:44 +0000 Subject: [PATCH 14/86] Update dependencies --- .../resources/constraints-python310.txt | 2 +- .../resources/constraints-python311.txt | 2 +- .../resources/constraints-python37.txt | 2 +- .../resources/constraints-python38.txt | 2 +- .../resources/constraints-python39.txt | 2 +- cibuildwheel/resources/constraints.txt | 2 +- .../resources/pinned_docker_images.cfg | 64 +++--- docs/working-examples.md | 206 +++++++++--------- 8 files changed, 141 insertions(+), 141 deletions(-) diff --git a/cibuildwheel/resources/constraints-python310.txt b/cibuildwheel/resources/constraints-python310.txt index 9c96aa12..86e4bdf0 100644 --- a/cibuildwheel/resources/constraints-python310.txt +++ b/cibuildwheel/resources/constraints-python310.txt @@ -26,5 +26,5 @@ wheel==0.37.1 # The following packages are considered to be unsafe in a requirements file: pip==22.1.2 # via -r cibuildwheel/resources/constraints.in -setuptools==62.4.0 +setuptools==62.6.0 # via -r cibuildwheel/resources/constraints.in diff --git a/cibuildwheel/resources/constraints-python311.txt b/cibuildwheel/resources/constraints-python311.txt index 82e6c46d..beaa5107 100644 --- a/cibuildwheel/resources/constraints-python311.txt +++ b/cibuildwheel/resources/constraints-python311.txt @@ -26,5 +26,5 @@ wheel==0.37.1 # The following packages are considered to be unsafe in a requirements file: pip==22.1.2 # via -r cibuildwheel/resources/constraints.in -setuptools==62.4.0 +setuptools==62.6.0 # via -r cibuildwheel/resources/constraints.in diff --git a/cibuildwheel/resources/constraints-python37.txt b/cibuildwheel/resources/constraints-python37.txt index e0a25472..25a3a1d6 100644 --- a/cibuildwheel/resources/constraints-python37.txt +++ b/cibuildwheel/resources/constraints-python37.txt @@ -32,5 +32,5 @@ zipp==3.8.0 # The following packages are considered to be unsafe in a requirements file: pip==22.1.2 # via -r cibuildwheel/resources/constraints.in -setuptools==62.4.0 +setuptools==62.6.0 # via -r cibuildwheel/resources/constraints.in diff --git a/cibuildwheel/resources/constraints-python38.txt b/cibuildwheel/resources/constraints-python38.txt index 971a8e42..a9e3d2c5 100644 --- a/cibuildwheel/resources/constraints-python38.txt +++ b/cibuildwheel/resources/constraints-python38.txt @@ -26,5 +26,5 @@ wheel==0.37.1 # The following packages are considered to be unsafe in a requirements file: pip==22.1.2 # via -r cibuildwheel/resources/constraints.in -setuptools==62.4.0 +setuptools==62.6.0 # via -r cibuildwheel/resources/constraints.in diff --git a/cibuildwheel/resources/constraints-python39.txt b/cibuildwheel/resources/constraints-python39.txt index 8f6d1c00..e5134e9f 100644 --- a/cibuildwheel/resources/constraints-python39.txt +++ b/cibuildwheel/resources/constraints-python39.txt @@ -26,5 +26,5 @@ wheel==0.37.1 # The following packages are considered to be unsafe in a requirements file: pip==22.1.2 # via -r cibuildwheel/resources/constraints.in -setuptools==62.4.0 +setuptools==62.6.0 # via -r cibuildwheel/resources/constraints.in diff --git a/cibuildwheel/resources/constraints.txt b/cibuildwheel/resources/constraints.txt index 8f6d1c00..e5134e9f 100644 --- a/cibuildwheel/resources/constraints.txt +++ b/cibuildwheel/resources/constraints.txt @@ -26,5 +26,5 @@ wheel==0.37.1 # The following packages are considered to be unsafe in a requirements file: pip==22.1.2 # via -r cibuildwheel/resources/constraints.in -setuptools==62.4.0 +setuptools==62.6.0 # via -r cibuildwheel/resources/constraints.in diff --git a/cibuildwheel/resources/pinned_docker_images.cfg b/cibuildwheel/resources/pinned_docker_images.cfg index 0a7c6592..ecb061c4 100644 --- a/cibuildwheel/resources/pinned_docker_images.cfg +++ b/cibuildwheel/resources/pinned_docker_images.cfg @@ -1,48 +1,48 @@ [x86_64] -manylinux1 = quay.io/pypa/manylinux1_x86_64:2022-06-12-a846b05 -manylinux2010 = quay.io/pypa/manylinux2010_x86_64:2022-06-13-c365205 -manylinux2014 = quay.io/pypa/manylinux2014_x86_64:2022-06-13-c365205 -manylinux_2_24 = quay.io/pypa/manylinux_2_24_x86_64:2022-06-13-c365205 -manylinux_2_28 = quay.io/pypa/manylinux_2_28_x86_64:2022-06-13-c365205 -musllinux_1_1 = quay.io/pypa/musllinux_1_1_x86_64:2022-06-13-c365205 +manylinux1 = quay.io/pypa/manylinux1_x86_64:2022-06-19-48acfad +manylinux2010 = quay.io/pypa/manylinux2010_x86_64:2022-06-20-d72b943 +manylinux2014 = quay.io/pypa/manylinux2014_x86_64:2022-06-20-d72b943 +manylinux_2_24 = quay.io/pypa/manylinux_2_24_x86_64:2022-06-20-d72b943 +manylinux_2_28 = quay.io/pypa/manylinux_2_28_x86_64:2022-06-20-d72b943 +musllinux_1_1 = quay.io/pypa/musllinux_1_1_x86_64:2022-06-20-d72b943 [i686] -manylinux1 = quay.io/pypa/manylinux1_i686:2022-06-12-a846b05 -manylinux2010 = quay.io/pypa/manylinux2010_i686:2022-06-13-c365205 -manylinux2014 = quay.io/pypa/manylinux2014_i686:2022-06-13-c365205 -manylinux_2_24 = quay.io/pypa/manylinux_2_24_i686:2022-06-13-c365205 -musllinux_1_1 = quay.io/pypa/musllinux_1_1_i686:2022-06-13-c365205 +manylinux1 = quay.io/pypa/manylinux1_i686:2022-06-19-48acfad +manylinux2010 = quay.io/pypa/manylinux2010_i686:2022-06-20-d72b943 +manylinux2014 = quay.io/pypa/manylinux2014_i686:2022-06-20-d72b943 +manylinux_2_24 = quay.io/pypa/manylinux_2_24_i686:2022-06-20-d72b943 +musllinux_1_1 = quay.io/pypa/musllinux_1_1_i686:2022-06-20-d72b943 [pypy_x86_64] -manylinux2010 = quay.io/pypa/manylinux2010_x86_64:2022-06-13-c365205 -manylinux2014 = quay.io/pypa/manylinux2014_x86_64:2022-06-13-c365205 -manylinux_2_24 = quay.io/pypa/manylinux_2_24_x86_64:2022-06-13-c365205 -manylinux_2_28 = quay.io/pypa/manylinux_2_28_x86_64:2022-06-13-c365205 +manylinux2010 = quay.io/pypa/manylinux2010_x86_64:2022-06-20-d72b943 +manylinux2014 = quay.io/pypa/manylinux2014_x86_64:2022-06-20-d72b943 +manylinux_2_24 = quay.io/pypa/manylinux_2_24_x86_64:2022-06-20-d72b943 +manylinux_2_28 = quay.io/pypa/manylinux_2_28_x86_64:2022-06-20-d72b943 [pypy_i686] -manylinux2010 = quay.io/pypa/manylinux2010_i686:2022-06-13-c365205 -manylinux2014 = quay.io/pypa/manylinux2014_i686:2022-06-13-c365205 -manylinux_2_24 = quay.io/pypa/manylinux_2_24_i686:2022-06-13-c365205 +manylinux2010 = quay.io/pypa/manylinux2010_i686:2022-06-20-d72b943 +manylinux2014 = quay.io/pypa/manylinux2014_i686:2022-06-20-d72b943 +manylinux_2_24 = quay.io/pypa/manylinux_2_24_i686:2022-06-20-d72b943 [aarch64] -manylinux2014 = quay.io/pypa/manylinux2014_aarch64:2022-06-13-c365205 -manylinux_2_24 = quay.io/pypa/manylinux_2_24_aarch64:2022-06-13-c365205 -manylinux_2_28 = quay.io/pypa/manylinux_2_28_aarch64:2022-06-13-c365205 -musllinux_1_1 = quay.io/pypa/musllinux_1_1_aarch64:2022-06-13-c365205 +manylinux2014 = quay.io/pypa/manylinux2014_aarch64:2022-06-20-d72b943 +manylinux_2_24 = quay.io/pypa/manylinux_2_24_aarch64:2022-06-20-d72b943 +manylinux_2_28 = quay.io/pypa/manylinux_2_28_aarch64:2022-06-20-d72b943 +musllinux_1_1 = quay.io/pypa/musllinux_1_1_aarch64:2022-06-20-d72b943 [ppc64le] -manylinux2014 = quay.io/pypa/manylinux2014_ppc64le:2022-06-13-c365205 -manylinux_2_24 = quay.io/pypa/manylinux_2_24_ppc64le:2022-06-13-c365205 -manylinux_2_28 = quay.io/pypa/manylinux_2_28_ppc64le:2022-06-13-c365205 -musllinux_1_1 = quay.io/pypa/musllinux_1_1_ppc64le:2022-06-13-c365205 +manylinux2014 = quay.io/pypa/manylinux2014_ppc64le:2022-06-20-d72b943 +manylinux_2_24 = quay.io/pypa/manylinux_2_24_ppc64le:2022-06-20-d72b943 +manylinux_2_28 = quay.io/pypa/manylinux_2_28_ppc64le:2022-06-20-d72b943 +musllinux_1_1 = quay.io/pypa/musllinux_1_1_ppc64le:2022-06-20-d72b943 [s390x] -manylinux2014 = quay.io/pypa/manylinux2014_s390x:2022-06-13-c365205 -manylinux_2_24 = quay.io/pypa/manylinux_2_24_s390x:2022-06-13-c365205 -musllinux_1_1 = quay.io/pypa/musllinux_1_1_s390x:2022-06-13-c365205 +manylinux2014 = quay.io/pypa/manylinux2014_s390x:2022-06-20-d72b943 +manylinux_2_24 = quay.io/pypa/manylinux_2_24_s390x:2022-06-20-d72b943 +musllinux_1_1 = quay.io/pypa/musllinux_1_1_s390x:2022-06-20-d72b943 [pypy_aarch64] -manylinux2014 = quay.io/pypa/manylinux2014_aarch64:2022-06-13-c365205 -manylinux_2_24 = quay.io/pypa/manylinux_2_24_aarch64:2022-06-13-c365205 -manylinux_2_28 = quay.io/pypa/manylinux_2_28_aarch64:2022-06-13-c365205 +manylinux2014 = quay.io/pypa/manylinux2014_aarch64:2022-06-20-d72b943 +manylinux_2_24 = quay.io/pypa/manylinux_2_24_aarch64:2022-06-20-d72b943 +manylinux_2_28 = quay.io/pypa/manylinux_2_28_aarch64:2022-06-20-d72b943 diff --git a/docs/working-examples.md b/docs/working-examples.md index 2845ebec..0fbf1f55 100644 --- a/docs/working-examples.md +++ b/docs/working-examples.md @@ -18,8 +18,8 @@ title: Working examples | [Prophet][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Tool for producing high quality forecasts for time series data that has multiple seasonality with linear or non-linear growth. | | [MyPy][] | ![github icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | The compiled version of MyPy using MyPyC. | | [pydantic][] | ![github icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | Data parsing and validation using Python type hints | -| [uvloop][] | ![github icon][] | ![apple icon][] ![linux icon][] | Ultra fast asyncio event loop. | | [MemRay][] | ![github icon][] | ![linux icon][] | Memray is a memory profiler for Python | +| [uvloop][] | ![github icon][] | ![apple icon][] ![linux icon][] | Ultra fast asyncio event loop. | | [psutil][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Cross-platform lib for process and system monitoring in Python | | [vaex][] | ![github icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | Out-of-Core hybrid Apache Arrow/NumPy DataFrame for Python, ML, visualization and exploration of big tabular data at a billion rows per second 🚀 | | [Google Benchmark][] | ![github icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | A microbenchmark support library | @@ -52,8 +52,8 @@ title: Working examples | [Wrapt][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | A Python module for decorators, wrappers and monkey patching. | | [PyAV][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Pythonic bindings for FFmpeg's libraries. | | [SimpleJSON][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | simplejson is a simple, fast, extensible JSON encoder/decoder for Python | -| [OpenColorIO][] | ![github icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | A color management framework for visual effects and animation. | | [pikepdf][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | A Python library for reading and writing PDF, powered by qpdf | +| [OpenColorIO][] | ![github icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | A color management framework for visual effects and animation. | | [Line Profiler][] | ![github icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | Line-by-line profiling for Python | | [PyTables][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | A Python package to manage extremely large amounts of data | | [OpenTimelineIO][] | ![github icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | Open Source API and interchange format for editorial timeline information. | @@ -86,8 +86,8 @@ title: Working examples | [PyGLM][] | ![github icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | Fast OpenGL Mathematics (GLM) for Python | | [boost-histogram][] | ![github icon][] ![travisci icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Supports full range of wheels, including PyPy and alternate archs. | | [bx-python][] | ![travisci icon][] | ![apple icon][] ![linux icon][] | A library that includes Cython extensions. | -| [iDynTree][] | ![github icon][] | ![linux icon][] | Uses manylinux_2_24 | | [TgCrypto][] | ![travisci icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Includes a Windows Travis build. | +| [iDynTree][] | ![github icon][] | ![linux icon][] | Uses manylinux_2_24 | | [Python-WebRTC][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | a Python extension that provides bindings to WebRTC M92 | | [pybase64][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Fast Base64 encoding/decoding in Python | | [Arbor][] | ![github icon][] | ![apple icon][] ![linux icon][] | Arbor is a multi-compartment neuron simulation library; compatible with next-generation accelerators; best-practices applied to research software; focused on community-driven development. Includes a [small script](https://github.com/arbor-sim/arbor/blob/master/scripts/patchwheel.py) patching `rpath` in bundled libraries. | @@ -118,8 +118,8 @@ title: Working examples [Prophet]: https://github.com/facebook/prophet [MyPy]: https://github.com/mypyc/mypy_mypyc-wheels [pydantic]: https://github.com/samuelcolvin/pydantic -[uvloop]: https://github.com/MagicStack/uvloop [MemRay]: https://github.com/bloomberg/memray +[uvloop]: https://github.com/MagicStack/uvloop [psutil]: https://github.com/giampaolo/psutil [vaex]: https://github.com/vaexio/vaex [Google Benchmark]: https://github.com/google/benchmark @@ -152,8 +152,8 @@ title: Working examples [Wrapt]: https://github.com/GrahamDumpleton/wrapt [PyAV]: https://github.com/PyAV-Org/PyAV [SimpleJSON]: https://github.com/simplejson/simplejson -[OpenColorIO]: https://github.com/AcademySoftwareFoundation/OpenColorIO [pikepdf]: https://github.com/pikepdf/pikepdf +[OpenColorIO]: https://github.com/AcademySoftwareFoundation/OpenColorIO [Line Profiler]: https://github.com/pyutils/line_profiler [PyTables]: https://github.com/PyTables/PyTables [OpenTimelineIO]: https://github.com/PixarAnimationStudios/OpenTimelineIO @@ -186,8 +186,8 @@ title: Working examples [PyGLM]: https://github.com/Zuzu-Typ/PyGLM [boost-histogram]: https://github.com/scikit-hep/boost-histogram [bx-python]: https://github.com/bxlab/bx-python -[iDynTree]: https://github.com/robotology/idyntree [TgCrypto]: https://github.com/pyrogram/tgcrypto +[iDynTree]: https://github.com/robotology/idyntree [Python-WebRTC]: https://github.com/MarshalX/python-webrtc [pybase64]: https://github.com/mayeut/pybase64 [Arbor]: https://github.com/arbor-sim/arbor @@ -218,105 +218,105 @@ title: Working examples [apple icon]: data/readme_icons/apple.svg [linux icon]: data/readme_icons/linux.svg - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + From df317a9000f61065ce55244b1f7ea05408cf45d8 Mon Sep 17 00:00:00 2001 From: joncrall Date: Thu, 16 Jun 2022 18:11:59 -0400 Subject: [PATCH 15/86] Flattened podman support commits --- .github/install_latest_podman.sh | 12 ++ .github/workflows/test.yml | 7 + cibuildwheel/docker_container.py | 132 +++++++++++++++-- cibuildwheel/linux.py | 9 +- cibuildwheel/options.py | 3 + cibuildwheel/resources/defaults.toml | 2 + setup.py | 1 + unit_test/conftest.py | 2 +- unit_test/docker_container_test.py | 214 ++++++++++++++++++++++++--- 9 files changed, 339 insertions(+), 43 deletions(-) create mode 100755 .github/install_latest_podman.sh diff --git a/.github/install_latest_podman.sh b/.github/install_latest_podman.sh new file mode 100755 index 00000000..42eca8b9 --- /dev/null +++ b/.github/install_latest_podman.sh @@ -0,0 +1,12 @@ +#!/bin/bash +__doc__=" +Based on code in: https://github.com/redhat-actions/podman-login/blob/main/.github/install_latest_podman.sh +" +# https://podman.io/getting-started/installation +# shellcheck source=/dev/null +. /etc/os-release +echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/ /" | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list +curl -sSfL "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/Release.key" | sudo apt-key add - +sudo apt-get update +sudo apt-get -y upgrade +sudo apt-get -y install podman diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a588b526..63f3f5d4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -45,6 +45,13 @@ jobs: with: python-version: ${{ matrix.python_version }} + # Install podman on this CI instance for podman tests on linux + # Snippet from: https://github.com/redhat-actions/podman-login/blob/main/.github/workflows/example.yml + - name: Install latest podman + if: runner.os == 'Linux' + run: | + bash .github/install_latest_podman.sh + - name: Install dependencies run: | python -m pip install ".[test]" diff --git a/cibuildwheel/docker_container.py b/cibuildwheel/docker_container.py index 9dc3ab70..ff57b78d 100644 --- a/cibuildwheel/docker_container.py +++ b/cibuildwheel/docker_container.py @@ -1,4 +1,5 @@ import io +import os import json import platform import shlex @@ -25,6 +26,18 @@ class DockerContainer: 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 + >>> docker_image = "quay.io/pypa/manylinux2014_x86_64:2020-05-17-2f8ac3b" + >>> # Test the default container + >>> with DockerContainer(docker_image=docker_image) as self: + ... self.call(["echo", "hello world"]) + ... self.call(["cat", "/proc/1/cgroup"]) + ... print(self.get_environment()) """ UTILITY_PYTHON = "/opt/python/cp38-cp38/bin/python" @@ -34,7 +47,13 @@ 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, + container_engine: str = "docker", + env: Optional[Dict[str, str]] = None, ): if not docker_image: raise ValueError("Must have a non-empty docker image to run.") @@ -43,10 +62,12 @@ class DockerContainer: self.simulate_32_bit = simulate_32_bit self.cwd = cwd self.name: Optional[str] = None + self.container_engine = container_engine + self.env = env # If specified, overwrite environment variables 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 @@ -57,24 +78,27 @@ class DockerContainer: network_args = ["--network=host"] shell_args = ["linux32", "/bin/bash"] if self.simulate_32_bit else ["/bin/bash"] + subprocess.run( [ - "docker", + self.container_engine, "create", "--env=CIBUILDWHEEL", f"--name={self.name}", "--interactive", - "--volume=/:/host", # ignored on CircleCI *network_args, - *cwd_args, + # Z-flags is for SELinux + "--volume=/:/host:Z", # ignored on CircleCI self.docker_image, *shell_args, ], + env=self.env, check=True, ) + self.process = subprocess.Popen( [ - "docker", + self.container_engine, "start", "--attach", "--interactive", @@ -82,6 +106,7 @@ class DockerContainer: ], stdin=subprocess.PIPE, stdout=subprocess.PIPE, + env=self.env, ) assert self.process.stdin and self.process.stdout @@ -89,7 +114,13 @@ class DockerContainer: self.bash_stdout = self.process.stdout # run a noop command to block until the container is responding - self.call(["/bin/true"]) + self.call(["/bin/true"], cwd="") + + if self.cwd: + # Although `docker create -w` does create the working dir if it + # does not exist, podman does not. There does not seem to be a way + # to setup a workdir for a container running in podman. + self.call(["mkdir", "-p", str(self.cwd)], cwd="") return self @@ -106,10 +137,20 @@ class DockerContainer: self.bash_stdin.close() self.bash_stdout.close() + if self.container_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. + # For now, this seems to work "well enough". + self.process.wait() + assert isinstance(self.name, str) subprocess.run( - ["docker", "rm", "--force", "-v", self.name], stdout=subprocess.DEVNULL, check=False + [self.container_engine, "rm", "--force", "-v", self.name], + stdout=subprocess.DEVNULL, + env=self.env, + check=False, ) self.name = None @@ -122,15 +163,16 @@ class DockerContainer: if from_path.is_dir(): self.call(["mkdir", "-p", to_path]) subprocess.run( - f"tar cf - . | docker exec -i {self.name} tar --no-same-owner -xC {shell_quote(to_path)} -f -", + f"tar cf - . | {self.container_engine} exec -i {self.name} tar --no-same-owner -xC {shell_quote(to_path)} -f -", shell=True, check=True, cwd=from_path, + env=self.env, ) else: with subprocess.Popen( [ - "docker", + "{self.container_engine}", "exec", "-i", str(self.name), @@ -138,6 +180,7 @@ class DockerContainer: "-c", f"cat > {shell_quote(to_path)}", ], + env=self.env, stdin=subprocess.PIPE, ) as docker: docker.stdin = cast(IO[bytes], docker.stdin) @@ -155,12 +198,47 @@ class DockerContainer: # note: we assume from_path is a dir to_path.mkdir(parents=True, exist_ok=True) - subprocess.run( - f"docker exec -i {self.name} tar -cC {shell_quote(from_path)} -f - . | tar -xf -", - shell=True, - check=True, - cwd=to_path, - ) + if self.container_engine == "podman": + # The copy out logic that works for docker does not seem to + # translate to podman, which seems to need the steps spelled out + # more explicitly. + command = f"{self.container_engine} exec -i {self.name} tar -cC {shell_quote(from_path)} -f /tmp/output-{self.name}.tar ." + subprocess.run( + command, + shell=True, + check=True, + cwd=to_path, + env=self.env, + ) + + command = f"{self.container_engine} cp {self.name}:/tmp/output-{self.name}.tar output-{self.name}.tar" + subprocess.run( + command, + shell=True, + check=True, + cwd=to_path, + env=self.env, + ) + command = f"tar -xvf output-{self.name}.tar" + subprocess.run( + command, + shell=True, + check=True, + cwd=to_path, + env=self.env, + ) + os.unlink(to_path / f"output-{self.name}.tar") + elif self.container_engine == "docker": + command = f"{self.container_engine} exec -i {self.name} tar -cC {shell_quote(from_path)} -f - . | tar -xf -" + subprocess.run( + command, + shell=True, + check=True, + cwd=to_path, + env=self.env, + ) + else: + raise KeyError(self.container_engine) def glob(self, path: PurePosixPath, pattern: str) -> List[PurePosixPath]: glob_pattern = path.joinpath(pattern) @@ -186,6 +264,11 @@ class DockerContainer: cwd: Optional[PathOrStr] = None, ) -> str: + if cwd is None: + # Podman does not start the a container in a specific working dir + # so we always need to specify it when making calls. + cwd = self.cwd + chdir = f"cd {cwd}" if cwd else "" env_assignments = ( " ".join(f"{shlex.quote(k)}={shlex.quote(v)}" for k, v in env.items()) @@ -271,6 +354,23 @@ class DockerContainer: # used as an EnvironmentExecutor to evaluate commands and capture output 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" + else: + command = f"{self.container_engine} info" + completed = subprocess.run( + command, + shell=True, + check=True, + cwd=self.cwd, + env=self.env, + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + ) + output = str(completed.stdout, encoding="utf8", errors="surrogateescape") + return output + def shell_quote(path: PurePath) -> str: return shlex.quote(str(path)) diff --git a/cibuildwheel/linux.py b/cibuildwheel/linux.py index 93225c21..e89a35b6 100644 --- a/cibuildwheel/linux.py +++ b/cibuildwheel/linux.py @@ -320,12 +320,16 @@ def build_on_docker( def build(options: Options, tmp_path: Path) -> None: # pylint: disable=unused-argument + + build_opts = options.build_options(None) try: # check docker is installed - subprocess.run(["docker", "--version"], check=True, stdout=subprocess.DEVNULL) + subprocess.run( + [build_opts.container_engine, "--version"], check=True, stdout=subprocess.DEVNULL + ) except subprocess.CalledProcessError: print( - "cibuildwheel: Docker not found. Docker is required to run Linux builds. " + f"cibuildwheel: {build_opts.container_engine} not found. An OCI exe like Docker or Podman is required to run Linux builds " "If you're building on Travis CI, add `services: [docker]` to your .travis.yml." "If you're building on Circle CI in Linux, add a `setup_remote_docker` step to your .circleci/config.yml", file=sys.stderr, @@ -355,6 +359,7 @@ def build(options: Options, tmp_path: Path) -> None: # pylint: disable=unused-a docker_image=build_step.docker_image, simulate_32_bit=build_step.platform_tag.endswith("i686"), cwd=container_project_path, + container_engine=build_opts.container_engine, ) as docker: build_on_docker( diff --git a/cibuildwheel/options.py b/cibuildwheel/options.py index 5d9744af..80ee5327 100644 --- a/cibuildwheel/options.py +++ b/cibuildwheel/options.py @@ -79,6 +79,7 @@ class BuildOptions(NamedTuple): test_extras: str build_verbosity: int build_frontend: BuildFrontend + container_engine: str @property def package_dir(self) -> Path: @@ -422,6 +423,7 @@ class Options: test_requires = self.reader.get("test-requires", sep=" ").split() test_extras = self.reader.get("test-extras", sep=",") build_verbosity_str = self.reader.get("build-verbosity") + container_engine = self.reader.get("container-engine") build_frontend: BuildFrontend if build_frontend_str == "build": @@ -520,6 +522,7 @@ class Options: manylinux_images=manylinux_images or None, musllinux_images=musllinux_images or None, build_frontend=build_frontend, + container_engine=container_engine, ) def check_for_invalid_configuration(self, identifiers: List[str]) -> None: diff --git a/cibuildwheel/resources/defaults.toml b/cibuildwheel/resources/defaults.toml index 5890c8ed..5e0bdacf 100644 --- a/cibuildwheel/resources/defaults.toml +++ b/cibuildwheel/resources/defaults.toml @@ -19,6 +19,8 @@ before-test = "" test-requires = [] test-extras = [] +container-engine = "docker" + manylinux-x86_64-image = "manylinux2014" manylinux-i686-image = "manylinux2014" manylinux-aarch64-image = "manylinux2014" diff --git a/setup.py b/setup.py index 7a9eee68..ad32d3f3 100644 --- a/setup.py +++ b/setup.py @@ -14,6 +14,7 @@ extras = { "pytest-timeout", "pytest-xdist", "build", + "toml", ], "bin": [ "click", diff --git a/unit_test/conftest.py b/unit_test/conftest.py index 2f794a21..4e22853a 100644 --- a/unit_test/conftest.py +++ b/unit_test/conftest.py @@ -16,7 +16,7 @@ def pytest_configure(config): def pytest_collection_modifyitems(config, items): if config.getoption("--run-docker"): - # --run-docker given in cli: do not skip docker tests + # --run-docker given in cli: do not skip container tests return skip_docker = pytest.mark.skip(reason="need --run-docker option to run") for item in items: diff --git a/unit_test/docker_container_test.py b/unit_test/docker_container_test.py index e9c43e77..dd317ee2 100644 --- a/unit_test/docker_container_test.py +++ b/unit_test/docker_container_test.py @@ -1,11 +1,15 @@ +import atexit +import os import platform import random import shutil import subprocess +import tempfile import textwrap from pathlib import Path, PurePath, PurePosixPath import pytest +import toml # type: ignore[import] from cibuildwheel.docker_container import DockerContainer from cibuildwheel.environment import EnvironmentAssignmentBash @@ -21,23 +25,178 @@ elif pm == "ppc64le": DEFAULT_IMAGE = "quay.io/pypa/manylinux2014_ppc64le:2020-05-17-2f8ac3b" elif pm == "s390x": DEFAULT_IMAGE = "quay.io/pypa/manylinux2014_s390x:2020-05-17-2f8ac3b" +else: + DEFAULT_IMAGE = "" + + +temp_test_dir = None + + +@atexit.register +def _cleanup_tempdir(): + """ + Cleans up any configuration written by :func:`basis_container_kwargs`. + + For podman tests, the user is not given write permissions by default in new + directories. As a workaround chown them before trying to delete them. + + It may be possible to handle this more cleanly in pytest itself, but using + atexit works well enough for now. + """ + import stat + + global temp_test_dir + if temp_test_dir is not None: + print(f"CLEANUP temp_test_dir = {temp_test_dir!r}") # type: ignore[unreachable] + for r, ds, fs in os.walk(temp_test_dir.name): + for d in ds: + dpath = os.path.join(r, d) + if not os.path.islink(dpath): + perms = os.lstat(dpath).st_mode + try: + os.chmod(dpath, stat.S_IWUSR | perms) + except Exception as ex: + print(f"issue with dpath = {dpath!r}, {ex!r}") + + for f in fs: + fpath = os.path.join(r, f) + if not os.path.islink(fpath): + perms = os.lstat(fpath).st_mode + try: + os.chmod(fpath, stat.S_IWUSR | perms) + except Exception as ex: + print(f"issue with fpath = {fpath!r}, {ex!r}") + else: + os.unlink(fpath) + try: + temp_test_dir.cleanup() + except Exception as ex: + print(f"Issue cleaning up ex = {ex!r}") + temp_test_dir = None + + +def basis_container_kwargs(): + """ + Generate keyword args that can be passed to to :class:`DockerContainer`. + + This is used with :func:`pytest.mark.parametrize` to run each test with + different configuraions of each supported containers engine. + + For docker we test the default configuration. + + For podman we test the default configuration and a configuration with VFS + (virtual file system) enabled as the storage driver. + """ + + global temp_test_dir + if temp_test_dir is None: + # Only setup the temp directory once for all tests + temp_test_dir = tempfile.TemporaryDirectory(prefix="cibw_test_") + + HAVE_DOCKER = bool(shutil.which("docker")) + HAVE_PODMAN = bool(shutil.which("podman")) + + if HAVE_DOCKER: + # Basic podman configuration + yield {"container_engine": "docker", "docker_image": DEFAULT_IMAGE} + + if HAVE_PODMAN: + # Basic podman usage + yield {"container_engine": "podman", "docker_image": DEFAULT_IMAGE} + + # VFS Podman usage (for the podman in docker use-case) + dpath = Path(temp_test_dir.name) + + # This requires that we write configuration files and point to them + # with environment variables before we run podman + # https://github.com/containers/common/blob/main/docs/containers.conf.5.md + vfs_containers_conf_data = { + "containers": { + "default_capabilities": [ + "CHOWN", + "DAC_OVERRIDE", + "FOWNER", + "FSETID", + "KILL", + "NET_BIND_SERVICE", + "SETFCAP", + "SETGID", + "SETPCAP", + "SETUID", + "SYS_CHROOT", + ] + }, + "engine": {"cgroup_manager": "cgroupfs", "events_logger": "file"}, + } + # https://github.com/containers/storage/blob/main/docs/containers-storage.conf.5.md + storage_root = dpath / ".local/share/containers/vfs-storage" + run_root = dpath / ".local/share/containers/vfs-runroot" + storage_root.mkdir(parents=True, exist_ok=True) + run_root.mkdir(parents=True, exist_ok=True) + vfs_containers_storage_conf_data = { + "storage": { + "driver": "vfs", + "graphroot": str(storage_root), + "runroot": str(run_root), + "rootless_storage_path": str(storage_root), + "options": { + # "remap-user": "containers", + "aufs": {"mountopt": "rw"}, + "overlay": {"mountopt": "rw", "force_mask": "shared"}, + # "vfs": {"ignore_chown_errors": "true"}, + }, + } + } + vfs_containers_conf_fpath = dpath / "temp_vfs_containers.conf" + vfs_containers_storage_conf_fpath = dpath / "temp_vfs_containers_storage.conf" + with open(vfs_containers_conf_fpath, "w") as file: + toml.dump(vfs_containers_conf_data, file) + + with open(vfs_containers_storage_conf_fpath, "w") as file: + toml.dump(vfs_containers_storage_conf_data, file) + + oci_environ = os.environ.copy() + oci_environ.update( + { + "CONTAINERS_CONF": str(vfs_containers_conf_fpath), + "CONTAINERS_STORAGE_CONF": str(vfs_containers_storage_conf_fpath), + } + ) + + yield { + "container_engine": "podman", + "docker_image": DEFAULT_IMAGE, + "env": oci_environ, + } @pytest.mark.docker -def test_simple(): - with DockerContainer(docker_image=DEFAULT_IMAGE) as container: +@pytest.mark.parametrize("container_kwargs", basis_container_kwargs()) +def test_simple(container_kwargs): + with DockerContainer(**container_kwargs) as container: assert container.call(["echo", "hello"], capture_output=True) == "hello\n" @pytest.mark.docker -def test_no_lf(): - with DockerContainer(docker_image=DEFAULT_IMAGE) as container: +@pytest.mark.parametrize("container_kwargs", basis_container_kwargs()) +def test_no_lf(container_kwargs): + with DockerContainer(**container_kwargs) as container: assert container.call(["printf", "hello"], capture_output=True) == "hello" @pytest.mark.docker -def test_environment(): - with DockerContainer(docker_image=DEFAULT_IMAGE) as container: +@pytest.mark.parametrize("container_kwargs", basis_container_kwargs()) +def test_debug_info(container_kwargs): + container = DockerContainer(**container_kwargs) + print(container.debug_info()) + with container: + pass + + +@pytest.mark.docker +@pytest.mark.parametrize("container_kwargs", basis_container_kwargs()) +def test_environment(container_kwargs): + with DockerContainer(**container_kwargs) as container: assert ( container.call( ["sh", "-c", "echo $TEST_VAR"], env={"TEST_VAR": "1"}, capture_output=True @@ -47,40 +206,43 @@ def test_environment(): @pytest.mark.docker -def test_cwd(): - with DockerContainer( - docker_image=DEFAULT_IMAGE, cwd="/cibuildwheel/working_directory" - ) as container: +@pytest.mark.parametrize("container_kwargs", basis_container_kwargs()) +def test_cwd(container_kwargs): + with DockerContainer(cwd="/cibuildwheel/working_directory", **container_kwargs) as container: assert container.call(["pwd"], capture_output=True) == "/cibuildwheel/working_directory\n" assert container.call(["pwd"], capture_output=True, cwd="/opt") == "/opt\n" @pytest.mark.docker -def test_container_removed(): - with DockerContainer(docker_image=DEFAULT_IMAGE) as container: +@pytest.mark.parametrize("container_kwargs", basis_container_kwargs()) +def test_container_removed(container_kwargs): + with DockerContainer(**container_kwargs) as container: docker_containers_listing = subprocess.run( - "docker container ls", + f"{container.container_engine} container ls", shell=True, check=True, stdout=subprocess.PIPE, universal_newlines=True, + env=container.env, ).stdout assert container.name is not None assert container.name in docker_containers_listing old_container_name = container.name docker_containers_listing = subprocess.run( - "docker container ls", + f"{container.container_engine} container ls", shell=True, check=True, stdout=subprocess.PIPE, universal_newlines=True, + env=container.env, ).stdout assert old_container_name not in docker_containers_listing @pytest.mark.docker -def test_large_environment(): +@pytest.mark.parametrize("container_kwargs", basis_container_kwargs()) +def test_large_environment(container_kwargs): # max environment variable size is 128kB long_env_var_length = 127 * 1024 large_environment = { @@ -90,7 +252,7 @@ def test_large_environment(): "d": "0" * long_env_var_length, } - with DockerContainer(docker_image=DEFAULT_IMAGE) as container: + with DockerContainer(**container_kwargs) as container: # check the length of d assert ( container.call(["sh", "-c", "echo ${#d}"], env=large_environment, capture_output=True) @@ -99,8 +261,9 @@ def test_large_environment(): @pytest.mark.docker -def test_binary_output(): - with DockerContainer(docker_image=DEFAULT_IMAGE) as container: +@pytest.mark.parametrize("container_kwargs", basis_container_kwargs()) +def test_binary_output(container_kwargs): + with DockerContainer(**container_kwargs) as container: # note: the below embedded snippets are in python2 # check that we can pass though arbitrary binary data without erroring @@ -150,8 +313,9 @@ def test_binary_output(): @pytest.mark.docker -def test_file_operations(tmp_path: Path): - with DockerContainer(docker_image=DEFAULT_IMAGE) as container: +@pytest.mark.parametrize("container_kwargs", basis_container_kwargs()) +def test_file_operation(tmp_path: Path, container_kwargs): + with DockerContainer(**container_kwargs) 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" @@ -166,8 +330,9 @@ def test_file_operations(tmp_path: Path): @pytest.mark.docker -def test_dir_operations(tmp_path: Path): - with DockerContainer(docker_image=DEFAULT_IMAGE) as container: +@pytest.mark.parametrize("container_kwargs", basis_container_kwargs()) +def test_dir_operations(tmp_path: Path, container_kwargs): + with DockerContainer(**container_kwargs) 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) @@ -196,7 +361,8 @@ def test_dir_operations(tmp_path: Path): @pytest.mark.docker -def test_environment_executor(): - with DockerContainer(docker_image=DEFAULT_IMAGE) as container: +@pytest.mark.parametrize("container_kwargs", basis_container_kwargs()) +def test_environment_executor(container_kwargs): + with DockerContainer(**container_kwargs) as container: assignment = EnvironmentAssignmentBash("TEST=$(echo 42)") assert assignment.evaluated_value({}, container.environment_executor) == "42" From 8dd76aaad7f722d5180db89f0b0a899194a3b43e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 23 Jun 2022 15:01:00 +0000 Subject: [PATCH 16/86] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- cibuildwheel/docker_container.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cibuildwheel/docker_container.py b/cibuildwheel/docker_container.py index ff57b78d..e4543815 100644 --- a/cibuildwheel/docker_container.py +++ b/cibuildwheel/docker_container.py @@ -1,6 +1,6 @@ import io -import os import json +import os import platform import shlex import shutil From 08bf6bfc8b5cbada3ac1132725a2dce2339dc6e2 Mon Sep 17 00:00:00 2001 From: joncrall Date: Thu, 23 Jun 2022 11:03:09 -0400 Subject: [PATCH 17/86] Fix bad fmtstring --- cibuildwheel/docker_container.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cibuildwheel/docker_container.py b/cibuildwheel/docker_container.py index ff57b78d..02636061 100644 --- a/cibuildwheel/docker_container.py +++ b/cibuildwheel/docker_container.py @@ -172,7 +172,7 @@ class DockerContainer: else: with subprocess.Popen( [ - "{self.container_engine}", + self.container_engine, "exec", "-i", str(self.name), From 65d70682afe31ca92b26c9fd376f043f9b17df47 Mon Sep 17 00:00:00 2001 From: joncrall Date: Thu, 23 Jun 2022 11:08:09 -0400 Subject: [PATCH 18/86] have doctest use a pinned docker images --- cibuildwheel/docker_container.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cibuildwheel/docker_container.py b/cibuildwheel/docker_container.py index 8da13d7e..55372be1 100644 --- a/cibuildwheel/docker_container.py +++ b/cibuildwheel/docker_container.py @@ -32,12 +32,14 @@ class DockerContainer: Example: >>> from cibuildwheel.docker_container import * # NOQA - >>> docker_image = "quay.io/pypa/manylinux2014_x86_64:2020-05-17-2f8ac3b" + >>> from cibuildwheel.options import _get_pinned_docker_images + >>> docker_image = _get_pinned_docker_images()['x86_64']['manylinux2014'] >>> # Test the default container >>> with DockerContainer(docker_image=docker_image) as self: ... self.call(["echo", "hello world"]) ... self.call(["cat", "/proc/1/cgroup"]) ... print(self.get_environment()) + ... print(self.debug_info()) """ UTILITY_PYTHON = "/opt/python/cp38-cp38/bin/python" From 0696c94710c746f6c6d0255e5d8c3f98870c57bc Mon Sep 17 00:00:00 2001 From: mayeut Date: Sun, 19 Jun 2022 16:34:28 +0200 Subject: [PATCH 19/86] feature: add support for `py3-none-{platform}` wheels This extends the mechanism introduced in #1091 for `abi3` wheels. Most of the mentions to `abi3` have been removed and replaced by a more generic `compatible_wheel`. This allows to build a wheel `foo-0.1-py3-none-win_amd64.whl` only once and still test with every configured python. --- cibuildwheel/linux.py | 12 +++++------ cibuildwheel/macos.py | 12 +++++------ cibuildwheel/util.py | 20 ++++++++++--------- cibuildwheel/windows.py | 12 +++++------ unit_test/utils_test.py | 44 ++++++++++++++++++++++++++++++++++++++++- 5 files changed, 72 insertions(+), 28 deletions(-) diff --git a/cibuildwheel/linux.py b/cibuildwheel/linux.py index 93225c21..58fe4dc9 100644 --- a/cibuildwheel/linux.py +++ b/cibuildwheel/linux.py @@ -12,7 +12,7 @@ from .typing import OrderedDict, PathOrStr, assert_never from .util import ( BuildSelector, NonPlatformWheelError, - find_compatible_abi3_wheel, + find_compatible_wheel, get_build_verbosity_extra_flags, prepare_command, read_python_configs, @@ -177,13 +177,13 @@ def build_on_docker( ) sys.exit(1) - abi3_wheel = find_compatible_abi3_wheel(built_wheels, config.identifier) - if abi3_wheel: + compatible_wheel = find_compatible_wheel(built_wheels, config.identifier) + if compatible_wheel: log.step_end() print( - f"\nFound previously built wheel {abi3_wheel.name}, that's compatible with {config.identifier}. Skipping build step..." + f"\nFound previously built wheel {compatible_wheel.name}, that's compatible with {config.identifier}. Skipping build step..." ) - repaired_wheels = [abi3_wheel] + repaired_wheels = [compatible_wheel] else: if build_options.before_build: @@ -304,7 +304,7 @@ def build_on_docker( docker.call(["rm", "-rf", venv_dir]) # move repaired wheels to output - if abi3_wheel is None: + if compatible_wheel is None: docker.call(["mkdir", "-p", container_output_dir]) docker.call(["mv", *repaired_wheels, container_output_dir]) built_wheels.extend( diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index 91ba3f8e..56942cfb 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -23,7 +23,7 @@ from .util import ( call, detect_ci_provider, download, - find_compatible_abi3_wheel, + find_compatible_wheel, get_build_verbosity_extra_flags, get_pip_version, install_certifi_script, @@ -321,13 +321,13 @@ def build(options: Options, tmp_path: Path) -> None: build_options.build_frontend, ) - abi3_wheel = find_compatible_abi3_wheel(built_wheels, config.identifier) - if abi3_wheel: + compatible_wheel = find_compatible_wheel(built_wheels, config.identifier) + if compatible_wheel: log.step_end() print( - f"\nFound previously built wheel {abi3_wheel.name}, that's compatible with {config.identifier}. Skipping build step..." + f"\nFound previously built wheel {compatible_wheel.name}, that's compatible with {config.identifier}. Skipping build step..." ) - repaired_wheel = abi3_wheel + repaired_wheel = compatible_wheel else: if build_options.before_build: log.step("Running before_build...") @@ -534,7 +534,7 @@ def build(options: Options, tmp_path: Path) -> None: ) # we're all done here; move it to output (overwrite existing) - if abi3_wheel is None: + if compatible_wheel is None: try: (build_options.output_dir / repaired_wheel.name).unlink() except FileNotFoundError: diff --git a/cibuildwheel/util.py b/cibuildwheel/util.py index db0cc687..45cd243a 100644 --- a/cibuildwheel/util.py +++ b/cibuildwheel/util.py @@ -54,7 +54,7 @@ __all__ = [ "MANYLINUX_ARCHS", "call", "shell", - "find_compatible_abi3_wheel", + "find_compatible_wheel", "format_safe", "prepare_command", "get_build_verbosity_extra_flags", @@ -574,23 +574,25 @@ def virtualenv( T = TypeVar("T", bound=PurePath) -def find_compatible_abi3_wheel(wheels: Sequence[T], identifier: str) -> Optional[T]: +def find_compatible_wheel(wheels: Sequence[T], identifier: str) -> Optional[T]: """ - Finds an ABI3 wheel in `wheels` compatible with the Python interpreter + Finds a wheel with an abi3 or a none ABI tag in `wheels` compatible with the Python interpreter specified by `identifier`. """ interpreter, platform = identifier.split("-") - if not interpreter.startswith("cp3"): - return None for wheel in wheels: _, _, _, tags = parse_wheel_filename(wheel.name) for tag in tags: - if tag.abi != "abi3": + if tag.abi == "abi3": + if not (interpreter.startswith("cp3") and tag.interpreter.startswith("cp3")): + continue + elif tag.abi == "none": + if tag.interpreter[:3] != "py3": + continue + else: continue - if not tag.interpreter.startswith("cp3"): - continue - if int(tag.interpreter[3:]) > int(interpreter[3:]): + if tag.interpreter != "py3" and int(tag.interpreter[3:]) > int(interpreter[3:]): continue if platform.startswith(("manylinux", "musllinux", "macosx")): # Linux, macOS diff --git a/cibuildwheel/windows.py b/cibuildwheel/windows.py index 1e95c225..5f0d2344 100644 --- a/cibuildwheel/windows.py +++ b/cibuildwheel/windows.py @@ -22,7 +22,7 @@ from .util import ( NonPlatformWheelError, call, download, - find_compatible_abi3_wheel, + find_compatible_wheel, get_build_verbosity_extra_flags, get_pip_version, prepare_command, @@ -277,13 +277,13 @@ def build(options: Options, tmp_path: Path) -> None: build_options.build_frontend, ) - abi3_wheel = find_compatible_abi3_wheel(built_wheels, config.identifier) - if abi3_wheel: + compatible_wheel = find_compatible_wheel(built_wheels, config.identifier) + if compatible_wheel: log.step_end() print( - f"\nFound previously built wheel {abi3_wheel.name}, that's compatible with {config.identifier}. Skipping build step..." + f"\nFound previously built wheel {compatible_wheel.name}, that's compatible with {config.identifier}. Skipping build step..." ) - repaired_wheel = abi3_wheel + repaired_wheel = compatible_wheel else: # run the before_build command if build_options.before_build: @@ -418,7 +418,7 @@ def build(options: Options, tmp_path: Path) -> None: shell(test_command_prepared, cwd="c:\\", env=virtualenv_env) # we're all done here; move it to output (remove if already exists) - if abi3_wheel is None: + if compatible_wheel is None: shutil.move(str(repaired_wheel), build_options.output_dir) built_wheels.append(build_options.output_dir / repaired_wheel.name) diff --git a/unit_test/utils_test.py b/unit_test/utils_test.py index 41e376fa..7f949a73 100644 --- a/unit_test/utils_test.py +++ b/unit_test/utils_test.py @@ -1,4 +1,8 @@ -from cibuildwheel.util import format_safe, prepare_command +from pathlib import PurePath + +import pytest + +from cibuildwheel.util import find_compatible_wheel, format_safe, prepare_command def test_format_safe(): @@ -46,3 +50,41 @@ def test_prepare_command(): prepare_command("{a}{a,b}{b:.2e}{c}{d%s}{e:3}{f[0]}", a="42", b="3.14159") == "42{a,b}{b:.2e}{c}{d%s}{e:3}{f[0]}" ) + + +@pytest.mark.parametrize( + "wheel,identifier", + ( + ("foo-0.1-cp38-abi3-win_amd64.whl", "cp310-win_amd64"), + ("foo-0.1-cp38-abi3-macosx_11_0_x86_64.whl", "cp310-macosx_x86_64"), + ("foo-0.1-cp38-abi3-manylinux2014_x86_64.whl", "cp310-manylinux_x86_64"), + ("foo-0.1-cp38-abi3-musllinux_1_1_x86_64.whl", "cp310-musllinux_x86_64"), + ("foo-0.1-py2.py3-none-win_amd64.whl", "cp310-win_amd64"), + ("foo-0.1-py2.py3-none-win_amd64.whl", "pp310-win_amd64"), + ("foo-0.1-py3-none-win_amd64.whl", "cp310-win_amd64"), + ("foo-0.1-py38-none-win_amd64.whl", "cp310-win_amd64"), + ("foo-0.1-py38-none-win_amd64.whl", "pp310-win_amd64"), + ), +) +def test_find_compatible_wheel_found(wheel: str, identifier: str): + wheel_ = PurePath(wheel) + found = find_compatible_wheel([wheel_], identifier) + assert found is wheel_ + + +@pytest.mark.parametrize( + "wheel,identifier", + ( + ("foo-0.1-cp38-abi3-win_amd64.whl", "cp310-win32"), + ("foo-0.1-cp38-abi3-win_amd64.whl", "cp37-win_amd64"), + ("foo-0.1-cp38-abi3-macosx_11_0_x86_64.whl", "cp310-macosx_universal2"), + ("foo-0.1-cp38-abi3-manylinux2014_x86_64.whl", "cp310-musllinux_x86_64"), + ("foo-0.1-cp38-abi3-musllinux_1_1_x86_64.whl", "cp310-manylinux_x86_64"), + ("foo-0.1-py2-none-win_amd64.whl", "cp310-win_amd64"), + ("foo-0.1-py38-none-win_amd64.whl", "cp37-win_amd64"), + ("foo-0.1-py38-none-win_amd64.whl", "pp37-win_amd64"), + ("foo-0.1-cp38-cp38-win_amd64.whl", "cp310-win_amd64"), + ), +) +def test_find_compatible_wheel_not_found(wheel: str, identifier: str): + assert find_compatible_wheel([PurePath(wheel)], identifier) is None From ef18186c455b3d4225b9de89e623cb2a77c6091c Mon Sep 17 00:00:00 2001 From: mayeut Date: Sun, 19 Jun 2022 18:03:05 +0200 Subject: [PATCH 20/86] fix: error out if multiple wheels with the same name are produced We shouldn't silently overwrite wheels that are produced in the same run that have the same filename, as this implies a misconfiguration. --- cibuildwheel/linux.py | 5 +++++ cibuildwheel/macos.py | 4 ++++ cibuildwheel/util.py | 14 ++++++++++++++ cibuildwheel/windows.py | 4 ++++ test/test_same_wheel.py | 42 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 69 insertions(+) create mode 100644 test/test_same_wheel.py diff --git a/cibuildwheel/linux.py b/cibuildwheel/linux.py index 58fe4dc9..d6b39e74 100644 --- a/cibuildwheel/linux.py +++ b/cibuildwheel/linux.py @@ -10,6 +10,7 @@ from .logger import log from .options import Options from .typing import OrderedDict, PathOrStr, assert_never from .util import ( + AlreadyBuiltWheelError, BuildSelector, NonPlatformWheelError, find_compatible_wheel, @@ -255,6 +256,10 @@ def build_on_docker( repaired_wheels = docker.glob(repaired_wheel_dir, "*.whl") + for repaired_wheel in repaired_wheels: + if repaired_wheel.name in {wheel.name for wheel in built_wheels}: + raise AlreadyBuiltWheelError(repaired_wheel.name) + if build_options.test_command and build_options.test_selector(config.identifier): log.step("Testing wheel...") diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index 56942cfb..d5fff5ed 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -17,6 +17,7 @@ from .options import Options from .typing import Literal, PathOrStr, assert_never from .util import ( CIBW_CACHE_PATH, + AlreadyBuiltWheelError, BuildFrontend, BuildSelector, NonPlatformWheelError, @@ -408,6 +409,9 @@ def build(options: Options, tmp_path: Path) -> None: repaired_wheel = next(repaired_wheel_dir.glob("*.whl")) + if repaired_wheel.name in {wheel.name for wheel in built_wheels}: + raise AlreadyBuiltWheelError(repaired_wheel.name) + log.step_end() if build_options.test_command and build_options.test_selector(config.identifier): diff --git a/cibuildwheel/util.py b/cibuildwheel/util.py index 45cd243a..268e7ce4 100644 --- a/cibuildwheel/util.py +++ b/cibuildwheel/util.py @@ -373,6 +373,20 @@ class NonPlatformWheelError(Exception): super().__init__(message) +class AlreadyBuiltWheelError(Exception): + def __init__(self, wheel_name: str) -> None: + message = textwrap.dedent( + f""" + cibuildwheel: Build failed because a wheel named {wheel_name} was already generated in the current run. + + If you expected another wheel to be generated, check your project configuration, or run + cibuildwheel with CIBW_BUILD_VERBOSITY=1 to view build logs. + """ + ) + + super().__init__(message) + + def strtobool(val: str) -> bool: return val.lower() in {"y", "yes", "t", "true", "on", "1"} diff --git a/cibuildwheel/windows.py b/cibuildwheel/windows.py index 5f0d2344..b4ae6e07 100644 --- a/cibuildwheel/windows.py +++ b/cibuildwheel/windows.py @@ -17,6 +17,7 @@ from .options import Options from .typing import PathOrStr, assert_never from .util import ( CIBW_CACHE_PATH, + AlreadyBuiltWheelError, BuildFrontend, BuildSelector, NonPlatformWheelError, @@ -365,6 +366,9 @@ def build(options: Options, tmp_path: Path) -> None: repaired_wheel = next(repaired_wheel_dir.glob("*.whl")) + if repaired_wheel.name in {wheel.name for wheel in built_wheels}: + raise AlreadyBuiltWheelError(repaired_wheel.name) + if build_options.test_command and options.globals.test_selector(config.identifier): log.step("Testing wheel...") # set up a virtual environment to install and test from, to make sure diff --git a/test/test_same_wheel.py b/test/test_same_wheel.py new file mode 100644 index 00000000..d89f28cb --- /dev/null +++ b/test/test_same_wheel.py @@ -0,0 +1,42 @@ +import subprocess +from test import test_projects + +import pytest + +from . import utils + +basic_project = test_projects.new_c_project() +basic_project.files[ + "repair.py" +] = """ +import shutil +import sys +from pathlib import Path + +wheel = Path(sys.argv[1]) +dest_dir = Path(sys.argv[2]) +platform = wheel.stem.split("-")[-1] +name = f"spam-0.1.0-py2-none-{platform}.whl" +dest = dest_dir / name +dest_dir.mkdir(parents=True, exist_ok=True) +if dest.exists(): + dest.unlink() +shutil.copy(wheel, dest) +""" + + +def test(tmp_path, capfd): + # this test checks that a generated wheel name shall be unique in a given cibuildwheel run + project_dir = tmp_path / "project" + basic_project.generate(project_dir) + + with pytest.raises(subprocess.CalledProcessError): + utils.cibuildwheel_run( + project_dir, + add_env={ + "CIBW_REPAIR_WHEEL_COMMAND": "python repair.py {wheel} {dest_dir}", + }, + ) + + captured = capfd.readouterr() + assert "Build failed because a wheel named" in captured.err From 90945a38d2fc3ee8d2ad155baeafb951cd624b2e Mon Sep 17 00:00:00 2001 From: joncrall Date: Sun, 26 Jun 2022 15:53:44 -0400 Subject: [PATCH 21/86] reworks --- cibuildwheel/docker_container.py | 24 +++- unit_test/docker_container_test.py | 186 +++++++++++++++-------------- 2 files changed, 115 insertions(+), 95 deletions(-) diff --git a/cibuildwheel/docker_container.py b/cibuildwheel/docker_container.py index 55372be1..4fd1b471 100644 --- a/cibuildwheel/docker_container.py +++ b/cibuildwheel/docker_container.py @@ -80,7 +80,6 @@ class DockerContainer: network_args = ["--network=host"] shell_args = ["linux32", "/bin/bash"] if self.simulate_32_bit else ["/bin/bash"] - subprocess.run( [ self.container_engine, @@ -89,8 +88,10 @@ class DockerContainer: f"--name={self.name}", "--interactive", *network_args, + # Do we need the hostmout? # Z-flags is for SELinux - "--volume=/:/host:Z", # ignored on CircleCI + # "--volume=/:/host:Z", # ignored on CircleCI + # "--volume=/:/host", self.docker_image, *shell_args, ], @@ -116,13 +117,13 @@ class DockerContainer: self.bash_stdout = self.process.stdout # run a noop command to block until the container is responding - self.call(["/bin/true"], cwd="") + self.call(["/bin/true"], cwd="/") if self.cwd: # Although `docker create -w` does create the working dir if it # does not exist, podman does not. There does not seem to be a way # to setup a workdir for a container running in podman. - self.call(["mkdir", "-p", str(self.cwd)], cwd="") + self.call(["mkdir", "-p", str(self.cwd)], cwd="/") return self @@ -200,7 +201,20 @@ class DockerContainer: # note: we assume from_path is a dir to_path.mkdir(parents=True, exist_ok=True) - if self.container_engine == "podman": + TRY_SIMPLE_CP = 0 + if TRY_SIMPLE_CP: + # There is a bug in docker that prevents this simple implementation + # from working https://github.com/moby/moby/issues/38995 + # It seems to also not workin podman as well + command = f"{self.container_engine} cp {self.name}:{shell_quote(from_path)} {shell_quote(to_path)}" + subprocess.run( + command, + shell=True, + check=True, + cwd=to_path, + env=self.env, + ) + elif self.container_engine == "podman": # The copy out logic that works for docker does not seem to # translate to podman, which seems to need the steps spelled out # more explicitly. diff --git a/unit_test/docker_container_test.py b/unit_test/docker_container_test.py index dd317ee2..a52279e8 100644 --- a/unit_test/docker_container_test.py +++ b/unit_test/docker_container_test.py @@ -28,11 +28,14 @@ elif pm == "s390x": else: DEFAULT_IMAGE = "" - -temp_test_dir = None +# A dictionary to make it easier to manipulate globals +_STATE = { + 'temp_test_dir': None, + 'using_podman': False, +} -@atexit.register +# @atexit.register def _cleanup_tempdir(): """ Cleans up any configuration written by :func:`basis_container_kwargs`. @@ -42,37 +45,24 @@ def _cleanup_tempdir(): It may be possible to handle this more cleanly in pytest itself, but using atexit works well enough for now. + + The reason why permission errors occur on podman is documented in + [PodmanStoragePerms]_. + + References: + .. [PodmanStoragePerms] https://podman.io/blogs/2018/10/03/podman-remove-content-homedir.html """ - import stat - - global temp_test_dir + temp_test_dir = _STATE['temp_test_dir'] if temp_test_dir is not None: - print(f"CLEANUP temp_test_dir = {temp_test_dir!r}") # type: ignore[unreachable] - for r, ds, fs in os.walk(temp_test_dir.name): - for d in ds: - dpath = os.path.join(r, d) - if not os.path.islink(dpath): - perms = os.lstat(dpath).st_mode - try: - os.chmod(dpath, stat.S_IWUSR | perms) - except Exception as ex: - print(f"issue with dpath = {dpath!r}, {ex!r}") - - for f in fs: - fpath = os.path.join(r, f) - if not os.path.islink(fpath): - perms = os.lstat(fpath).st_mode - try: - os.chmod(fpath, stat.S_IWUSR | perms) - except Exception as ex: - print(f"issue with fpath = {fpath!r}, {ex!r}") - else: - os.unlink(fpath) + # When podman creates special directories, they cant be cleaned up + # unless you fake a UID of 0. The package rootlesskit helps with that. + if _STATE['using_podman']: + subprocess.call(['podman', 'unshare', 'rm', '-rf', temp_test_dir.name]) try: temp_test_dir.cleanup() except Exception as ex: print(f"Issue cleaning up ex = {ex!r}") - temp_test_dir = None + _STATE['temp_test_dir'] = None def basis_container_kwargs(): @@ -80,18 +70,27 @@ def basis_container_kwargs(): Generate keyword args that can be passed to to :class:`DockerContainer`. This is used with :func:`pytest.mark.parametrize` to run each test with - different configuraions of each supported containers engine. + different configurations of each supported containers engine. For docker we test the default configuration. For podman we test the default configuration and a configuration with VFS (virtual file system) enabled as the storage driver. + + Yields: + Dict: a configuration passed as ``container_kwargs`` to each + parameterized test. """ - global temp_test_dir - if temp_test_dir is None: + if _STATE['temp_test_dir'] is None: # Only setup the temp directory once for all tests - temp_test_dir = tempfile.TemporaryDirectory(prefix="cibw_test_") + _STATE['temp_test_dir'] = tempfile.TemporaryDirectory(prefix="cibw_test_") + # Register the special cleanup hook after the temp directory is created + # to ensure that it runs before the temp directory logic runs (which + # will not handle cases where there is a fake root UID). + atexit.register(_cleanup_tempdir) + + temp_test_dir = _STATE['temp_test_dir'] HAVE_DOCKER = bool(shutil.which("docker")) HAVE_PODMAN = bool(shutil.which("podman")) @@ -102,67 +101,11 @@ def basis_container_kwargs(): if HAVE_PODMAN: # Basic podman usage + _STATE['using_podman'] = True yield {"container_engine": "podman", "docker_image": DEFAULT_IMAGE} # VFS Podman usage (for the podman in docker use-case) - dpath = Path(temp_test_dir.name) - - # This requires that we write configuration files and point to them - # with environment variables before we run podman - # https://github.com/containers/common/blob/main/docs/containers.conf.5.md - vfs_containers_conf_data = { - "containers": { - "default_capabilities": [ - "CHOWN", - "DAC_OVERRIDE", - "FOWNER", - "FSETID", - "KILL", - "NET_BIND_SERVICE", - "SETFCAP", - "SETGID", - "SETPCAP", - "SETUID", - "SYS_CHROOT", - ] - }, - "engine": {"cgroup_manager": "cgroupfs", "events_logger": "file"}, - } - # https://github.com/containers/storage/blob/main/docs/containers-storage.conf.5.md - storage_root = dpath / ".local/share/containers/vfs-storage" - run_root = dpath / ".local/share/containers/vfs-runroot" - storage_root.mkdir(parents=True, exist_ok=True) - run_root.mkdir(parents=True, exist_ok=True) - vfs_containers_storage_conf_data = { - "storage": { - "driver": "vfs", - "graphroot": str(storage_root), - "runroot": str(run_root), - "rootless_storage_path": str(storage_root), - "options": { - # "remap-user": "containers", - "aufs": {"mountopt": "rw"}, - "overlay": {"mountopt": "rw", "force_mask": "shared"}, - # "vfs": {"ignore_chown_errors": "true"}, - }, - } - } - vfs_containers_conf_fpath = dpath / "temp_vfs_containers.conf" - vfs_containers_storage_conf_fpath = dpath / "temp_vfs_containers_storage.conf" - with open(vfs_containers_conf_fpath, "w") as file: - toml.dump(vfs_containers_conf_data, file) - - with open(vfs_containers_storage_conf_fpath, "w") as file: - toml.dump(vfs_containers_storage_conf_data, file) - - oci_environ = os.environ.copy() - oci_environ.update( - { - "CONTAINERS_CONF": str(vfs_containers_conf_fpath), - "CONTAINERS_STORAGE_CONF": str(vfs_containers_storage_conf_fpath), - } - ) - + oci_environ = _setup_podman_vfs(temp_test_dir.name) yield { "container_engine": "podman", "docker_image": DEFAULT_IMAGE, @@ -170,6 +113,69 @@ def basis_container_kwargs(): } +def _setup_podman_vfs(dpath): + """ + Setup the filesystem and environment variables for the VFS podman test + """ + dpath = Path(dpath) + # This requires that we write configuration files and point to them + # with environment variables before we run podman + # https://github.com/containers/common/blob/main/docs/containers.conf.5.md + vfs_containers_conf_data = { + "containers": { + "default_capabilities": [ + "CHOWN", + "DAC_OVERRIDE", + "FOWNER", + "FSETID", + "KILL", + "NET_BIND_SERVICE", + "SETFCAP", + "SETGID", + "SETPCAP", + "SETUID", + "SYS_CHROOT", + ] + }, + "engine": {"cgroup_manager": "cgroupfs", "events_logger": "file"}, + } + # https://github.com/containers/storage/blob/main/docs/containers-storage.conf.5.md + storage_root = dpath / ".local/share/containers/vfs-storage" + run_root = dpath / ".local/share/containers/vfs-runroot" + storage_root.mkdir(parents=True, exist_ok=True) + run_root.mkdir(parents=True, exist_ok=True) + vfs_containers_storage_conf_data = { + "storage": { + "driver": "vfs", + "graphroot": os.fspath(storage_root), + "runroot": os.fspath(run_root), + "rootless_storage_path": os.fspath(storage_root), + "options": { + # "remap-user": "containers", + "aufs": {"mountopt": "rw"}, + "overlay": {"mountopt": "rw", "force_mask": "shared"}, + # "vfs": {"ignore_chown_errors": "true"}, + }, + } + } + vfs_containers_conf_fpath = dpath / "temp_vfs_containers.conf" + vfs_containers_storage_conf_fpath = dpath / "temp_vfs_containers_storage.conf" + with open(vfs_containers_conf_fpath, "w") as file: + toml.dump(vfs_containers_conf_data, file) + + with open(vfs_containers_storage_conf_fpath, "w") as file: + toml.dump(vfs_containers_storage_conf_data, file) + + oci_environ = os.environ.copy() + oci_environ.update( + { + "CONTAINERS_CONF": os.fspath(vfs_containers_conf_fpath), + "CONTAINERS_STORAGE_CONF": os.fspath(vfs_containers_storage_conf_fpath), + } + ) + return oci_environ + + @pytest.mark.docker @pytest.mark.parametrize("container_kwargs", basis_container_kwargs()) def test_simple(container_kwargs): From 4a7d89b3c8882441ae01de502a93d43b9a71985e Mon Sep 17 00:00:00 2001 From: joncrall Date: Sun, 26 Jun 2022 16:57:26 -0400 Subject: [PATCH 22/86] Does podman work with the original host args --- cibuildwheel/docker_container.py | 32 +++++++++++------------ unit_test/docker_container_test.py | 42 +++++++++++++++++++++--------- 2 files changed, 46 insertions(+), 28 deletions(-) diff --git a/cibuildwheel/docker_container.py b/cibuildwheel/docker_container.py index 4fd1b471..0d010aee 100644 --- a/cibuildwheel/docker_container.py +++ b/cibuildwheel/docker_container.py @@ -65,7 +65,6 @@ class DockerContainer: self.cwd = cwd self.name: Optional[str] = None self.container_engine = container_engine - self.env = env # If specified, overwrite environment variables def __enter__(self) -> "DockerContainer": @@ -80,6 +79,21 @@ class DockerContainer: network_args = ["--network=host"] shell_args = ["linux32", "/bin/bash"] if self.simulate_32_bit else ["/bin/bash"] + + # volume args are ignored on CircleCI + # For a discussion of if :Z should be included or not: + # https://github.com/pypa/cibuildwheel/pull/966#discussion_r906707824 + # https://stackoverflow.com/questions/35218194/what-is-z-flag-in-docker-containers-volumes-from-option/35222815#35222815 + # https://github.com/moby/moby/issues/30934 + # The Z option indicates that the bind mount content is private and + # unshared. Use extreme caution with these options. Bind-mounting a + # system directory such as /home or /usr with the Z option renders your + # host machine inoperable and you may need to relabel the host machine + # files by hand. + volume_args = ['--volume=/:/host'] + # volume_args = ['--volume=/:/host:Z'] + # volume_args = [] + subprocess.run( [ self.container_engine, @@ -88,14 +102,10 @@ class DockerContainer: f"--name={self.name}", "--interactive", *network_args, - # Do we need the hostmout? - # Z-flags is for SELinux - # "--volume=/:/host:Z", # ignored on CircleCI - # "--volume=/:/host", + *volume_args, self.docker_image, *shell_args, ], - env=self.env, check=True, ) @@ -109,7 +119,6 @@ class DockerContainer: ], stdin=subprocess.PIPE, stdout=subprocess.PIPE, - env=self.env, ) assert self.process.stdin and self.process.stdout @@ -152,7 +161,6 @@ class DockerContainer: subprocess.run( [self.container_engine, "rm", "--force", "-v", self.name], stdout=subprocess.DEVNULL, - env=self.env, check=False, ) self.name = None @@ -170,7 +178,6 @@ class DockerContainer: shell=True, check=True, cwd=from_path, - env=self.env, ) else: with subprocess.Popen( @@ -183,7 +190,6 @@ class DockerContainer: "-c", f"cat > {shell_quote(to_path)}", ], - env=self.env, stdin=subprocess.PIPE, ) as docker: docker.stdin = cast(IO[bytes], docker.stdin) @@ -212,7 +218,6 @@ class DockerContainer: shell=True, check=True, cwd=to_path, - env=self.env, ) elif self.container_engine == "podman": # The copy out logic that works for docker does not seem to @@ -224,7 +229,6 @@ class DockerContainer: shell=True, check=True, cwd=to_path, - env=self.env, ) command = f"{self.container_engine} cp {self.name}:/tmp/output-{self.name}.tar output-{self.name}.tar" @@ -233,7 +237,6 @@ class DockerContainer: shell=True, check=True, cwd=to_path, - env=self.env, ) command = f"tar -xvf output-{self.name}.tar" subprocess.run( @@ -241,7 +244,6 @@ class DockerContainer: shell=True, check=True, cwd=to_path, - env=self.env, ) os.unlink(to_path / f"output-{self.name}.tar") elif self.container_engine == "docker": @@ -251,7 +253,6 @@ class DockerContainer: shell=True, check=True, cwd=to_path, - env=self.env, ) else: raise KeyError(self.container_engine) @@ -380,7 +381,6 @@ class DockerContainer: shell=True, check=True, cwd=self.cwd, - env=self.env, stdin=subprocess.PIPE, stdout=subprocess.PIPE, ) diff --git a/unit_test/docker_container_test.py b/unit_test/docker_container_test.py index a52279e8..52603b5a 100644 --- a/unit_test/docker_container_test.py +++ b/unit_test/docker_container_test.py @@ -178,21 +178,27 @@ def _setup_podman_vfs(dpath): @pytest.mark.docker @pytest.mark.parametrize("container_kwargs", basis_container_kwargs()) -def test_simple(container_kwargs): +def test_simple(container_kwargs, monkeypatch): + for k, v in container_kwargs.pop('env', {}).items(): + monkeypatch.setenv(k, v) with DockerContainer(**container_kwargs) as container: assert container.call(["echo", "hello"], capture_output=True) == "hello\n" @pytest.mark.docker @pytest.mark.parametrize("container_kwargs", basis_container_kwargs()) -def test_no_lf(container_kwargs): +def test_no_lf(container_kwargs, monkeypatch): + for k, v in container_kwargs.pop('env', {}).items(): + monkeypatch.setenv(k, v) with DockerContainer(**container_kwargs) as container: assert container.call(["printf", "hello"], capture_output=True) == "hello" @pytest.mark.docker @pytest.mark.parametrize("container_kwargs", basis_container_kwargs()) -def test_debug_info(container_kwargs): +def test_debug_info(container_kwargs, monkeypatch): + for k, v in container_kwargs.pop('env', {}).items(): + monkeypatch.setenv(k, v) container = DockerContainer(**container_kwargs) print(container.debug_info()) with container: @@ -201,7 +207,9 @@ def test_debug_info(container_kwargs): @pytest.mark.docker @pytest.mark.parametrize("container_kwargs", basis_container_kwargs()) -def test_environment(container_kwargs): +def test_environment(container_kwargs, monkeypatch): + for k, v in container_kwargs.pop('env', {}).items(): + monkeypatch.setenv(k, v) with DockerContainer(**container_kwargs) as container: assert ( container.call( @@ -221,7 +229,9 @@ def test_cwd(container_kwargs): @pytest.mark.docker @pytest.mark.parametrize("container_kwargs", basis_container_kwargs()) -def test_container_removed(container_kwargs): +def test_container_removed(container_kwargs, monkeypatch): + for k, v in container_kwargs.pop('env', {}).items(): + monkeypatch.setenv(k, v) with DockerContainer(**container_kwargs) as container: docker_containers_listing = subprocess.run( f"{container.container_engine} container ls", @@ -229,7 +239,6 @@ def test_container_removed(container_kwargs): check=True, stdout=subprocess.PIPE, universal_newlines=True, - env=container.env, ).stdout assert container.name is not None assert container.name in docker_containers_listing @@ -241,14 +250,15 @@ def test_container_removed(container_kwargs): check=True, stdout=subprocess.PIPE, universal_newlines=True, - env=container.env, ).stdout assert old_container_name not in docker_containers_listing @pytest.mark.docker @pytest.mark.parametrize("container_kwargs", basis_container_kwargs()) -def test_large_environment(container_kwargs): +def test_large_environment(container_kwargs, monkeypatch): + for k, v in container_kwargs.pop('env', {}).items(): + monkeypatch.setenv(k, v) # max environment variable size is 128kB long_env_var_length = 127 * 1024 large_environment = { @@ -268,7 +278,9 @@ def test_large_environment(container_kwargs): @pytest.mark.docker @pytest.mark.parametrize("container_kwargs", basis_container_kwargs()) -def test_binary_output(container_kwargs): +def test_binary_output(container_kwargs, monkeypatch): + for k, v in container_kwargs.pop('env', {}).items(): + monkeypatch.setenv(k, v) with DockerContainer(**container_kwargs) as container: # note: the below embedded snippets are in python2 @@ -320,7 +332,9 @@ def test_binary_output(container_kwargs): @pytest.mark.docker @pytest.mark.parametrize("container_kwargs", basis_container_kwargs()) -def test_file_operation(tmp_path: Path, container_kwargs): +def test_file_operation(tmp_path: Path, container_kwargs, monkeypatch): + for k, v in container_kwargs.pop('env', {}).items(): + monkeypatch.setenv(k, v) with DockerContainer(**container_kwargs) as container: # test copying a file in test_binary_data = bytes(random.randrange(256) for _ in range(1000)) @@ -337,7 +351,9 @@ def test_file_operation(tmp_path: Path, container_kwargs): @pytest.mark.docker @pytest.mark.parametrize("container_kwargs", basis_container_kwargs()) -def test_dir_operations(tmp_path: Path, container_kwargs): +def test_dir_operations(tmp_path: Path, container_kwargs, monkeypatch): + for k, v in container_kwargs.pop('env', {}).items(): + monkeypatch.setenv(k, v) with DockerContainer(**container_kwargs) as container: test_binary_data = bytes(random.randrange(256) for _ in range(1000)) original_test_file = tmp_path / "test.dat" @@ -368,7 +384,9 @@ def test_dir_operations(tmp_path: Path, container_kwargs): @pytest.mark.docker @pytest.mark.parametrize("container_kwargs", basis_container_kwargs()) -def test_environment_executor(container_kwargs): +def test_environment_executor(container_kwargs, monkeypatch): + for k, v in container_kwargs.pop('env', {}).items(): + monkeypatch.setenv(k, v) with DockerContainer(**container_kwargs) as container: assignment = EnvironmentAssignmentBash("TEST=$(echo 42)") assert assignment.evaluated_value({}, container.environment_executor) == "42" From 15993834293f91fe27033b31edd520fc8eabdd5c Mon Sep 17 00:00:00 2001 From: joncrall Date: Sun, 26 Jun 2022 17:10:02 -0400 Subject: [PATCH 23/86] Cleanup --- cibuildwheel/docker_container.py | 23 ++++--------------- unit_test/docker_container_test.py | 37 ++++++++++++++++-------------- 2 files changed, 24 insertions(+), 36 deletions(-) diff --git a/cibuildwheel/docker_container.py b/cibuildwheel/docker_container.py index 0d010aee..cad594d8 100644 --- a/cibuildwheel/docker_container.py +++ b/cibuildwheel/docker_container.py @@ -55,7 +55,6 @@ class DockerContainer: simulate_32_bit: bool = False, cwd: Optional[PathOrStr] = None, container_engine: str = "docker", - env: Optional[Dict[str, str]] = None, ): if not docker_image: raise ValueError("Must have a non-empty docker image to run.") @@ -80,20 +79,6 @@ class DockerContainer: shell_args = ["linux32", "/bin/bash"] if self.simulate_32_bit else ["/bin/bash"] - # volume args are ignored on CircleCI - # For a discussion of if :Z should be included or not: - # https://github.com/pypa/cibuildwheel/pull/966#discussion_r906707824 - # https://stackoverflow.com/questions/35218194/what-is-z-flag-in-docker-containers-volumes-from-option/35222815#35222815 - # https://github.com/moby/moby/issues/30934 - # The Z option indicates that the bind mount content is private and - # unshared. Use extreme caution with these options. Bind-mounting a - # system directory such as /home or /usr with the Z option renders your - # host machine inoperable and you may need to relabel the host machine - # files by hand. - volume_args = ['--volume=/:/host'] - # volume_args = ['--volume=/:/host:Z'] - # volume_args = [] - subprocess.run( [ self.container_engine, @@ -101,8 +86,8 @@ class DockerContainer: "--env=CIBUILDWHEEL", f"--name={self.name}", "--interactive", + "--volume=/:/host", # ignored on CircleCI *network_args, - *volume_args, self.docker_image, *shell_args, ], @@ -126,13 +111,13 @@ class DockerContainer: self.bash_stdout = self.process.stdout # run a noop command to block until the container is responding - self.call(["/bin/true"], cwd="/") + self.call(["/bin/true"]) if self.cwd: # Although `docker create -w` does create the working dir if it # does not exist, podman does not. There does not seem to be a way # to setup a workdir for a container running in podman. - self.call(["mkdir", "-p", str(self.cwd)], cwd="/") + self.call(["mkdir", "-p", os.fspath(self.cwd)]) return self @@ -389,4 +374,4 @@ class DockerContainer: def shell_quote(path: PurePath) -> str: - return shlex.quote(str(path)) + return shlex.quote(os.fspath(path)) diff --git a/unit_test/docker_container_test.py b/unit_test/docker_container_test.py index 52603b5a..fac3dfdf 100644 --- a/unit_test/docker_container_test.py +++ b/unit_test/docker_container_test.py @@ -36,7 +36,7 @@ _STATE = { # @atexit.register -def _cleanup_tempdir(): +def _cleanup_podman_vfs_tempdir(): """ Cleans up any configuration written by :func:`basis_container_kwargs`. @@ -58,10 +58,6 @@ def _cleanup_tempdir(): # unless you fake a UID of 0. The package rootlesskit helps with that. if _STATE['using_podman']: subprocess.call(['podman', 'unshare', 'rm', '-rf', temp_test_dir.name]) - try: - temp_test_dir.cleanup() - except Exception as ex: - print(f"Issue cleaning up ex = {ex!r}") _STATE['temp_test_dir'] = None @@ -82,24 +78,31 @@ def basis_container_kwargs(): parameterized test. """ - if _STATE['temp_test_dir'] is None: - # Only setup the temp directory once for all tests - _STATE['temp_test_dir'] = tempfile.TemporaryDirectory(prefix="cibw_test_") - # Register the special cleanup hook after the temp directory is created - # to ensure that it runs before the temp directory logic runs (which - # will not handle cases where there is a fake root UID). - atexit.register(_cleanup_tempdir) - - temp_test_dir = _STATE['temp_test_dir'] - + # TODO: Pytest should be aware of if we are trying to test docker / podman + # or not HAVE_DOCKER = bool(shutil.which("docker")) HAVE_PODMAN = bool(shutil.which("podman")) - if HAVE_DOCKER: + REQUESTED_DOCKER = HAVE_DOCKER + REQUESTED_PODMAN = HAVE_PODMAN + + if _STATE['temp_test_dir'] is None: + # Only setup the temp directory once for all tests + _STATE['temp_test_dir'] = tempfile.TemporaryDirectory(prefix="cibw_test_") + if REQUESTED_PODMAN: + # Register the special cleanup hook after the temp directory is + # created to ensure that it runs before the temp directory logic + # runs (which will not handle cases where there is a fake root + # UID). + atexit.register(_cleanup_podman_vfs_tempdir) + + temp_test_dir = _STATE['temp_test_dir'] + + if REQUESTED_DOCKER: # Basic podman configuration yield {"container_engine": "docker", "docker_image": DEFAULT_IMAGE} - if HAVE_PODMAN: + if REQUESTED_PODMAN: # Basic podman usage _STATE['using_podman'] = True yield {"container_engine": "podman", "docker_image": DEFAULT_IMAGE} From 9401c90ddb06a5ef4b513c1011084c74e3076fe6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 26 Jun 2022 21:10:51 +0000 Subject: [PATCH 24/86] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- unit_test/docker_container_test.py | 40 +++++++++++++++--------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/unit_test/docker_container_test.py b/unit_test/docker_container_test.py index fac3dfdf..0854af5e 100644 --- a/unit_test/docker_container_test.py +++ b/unit_test/docker_container_test.py @@ -30,8 +30,8 @@ else: # A dictionary to make it easier to manipulate globals _STATE = { - 'temp_test_dir': None, - 'using_podman': False, + "temp_test_dir": None, + "using_podman": False, } @@ -52,13 +52,13 @@ def _cleanup_podman_vfs_tempdir(): References: .. [PodmanStoragePerms] https://podman.io/blogs/2018/10/03/podman-remove-content-homedir.html """ - temp_test_dir = _STATE['temp_test_dir'] + temp_test_dir = _STATE["temp_test_dir"] if temp_test_dir is not None: # When podman creates special directories, they cant be cleaned up # unless you fake a UID of 0. The package rootlesskit helps with that. - if _STATE['using_podman']: - subprocess.call(['podman', 'unshare', 'rm', '-rf', temp_test_dir.name]) - _STATE['temp_test_dir'] = None + if _STATE["using_podman"]: + subprocess.call(["podman", "unshare", "rm", "-rf", temp_test_dir.name]) + _STATE["temp_test_dir"] = None def basis_container_kwargs(): @@ -86,9 +86,9 @@ def basis_container_kwargs(): REQUESTED_DOCKER = HAVE_DOCKER REQUESTED_PODMAN = HAVE_PODMAN - if _STATE['temp_test_dir'] is None: + if _STATE["temp_test_dir"] is None: # Only setup the temp directory once for all tests - _STATE['temp_test_dir'] = tempfile.TemporaryDirectory(prefix="cibw_test_") + _STATE["temp_test_dir"] = tempfile.TemporaryDirectory(prefix="cibw_test_") if REQUESTED_PODMAN: # Register the special cleanup hook after the temp directory is # created to ensure that it runs before the temp directory logic @@ -96,7 +96,7 @@ def basis_container_kwargs(): # UID). atexit.register(_cleanup_podman_vfs_tempdir) - temp_test_dir = _STATE['temp_test_dir'] + temp_test_dir = _STATE["temp_test_dir"] if REQUESTED_DOCKER: # Basic podman configuration @@ -104,7 +104,7 @@ def basis_container_kwargs(): if REQUESTED_PODMAN: # Basic podman usage - _STATE['using_podman'] = True + _STATE["using_podman"] = True yield {"container_engine": "podman", "docker_image": DEFAULT_IMAGE} # VFS Podman usage (for the podman in docker use-case) @@ -182,7 +182,7 @@ def _setup_podman_vfs(dpath): @pytest.mark.docker @pytest.mark.parametrize("container_kwargs", basis_container_kwargs()) def test_simple(container_kwargs, monkeypatch): - for k, v in container_kwargs.pop('env', {}).items(): + for k, v in container_kwargs.pop("env", {}).items(): monkeypatch.setenv(k, v) with DockerContainer(**container_kwargs) as container: assert container.call(["echo", "hello"], capture_output=True) == "hello\n" @@ -191,7 +191,7 @@ def test_simple(container_kwargs, monkeypatch): @pytest.mark.docker @pytest.mark.parametrize("container_kwargs", basis_container_kwargs()) def test_no_lf(container_kwargs, monkeypatch): - for k, v in container_kwargs.pop('env', {}).items(): + for k, v in container_kwargs.pop("env", {}).items(): monkeypatch.setenv(k, v) with DockerContainer(**container_kwargs) as container: assert container.call(["printf", "hello"], capture_output=True) == "hello" @@ -200,7 +200,7 @@ def test_no_lf(container_kwargs, monkeypatch): @pytest.mark.docker @pytest.mark.parametrize("container_kwargs", basis_container_kwargs()) def test_debug_info(container_kwargs, monkeypatch): - for k, v in container_kwargs.pop('env', {}).items(): + for k, v in container_kwargs.pop("env", {}).items(): monkeypatch.setenv(k, v) container = DockerContainer(**container_kwargs) print(container.debug_info()) @@ -211,7 +211,7 @@ def test_debug_info(container_kwargs, monkeypatch): @pytest.mark.docker @pytest.mark.parametrize("container_kwargs", basis_container_kwargs()) def test_environment(container_kwargs, monkeypatch): - for k, v in container_kwargs.pop('env', {}).items(): + for k, v in container_kwargs.pop("env", {}).items(): monkeypatch.setenv(k, v) with DockerContainer(**container_kwargs) as container: assert ( @@ -233,7 +233,7 @@ def test_cwd(container_kwargs): @pytest.mark.docker @pytest.mark.parametrize("container_kwargs", basis_container_kwargs()) def test_container_removed(container_kwargs, monkeypatch): - for k, v in container_kwargs.pop('env', {}).items(): + for k, v in container_kwargs.pop("env", {}).items(): monkeypatch.setenv(k, v) with DockerContainer(**container_kwargs) as container: docker_containers_listing = subprocess.run( @@ -260,7 +260,7 @@ def test_container_removed(container_kwargs, monkeypatch): @pytest.mark.docker @pytest.mark.parametrize("container_kwargs", basis_container_kwargs()) def test_large_environment(container_kwargs, monkeypatch): - for k, v in container_kwargs.pop('env', {}).items(): + for k, v in container_kwargs.pop("env", {}).items(): monkeypatch.setenv(k, v) # max environment variable size is 128kB long_env_var_length = 127 * 1024 @@ -282,7 +282,7 @@ def test_large_environment(container_kwargs, monkeypatch): @pytest.mark.docker @pytest.mark.parametrize("container_kwargs", basis_container_kwargs()) def test_binary_output(container_kwargs, monkeypatch): - for k, v in container_kwargs.pop('env', {}).items(): + for k, v in container_kwargs.pop("env", {}).items(): monkeypatch.setenv(k, v) with DockerContainer(**container_kwargs) as container: # note: the below embedded snippets are in python2 @@ -336,7 +336,7 @@ def test_binary_output(container_kwargs, monkeypatch): @pytest.mark.docker @pytest.mark.parametrize("container_kwargs", basis_container_kwargs()) def test_file_operation(tmp_path: Path, container_kwargs, monkeypatch): - for k, v in container_kwargs.pop('env', {}).items(): + for k, v in container_kwargs.pop("env", {}).items(): monkeypatch.setenv(k, v) with DockerContainer(**container_kwargs) as container: # test copying a file in @@ -355,7 +355,7 @@ def test_file_operation(tmp_path: Path, container_kwargs, monkeypatch): @pytest.mark.docker @pytest.mark.parametrize("container_kwargs", basis_container_kwargs()) def test_dir_operations(tmp_path: Path, container_kwargs, monkeypatch): - for k, v in container_kwargs.pop('env', {}).items(): + for k, v in container_kwargs.pop("env", {}).items(): monkeypatch.setenv(k, v) with DockerContainer(**container_kwargs) as container: test_binary_data = bytes(random.randrange(256) for _ in range(1000)) @@ -388,7 +388,7 @@ def test_dir_operations(tmp_path: Path, container_kwargs, monkeypatch): @pytest.mark.docker @pytest.mark.parametrize("container_kwargs", basis_container_kwargs()) def test_environment_executor(container_kwargs, monkeypatch): - for k, v in container_kwargs.pop('env', {}).items(): + for k, v in container_kwargs.pop("env", {}).items(): monkeypatch.setenv(k, v) with DockerContainer(**container_kwargs) as container: assignment = EnvironmentAssignmentBash("TEST=$(echo 42)") From c68223b172a149617d0ed72f2cb771784107b8b4 Mon Sep 17 00:00:00 2001 From: joncrall Date: Sun, 26 Jun 2022 17:21:59 -0400 Subject: [PATCH 25/86] Make mypy happy --- unit_test/docker_container_test.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/unit_test/docker_container_test.py b/unit_test/docker_container_test.py index 0854af5e..de14ea38 100644 --- a/unit_test/docker_container_test.py +++ b/unit_test/docker_container_test.py @@ -7,9 +7,10 @@ import subprocess import tempfile import textwrap from pathlib import Path, PurePath, PurePosixPath +from typing import Dict, Optional, Union import pytest -import toml # type: ignore[import] +import toml from cibuildwheel.docker_container import DockerContainer from cibuildwheel.environment import EnvironmentAssignmentBash @@ -28,11 +29,9 @@ elif pm == "s390x": else: DEFAULT_IMAGE = "" -# A dictionary to make it easier to manipulate globals -_STATE = { - "temp_test_dir": None, - "using_podman": False, -} +# These globals will be manipulated +temp_test_dir: Optional[tempfile.TemporaryDirectory[str]] = None +using_podman = False # @atexit.register @@ -52,13 +51,14 @@ def _cleanup_podman_vfs_tempdir(): References: .. [PodmanStoragePerms] https://podman.io/blogs/2018/10/03/podman-remove-content-homedir.html """ - temp_test_dir = _STATE["temp_test_dir"] + global temp_test_dir + global using_podman if temp_test_dir is not None: - # When podman creates special directories, they cant be cleaned up + # When podman creates special directories, they can't be cleaned up # unless you fake a UID of 0. The package rootlesskit helps with that. - if _STATE["using_podman"]: + if using_podman: subprocess.call(["podman", "unshare", "rm", "-rf", temp_test_dir.name]) - _STATE["temp_test_dir"] = None + temp_test_dir = None def basis_container_kwargs(): @@ -77,6 +77,8 @@ def basis_container_kwargs(): Dict: a configuration passed as ``container_kwargs`` to each parameterized test. """ + global temp_test_dir + global using_podman # TODO: Pytest should be aware of if we are trying to test docker / podman # or not @@ -86,9 +88,9 @@ def basis_container_kwargs(): REQUESTED_DOCKER = HAVE_DOCKER REQUESTED_PODMAN = HAVE_PODMAN - if _STATE["temp_test_dir"] is None: + if temp_test_dir is None: # Only setup the temp directory once for all tests - _STATE["temp_test_dir"] = tempfile.TemporaryDirectory(prefix="cibw_test_") + temp_test_dir = tempfile.TemporaryDirectory(prefix="cibw_test_") if REQUESTED_PODMAN: # Register the special cleanup hook after the temp directory is # created to ensure that it runs before the temp directory logic @@ -96,15 +98,13 @@ def basis_container_kwargs(): # UID). atexit.register(_cleanup_podman_vfs_tempdir) - temp_test_dir = _STATE["temp_test_dir"] - if REQUESTED_DOCKER: # Basic podman configuration yield {"container_engine": "docker", "docker_image": DEFAULT_IMAGE} if REQUESTED_PODMAN: # Basic podman usage - _STATE["using_podman"] = True + using_podman = True yield {"container_engine": "podman", "docker_image": DEFAULT_IMAGE} # VFS Podman usage (for the podman in docker use-case) From 086ead0d6bc6a378d221dc217e8beadd56a43f82 Mon Sep 17 00:00:00 2001 From: joncrall Date: Sun, 26 Jun 2022 17:22:44 -0400 Subject: [PATCH 26/86] remove missing imports --- unit_test/docker_container_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unit_test/docker_container_test.py b/unit_test/docker_container_test.py index de14ea38..b4c1d390 100644 --- a/unit_test/docker_container_test.py +++ b/unit_test/docker_container_test.py @@ -7,7 +7,7 @@ import subprocess import tempfile import textwrap from pathlib import Path, PurePath, PurePosixPath -from typing import Dict, Optional, Union +from typing import Optional import pytest import toml From a86cabc71617d7fad65f0f9f8a46c71d8b5c74a7 Mon Sep 17 00:00:00 2001 From: joncrall Date: Sun, 26 Jun 2022 17:23:52 -0400 Subject: [PATCH 27/86] forgot to monkeypatch a test --- unit_test/docker_container_test.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/unit_test/docker_container_test.py b/unit_test/docker_container_test.py index b4c1d390..e9629382 100644 --- a/unit_test/docker_container_test.py +++ b/unit_test/docker_container_test.py @@ -224,7 +224,9 @@ def test_environment(container_kwargs, monkeypatch): @pytest.mark.docker @pytest.mark.parametrize("container_kwargs", basis_container_kwargs()) -def test_cwd(container_kwargs): +def test_cwd(container_kwargs, monkeypatch): + for k, v in container_kwargs.pop("env", {}).items(): + monkeypatch.setenv(k, v) with DockerContainer(cwd="/cibuildwheel/working_directory", **container_kwargs) as container: assert container.call(["pwd"], capture_output=True) == "/cibuildwheel/working_directory\n" assert container.call(["pwd"], capture_output=True, cwd="/opt") == "/opt\n" From fc0db9519855c158267a55bde9efdc767b0f3e18 Mon Sep 17 00:00:00 2001 From: joncrall Date: Sun, 26 Jun 2022 17:35:53 -0400 Subject: [PATCH 28/86] more mypy fixes --- .pre-commit-config.yaml | 1 + unit_test/docker_container_test.py | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 679254fd..e54c6d3b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -67,6 +67,7 @@ repos: - types-jinja2 - types-pyyaml - types-requests + - types-toml - bracex - dataclasses - id: mypy diff --git a/unit_test/docker_container_test.py b/unit_test/docker_container_test.py index e9629382..c6ac944f 100644 --- a/unit_test/docker_container_test.py +++ b/unit_test/docker_container_test.py @@ -7,7 +7,6 @@ import subprocess import tempfile import textwrap from pathlib import Path, PurePath, PurePosixPath -from typing import Optional import pytest import toml @@ -30,7 +29,7 @@ else: DEFAULT_IMAGE = "" # These globals will be manipulated -temp_test_dir: Optional[tempfile.TemporaryDirectory[str]] = None +temp_test_dir = None using_podman = False @@ -56,7 +55,7 @@ def _cleanup_podman_vfs_tempdir(): if temp_test_dir is not None: # When podman creates special directories, they can't be cleaned up # unless you fake a UID of 0. The package rootlesskit helps with that. - if using_podman: + if using_podman: # type: ignore[unreachable] subprocess.call(["podman", "unshare", "rm", "-rf", temp_test_dir.name]) temp_test_dir = None From 4bc5d9043021bbd9a0cd303d7ff6bba998f5294d Mon Sep 17 00:00:00 2001 From: "cibuildwheel-bot[bot]" <83877280+cibuildwheel-bot[bot]@users.noreply.github.com> Date: Mon, 27 Jun 2022 06:16:07 +0000 Subject: [PATCH 29/86] Update dependencies --- .../resources/constraints-python310.txt | 2 +- .../resources/constraints-python311.txt | 2 +- .../resources/constraints-python36.txt | 2 +- .../resources/constraints-python37.txt | 4 +- .../resources/constraints-python38.txt | 2 +- .../resources/constraints-python39.txt | 2 +- cibuildwheel/resources/constraints.txt | 2 +- .../resources/pinned_docker_images.cfg | 64 +++--- cibuildwheel/resources/virtualenv.toml | 4 +- docs/working-examples.md | 202 +++++++++--------- 10 files changed, 143 insertions(+), 143 deletions(-) diff --git a/cibuildwheel/resources/constraints-python310.txt b/cibuildwheel/resources/constraints-python310.txt index 86e4bdf0..6f02809e 100644 --- a/cibuildwheel/resources/constraints-python310.txt +++ b/cibuildwheel/resources/constraints-python310.txt @@ -16,7 +16,7 @@ six==1.16.0 # via virtualenv typing-extensions==4.2.0 # via delocate -virtualenv==20.14.1 +virtualenv==20.15.0 # via -r cibuildwheel/resources/constraints.in wheel==0.37.1 # via diff --git a/cibuildwheel/resources/constraints-python311.txt b/cibuildwheel/resources/constraints-python311.txt index beaa5107..5d69e081 100644 --- a/cibuildwheel/resources/constraints-python311.txt +++ b/cibuildwheel/resources/constraints-python311.txt @@ -16,7 +16,7 @@ six==1.16.0 # via virtualenv typing-extensions==4.2.0 # via delocate -virtualenv==20.14.1 +virtualenv==20.15.0 # via -r cibuildwheel/resources/constraints.in wheel==0.37.1 # via diff --git a/cibuildwheel/resources/constraints-python36.txt b/cibuildwheel/resources/constraints-python36.txt index 9ca0fd11..e5bc034c 100644 --- a/cibuildwheel/resources/constraints-python36.txt +++ b/cibuildwheel/resources/constraints-python36.txt @@ -22,7 +22,7 @@ typing-extensions==4.1.1 # via # delocate # importlib-metadata -virtualenv==20.14.1 +virtualenv==20.15.0 # via -r cibuildwheel/resources/constraints.in wheel==0.37.1 # via diff --git a/cibuildwheel/resources/constraints-python37.txt b/cibuildwheel/resources/constraints-python37.txt index 25a3a1d6..93118618 100644 --- a/cibuildwheel/resources/constraints-python37.txt +++ b/cibuildwheel/resources/constraints-python37.txt @@ -10,7 +10,7 @@ distlib==0.3.4 # via virtualenv filelock==3.7.1 # via virtualenv -importlib-metadata==4.11.4 +importlib-metadata==4.12.0 # via virtualenv platformdirs==2.5.2 # via virtualenv @@ -20,7 +20,7 @@ typing-extensions==4.2.0 # via # delocate # importlib-metadata -virtualenv==20.14.1 +virtualenv==20.15.0 # via -r cibuildwheel/resources/constraints.in wheel==0.37.1 # via diff --git a/cibuildwheel/resources/constraints-python38.txt b/cibuildwheel/resources/constraints-python38.txt index a9e3d2c5..3de94015 100644 --- a/cibuildwheel/resources/constraints-python38.txt +++ b/cibuildwheel/resources/constraints-python38.txt @@ -16,7 +16,7 @@ six==1.16.0 # via virtualenv typing-extensions==4.2.0 # via delocate -virtualenv==20.14.1 +virtualenv==20.15.0 # via -r cibuildwheel/resources/constraints.in wheel==0.37.1 # via diff --git a/cibuildwheel/resources/constraints-python39.txt b/cibuildwheel/resources/constraints-python39.txt index e5134e9f..8c407bb0 100644 --- a/cibuildwheel/resources/constraints-python39.txt +++ b/cibuildwheel/resources/constraints-python39.txt @@ -16,7 +16,7 @@ six==1.16.0 # via virtualenv typing-extensions==4.2.0 # via delocate -virtualenv==20.14.1 +virtualenv==20.15.0 # via -r cibuildwheel/resources/constraints.in wheel==0.37.1 # via diff --git a/cibuildwheel/resources/constraints.txt b/cibuildwheel/resources/constraints.txt index e5134e9f..8c407bb0 100644 --- a/cibuildwheel/resources/constraints.txt +++ b/cibuildwheel/resources/constraints.txt @@ -16,7 +16,7 @@ six==1.16.0 # via virtualenv typing-extensions==4.2.0 # via delocate -virtualenv==20.14.1 +virtualenv==20.15.0 # via -r cibuildwheel/resources/constraints.in wheel==0.37.1 # via diff --git a/cibuildwheel/resources/pinned_docker_images.cfg b/cibuildwheel/resources/pinned_docker_images.cfg index ecb061c4..9d8e6297 100644 --- a/cibuildwheel/resources/pinned_docker_images.cfg +++ b/cibuildwheel/resources/pinned_docker_images.cfg @@ -1,48 +1,48 @@ [x86_64] -manylinux1 = quay.io/pypa/manylinux1_x86_64:2022-06-19-48acfad -manylinux2010 = quay.io/pypa/manylinux2010_x86_64:2022-06-20-d72b943 -manylinux2014 = quay.io/pypa/manylinux2014_x86_64:2022-06-20-d72b943 -manylinux_2_24 = quay.io/pypa/manylinux_2_24_x86_64:2022-06-20-d72b943 -manylinux_2_28 = quay.io/pypa/manylinux_2_28_x86_64:2022-06-20-d72b943 -musllinux_1_1 = quay.io/pypa/musllinux_1_1_x86_64:2022-06-20-d72b943 +manylinux1 = quay.io/pypa/manylinux1_x86_64:2022-06-26-ddecca8 +manylinux2010 = quay.io/pypa/manylinux2010_x86_64:2022-06-26-9a2ca4b +manylinux2014 = quay.io/pypa/manylinux2014_x86_64:2022-06-26-9a2ca4b +manylinux_2_24 = quay.io/pypa/manylinux_2_24_x86_64:2022-06-26-9a2ca4b +manylinux_2_28 = quay.io/pypa/manylinux_2_28_x86_64:2022-06-26-9a2ca4b +musllinux_1_1 = quay.io/pypa/musllinux_1_1_x86_64:2022-06-26-9a2ca4b [i686] -manylinux1 = quay.io/pypa/manylinux1_i686:2022-06-19-48acfad -manylinux2010 = quay.io/pypa/manylinux2010_i686:2022-06-20-d72b943 -manylinux2014 = quay.io/pypa/manylinux2014_i686:2022-06-20-d72b943 -manylinux_2_24 = quay.io/pypa/manylinux_2_24_i686:2022-06-20-d72b943 -musllinux_1_1 = quay.io/pypa/musllinux_1_1_i686:2022-06-20-d72b943 +manylinux1 = quay.io/pypa/manylinux1_i686:2022-06-26-ddecca8 +manylinux2010 = quay.io/pypa/manylinux2010_i686:2022-06-26-9a2ca4b +manylinux2014 = quay.io/pypa/manylinux2014_i686:2022-06-26-9a2ca4b +manylinux_2_24 = quay.io/pypa/manylinux_2_24_i686:2022-06-26-9a2ca4b +musllinux_1_1 = quay.io/pypa/musllinux_1_1_i686:2022-06-26-9a2ca4b [pypy_x86_64] -manylinux2010 = quay.io/pypa/manylinux2010_x86_64:2022-06-20-d72b943 -manylinux2014 = quay.io/pypa/manylinux2014_x86_64:2022-06-20-d72b943 -manylinux_2_24 = quay.io/pypa/manylinux_2_24_x86_64:2022-06-20-d72b943 -manylinux_2_28 = quay.io/pypa/manylinux_2_28_x86_64:2022-06-20-d72b943 +manylinux2010 = quay.io/pypa/manylinux2010_x86_64:2022-06-26-9a2ca4b +manylinux2014 = quay.io/pypa/manylinux2014_x86_64:2022-06-26-9a2ca4b +manylinux_2_24 = quay.io/pypa/manylinux_2_24_x86_64:2022-06-26-9a2ca4b +manylinux_2_28 = quay.io/pypa/manylinux_2_28_x86_64:2022-06-26-9a2ca4b [pypy_i686] -manylinux2010 = quay.io/pypa/manylinux2010_i686:2022-06-20-d72b943 -manylinux2014 = quay.io/pypa/manylinux2014_i686:2022-06-20-d72b943 -manylinux_2_24 = quay.io/pypa/manylinux_2_24_i686:2022-06-20-d72b943 +manylinux2010 = quay.io/pypa/manylinux2010_i686:2022-06-26-9a2ca4b +manylinux2014 = quay.io/pypa/manylinux2014_i686:2022-06-26-9a2ca4b +manylinux_2_24 = quay.io/pypa/manylinux_2_24_i686:2022-06-26-9a2ca4b [aarch64] -manylinux2014 = quay.io/pypa/manylinux2014_aarch64:2022-06-20-d72b943 -manylinux_2_24 = quay.io/pypa/manylinux_2_24_aarch64:2022-06-20-d72b943 -manylinux_2_28 = quay.io/pypa/manylinux_2_28_aarch64:2022-06-20-d72b943 -musllinux_1_1 = quay.io/pypa/musllinux_1_1_aarch64:2022-06-20-d72b943 +manylinux2014 = quay.io/pypa/manylinux2014_aarch64:2022-06-26-9a2ca4b +manylinux_2_24 = quay.io/pypa/manylinux_2_24_aarch64:2022-06-26-9a2ca4b +manylinux_2_28 = quay.io/pypa/manylinux_2_28_aarch64:2022-06-26-9a2ca4b +musllinux_1_1 = quay.io/pypa/musllinux_1_1_aarch64:2022-06-26-9a2ca4b [ppc64le] -manylinux2014 = quay.io/pypa/manylinux2014_ppc64le:2022-06-20-d72b943 -manylinux_2_24 = quay.io/pypa/manylinux_2_24_ppc64le:2022-06-20-d72b943 -manylinux_2_28 = quay.io/pypa/manylinux_2_28_ppc64le:2022-06-20-d72b943 -musllinux_1_1 = quay.io/pypa/musllinux_1_1_ppc64le:2022-06-20-d72b943 +manylinux2014 = quay.io/pypa/manylinux2014_ppc64le:2022-06-26-9a2ca4b +manylinux_2_24 = quay.io/pypa/manylinux_2_24_ppc64le:2022-06-26-9a2ca4b +manylinux_2_28 = quay.io/pypa/manylinux_2_28_ppc64le:2022-06-26-9a2ca4b +musllinux_1_1 = quay.io/pypa/musllinux_1_1_ppc64le:2022-06-26-9a2ca4b [s390x] -manylinux2014 = quay.io/pypa/manylinux2014_s390x:2022-06-20-d72b943 -manylinux_2_24 = quay.io/pypa/manylinux_2_24_s390x:2022-06-20-d72b943 -musllinux_1_1 = quay.io/pypa/musllinux_1_1_s390x:2022-06-20-d72b943 +manylinux2014 = quay.io/pypa/manylinux2014_s390x:2022-06-26-9a2ca4b +manylinux_2_24 = quay.io/pypa/manylinux_2_24_s390x:2022-06-26-9a2ca4b +musllinux_1_1 = quay.io/pypa/musllinux_1_1_s390x:2022-06-26-9a2ca4b [pypy_aarch64] -manylinux2014 = quay.io/pypa/manylinux2014_aarch64:2022-06-20-d72b943 -manylinux_2_24 = quay.io/pypa/manylinux_2_24_aarch64:2022-06-20-d72b943 -manylinux_2_28 = quay.io/pypa/manylinux_2_28_aarch64:2022-06-20-d72b943 +manylinux2014 = quay.io/pypa/manylinux2014_aarch64:2022-06-26-9a2ca4b +manylinux_2_24 = quay.io/pypa/manylinux_2_24_aarch64:2022-06-26-9a2ca4b +manylinux_2_28 = quay.io/pypa/manylinux_2_28_aarch64:2022-06-26-9a2ca4b diff --git a/cibuildwheel/resources/virtualenv.toml b/cibuildwheel/resources/virtualenv.toml index 2296e59f..01489be2 100644 --- a/cibuildwheel/resources/virtualenv.toml +++ b/cibuildwheel/resources/virtualenv.toml @@ -1,2 +1,2 @@ -version = "20.14.1" -url = "https://github.com/pypa/get-virtualenv/blob/20.14.1/public/virtualenv.pyz?raw=true" +version = "20.15.0" +url = "https://github.com/pypa/get-virtualenv/blob/20.15.0/public/virtualenv.pyz?raw=true" diff --git a/docs/working-examples.md b/docs/working-examples.md index 0fbf1f55..a478ee7f 100644 --- a/docs/working-examples.md +++ b/docs/working-examples.md @@ -75,8 +75,8 @@ title: Working examples | [pybind11 python_example][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Example pybind11 module built with a Python-based build system | | [dd-trace-py][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Uses custom alternate arch emulation on GitHub | | [sourmash][] | ![github icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | Quickly search, compare, and analyze genomic and metagenomic data sets. | -| [time-machine][] | ![github icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | Time mocking library using only the CPython C API. | | [CTranslate2][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Includes libraries from the [Intel oneAPI toolkit](https://www.intel.com/content/www/us/en/developer/tools/oneapi/base-toolkit.html) and CUDA kernels compiled for multiple GPU architectures. | +| [time-machine][] | ![github icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | Time mocking library using only the CPython C API. | | [cyvcf2][] | ![github icon][] | ![apple icon][] ![linux icon][] | cython + htslib == fast VCF and BCF processing | | [matrixprofile][] | ![travisci icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | A Python 3 library making time series data mining tasks, utilizing matrix profile algorithms, accessible to everyone. | | [abess][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | A fast best-subset selection library. It uses cibuildwheel to build a large project with C++ extensions. | @@ -86,8 +86,8 @@ title: Working examples | [PyGLM][] | ![github icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | Fast OpenGL Mathematics (GLM) for Python | | [boost-histogram][] | ![github icon][] ![travisci icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Supports full range of wheels, including PyPy and alternate archs. | | [bx-python][] | ![travisci icon][] | ![apple icon][] ![linux icon][] | A library that includes Cython extensions. | -| [TgCrypto][] | ![travisci icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Includes a Windows Travis build. | | [iDynTree][] | ![github icon][] | ![linux icon][] | Uses manylinux_2_24 | +| [TgCrypto][] | ![travisci icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Includes a Windows Travis build. | | [Python-WebRTC][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | a Python extension that provides bindings to WebRTC M92 | | [pybase64][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Fast Base64 encoding/decoding in Python | | [Arbor][] | ![github icon][] | ![apple icon][] ![linux icon][] | Arbor is a multi-compartment neuron simulation library; compatible with next-generation accelerators; best-practices applied to research software; focused on community-driven development. Includes a [small script](https://github.com/arbor-sim/arbor/blob/master/scripts/patchwheel.py) patching `rpath` in bundled libraries. | @@ -175,8 +175,8 @@ title: Working examples [pybind11 python_example]: https://github.com/pybind/python_example [dd-trace-py]: https://github.com/DataDog/dd-trace-py [sourmash]: https://github.com/dib-lab/sourmash -[time-machine]: https://github.com/adamchainz/time-machine [CTranslate2]: https://github.com/OpenNMT/CTranslate2 +[time-machine]: https://github.com/adamchainz/time-machine [cyvcf2]: https://github.com/brentp/cyvcf2 [matrixprofile]: https://github.com/matrix-profile-foundation/matrixprofile [abess]: https://github.com/abess-team/abess @@ -186,8 +186,8 @@ title: Working examples [PyGLM]: https://github.com/Zuzu-Typ/PyGLM [boost-histogram]: https://github.com/scikit-hep/boost-histogram [bx-python]: https://github.com/bxlab/bx-python -[TgCrypto]: https://github.com/pyrogram/tgcrypto [iDynTree]: https://github.com/robotology/idyntree +[TgCrypto]: https://github.com/pyrogram/tgcrypto [Python-WebRTC]: https://github.com/MarshalX/python-webrtc [pybase64]: https://github.com/mayeut/pybase64 [Arbor]: https://github.com/arbor-sim/arbor @@ -218,105 +218,105 @@ title: Working examples [apple icon]: data/readme_icons/apple.svg [linux icon]: data/readme_icons/linux.svg - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - - - - - - + + + + + + + + + From 8d389467be139f4b0493f8371625c62344cc6ee6 Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Mon, 27 Jun 2022 14:48:33 +0100 Subject: [PATCH 30/86] Switch to the simpler podman cp implementation The trick is "{src_path}/.". See https://docs.podman.io/en/latest/markdown/podman-cp.1.html#description --- cibuildwheel/docker_container.py | 33 ++------------------------------ 1 file changed, 2 insertions(+), 31 deletions(-) diff --git a/cibuildwheel/docker_container.py b/cibuildwheel/docker_container.py index cad594d8..f62ee557 100644 --- a/cibuildwheel/docker_container.py +++ b/cibuildwheel/docker_container.py @@ -192,45 +192,16 @@ class DockerContainer: # note: we assume from_path is a dir to_path.mkdir(parents=True, exist_ok=True) - TRY_SIMPLE_CP = 0 - if TRY_SIMPLE_CP: + if self.container_engine == "podman": # There is a bug in docker that prevents this simple implementation # from working https://github.com/moby/moby/issues/38995 - # It seems to also not workin podman as well - command = f"{self.container_engine} cp {self.name}:{shell_quote(from_path)} {shell_quote(to_path)}" + command = f"{self.container_engine} cp {self.name}:{shell_quote(from_path)}/. {shell_quote(to_path)}" subprocess.run( command, shell=True, check=True, cwd=to_path, ) - elif self.container_engine == "podman": - # The copy out logic that works for docker does not seem to - # translate to podman, which seems to need the steps spelled out - # more explicitly. - command = f"{self.container_engine} exec -i {self.name} tar -cC {shell_quote(from_path)} -f /tmp/output-{self.name}.tar ." - subprocess.run( - command, - shell=True, - check=True, - cwd=to_path, - ) - - command = f"{self.container_engine} cp {self.name}:/tmp/output-{self.name}.tar output-{self.name}.tar" - subprocess.run( - command, - shell=True, - check=True, - cwd=to_path, - ) - command = f"tar -xvf output-{self.name}.tar" - subprocess.run( - command, - shell=True, - check=True, - cwd=to_path, - ) - os.unlink(to_path / f"output-{self.name}.tar") elif self.container_engine == "docker": command = f"{self.container_engine} exec -i {self.name} tar -cC {shell_quote(from_path)} -f - . | tar -xf -" subprocess.run( From d9b4644286a9b41172b15fcd2a8b40f16c851dd6 Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Mon, 27 Jun 2022 15:23:50 +0100 Subject: [PATCH 31/86] Don't need shell for this command --- cibuildwheel/docker_container.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cibuildwheel/docker_container.py b/cibuildwheel/docker_container.py index f62ee557..de41ded9 100644 --- a/cibuildwheel/docker_container.py +++ b/cibuildwheel/docker_container.py @@ -195,10 +195,13 @@ class DockerContainer: if self.container_engine == "podman": # There is a bug in docker that prevents this simple implementation # from working https://github.com/moby/moby/issues/38995 - command = f"{self.container_engine} cp {self.name}:{shell_quote(from_path)}/. {shell_quote(to_path)}" subprocess.run( - command, - shell=True, + [ + self.container_engine, + "cp", + f"{self.name}:{from_path}/.", + str(to_path), + ], check=True, cwd=to_path, ) From 6a371aca73bba6bf37099917a8e0551b8c4f7869 Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Mon, 27 Jun 2022 16:45:27 +0100 Subject: [PATCH 32/86] Refactor the tests to use --run-docker and --run-podman Simplified test setup using a parameterised fixture. The VFS test is now just a single test that handles its own clean up. --- unit_test/conftest.py | 15 +- unit_test/docker_container_test.py | 349 +++++++++++------------------ 2 files changed, 138 insertions(+), 226 deletions(-) diff --git a/unit_test/conftest.py b/unit_test/conftest.py index 4e22853a..cbfdbb72 100644 --- a/unit_test/conftest.py +++ b/unit_test/conftest.py @@ -8,20 +8,7 @@ MOCK_PACKAGE_DIR = Path("some_package_dir") def pytest_addoption(parser): parser.addoption("--run-docker", action="store_true", default=False, help="run docker tests") - - -def pytest_configure(config): - config.addinivalue_line("markers", "docker: mark test requiring docker to run") - - -def pytest_collection_modifyitems(config, items): - if config.getoption("--run-docker"): - # --run-docker given in cli: do not skip container tests - return - skip_docker = pytest.mark.skip(reason="need --run-docker option to run") - for item in items: - if "docker" in item.keywords: - item.add_marker(skip_docker) + parser.addoption("--run-podman", action="store_true", default=False, help="run podman tests") @pytest.fixture diff --git a/unit_test/docker_container_test.py b/unit_test/docker_container_test.py index c6ac944f..d8d1f7fb 100644 --- a/unit_test/docker_container_test.py +++ b/unit_test/docker_container_test.py @@ -4,6 +4,7 @@ import platform import random import shutil import subprocess +from tabnanny import check import tempfile import textwrap from pathlib import Path, PurePath, PurePosixPath @@ -14,6 +15,8 @@ import toml from cibuildwheel.docker_container import DockerContainer from cibuildwheel.environment import EnvironmentAssignmentBash +# Test utilities + # for these tests we use manylinux2014 images, because they're available on # multi architectures and include python3.8 pm = platform.machine() @@ -28,191 +31,44 @@ elif pm == "s390x": else: DEFAULT_IMAGE = "" -# These globals will be manipulated -temp_test_dir = None -using_podman = False + +@pytest.fixture(params=["docker", "podman"]) +def container_engine(request): + if request.param == "docker" and not request.config.getoption("--run-docker"): + pytest.skip("need --run-docker option to run") + if request.param == "podman" and not request.config.getoption("--run-podman"): + pytest.skip("need --run-podman option to run") + return request.param -# @atexit.register -def _cleanup_podman_vfs_tempdir(): - """ - Cleans up any configuration written by :func:`basis_container_kwargs`. - - For podman tests, the user is not given write permissions by default in new - directories. As a workaround chown them before trying to delete them. - - It may be possible to handle this more cleanly in pytest itself, but using - atexit works well enough for now. - - The reason why permission errors occur on podman is documented in - [PodmanStoragePerms]_. - - References: - .. [PodmanStoragePerms] https://podman.io/blogs/2018/10/03/podman-remove-content-homedir.html - """ - global temp_test_dir - global using_podman - if temp_test_dir is not None: - # When podman creates special directories, they can't be cleaned up - # unless you fake a UID of 0. The package rootlesskit helps with that. - if using_podman: # type: ignore[unreachable] - subprocess.call(["podman", "unshare", "rm", "-rf", temp_test_dir.name]) - temp_test_dir = None +# Tests -def basis_container_kwargs(): - """ - Generate keyword args that can be passed to to :class:`DockerContainer`. - - This is used with :func:`pytest.mark.parametrize` to run each test with - different configurations of each supported containers engine. - - For docker we test the default configuration. - - For podman we test the default configuration and a configuration with VFS - (virtual file system) enabled as the storage driver. - - Yields: - Dict: a configuration passed as ``container_kwargs`` to each - parameterized test. - """ - global temp_test_dir - global using_podman - - # TODO: Pytest should be aware of if we are trying to test docker / podman - # or not - HAVE_DOCKER = bool(shutil.which("docker")) - HAVE_PODMAN = bool(shutil.which("podman")) - - REQUESTED_DOCKER = HAVE_DOCKER - REQUESTED_PODMAN = HAVE_PODMAN - - if temp_test_dir is None: - # Only setup the temp directory once for all tests - temp_test_dir = tempfile.TemporaryDirectory(prefix="cibw_test_") - if REQUESTED_PODMAN: - # Register the special cleanup hook after the temp directory is - # created to ensure that it runs before the temp directory logic - # runs (which will not handle cases where there is a fake root - # UID). - atexit.register(_cleanup_podman_vfs_tempdir) - - if REQUESTED_DOCKER: - # Basic podman configuration - yield {"container_engine": "docker", "docker_image": DEFAULT_IMAGE} - - if REQUESTED_PODMAN: - # Basic podman usage - using_podman = True - yield {"container_engine": "podman", "docker_image": DEFAULT_IMAGE} - - # VFS Podman usage (for the podman in docker use-case) - oci_environ = _setup_podman_vfs(temp_test_dir.name) - yield { - "container_engine": "podman", - "docker_image": DEFAULT_IMAGE, - "env": oci_environ, - } - - -def _setup_podman_vfs(dpath): - """ - Setup the filesystem and environment variables for the VFS podman test - """ - dpath = Path(dpath) - # This requires that we write configuration files and point to them - # with environment variables before we run podman - # https://github.com/containers/common/blob/main/docs/containers.conf.5.md - vfs_containers_conf_data = { - "containers": { - "default_capabilities": [ - "CHOWN", - "DAC_OVERRIDE", - "FOWNER", - "FSETID", - "KILL", - "NET_BIND_SERVICE", - "SETFCAP", - "SETGID", - "SETPCAP", - "SETUID", - "SYS_CHROOT", - ] - }, - "engine": {"cgroup_manager": "cgroupfs", "events_logger": "file"}, - } - # https://github.com/containers/storage/blob/main/docs/containers-storage.conf.5.md - storage_root = dpath / ".local/share/containers/vfs-storage" - run_root = dpath / ".local/share/containers/vfs-runroot" - storage_root.mkdir(parents=True, exist_ok=True) - run_root.mkdir(parents=True, exist_ok=True) - vfs_containers_storage_conf_data = { - "storage": { - "driver": "vfs", - "graphroot": os.fspath(storage_root), - "runroot": os.fspath(run_root), - "rootless_storage_path": os.fspath(storage_root), - "options": { - # "remap-user": "containers", - "aufs": {"mountopt": "rw"}, - "overlay": {"mountopt": "rw", "force_mask": "shared"}, - # "vfs": {"ignore_chown_errors": "true"}, - }, - } - } - vfs_containers_conf_fpath = dpath / "temp_vfs_containers.conf" - vfs_containers_storage_conf_fpath = dpath / "temp_vfs_containers_storage.conf" - with open(vfs_containers_conf_fpath, "w") as file: - toml.dump(vfs_containers_conf_data, file) - - with open(vfs_containers_storage_conf_fpath, "w") as file: - toml.dump(vfs_containers_storage_conf_data, file) - - oci_environ = os.environ.copy() - oci_environ.update( - { - "CONTAINERS_CONF": os.fspath(vfs_containers_conf_fpath), - "CONTAINERS_STORAGE_CONF": os.fspath(vfs_containers_storage_conf_fpath), - } - ) - return oci_environ - - -@pytest.mark.docker -@pytest.mark.parametrize("container_kwargs", basis_container_kwargs()) -def test_simple(container_kwargs, monkeypatch): - for k, v in container_kwargs.pop("env", {}).items(): - monkeypatch.setenv(k, v) - with DockerContainer(**container_kwargs) as container: +def test_simple(container_engine): + with DockerContainer( + container_engine=container_engine, docker_image=DEFAULT_IMAGE + ) as container: assert container.call(["echo", "hello"], capture_output=True) == "hello\n" -@pytest.mark.docker -@pytest.mark.parametrize("container_kwargs", basis_container_kwargs()) -def test_no_lf(container_kwargs, monkeypatch): - for k, v in container_kwargs.pop("env", {}).items(): - monkeypatch.setenv(k, v) - with DockerContainer(**container_kwargs) as container: +def test_no_lf(container_engine): + with DockerContainer( + container_engine=container_engine, docker_image=DEFAULT_IMAGE + ) as container: assert container.call(["printf", "hello"], capture_output=True) == "hello" -@pytest.mark.docker -@pytest.mark.parametrize("container_kwargs", basis_container_kwargs()) -def test_debug_info(container_kwargs, monkeypatch): - for k, v in container_kwargs.pop("env", {}).items(): - monkeypatch.setenv(k, v) - container = DockerContainer(**container_kwargs) +def test_debug_info(container_engine): + container = DockerContainer(container_engine=container_engine, docker_image=DEFAULT_IMAGE) print(container.debug_info()) with container: pass -@pytest.mark.docker -@pytest.mark.parametrize("container_kwargs", basis_container_kwargs()) -def test_environment(container_kwargs, monkeypatch): - for k, v in container_kwargs.pop("env", {}).items(): - monkeypatch.setenv(k, v) - with DockerContainer(**container_kwargs) as container: +def test_environment(container_engine): + with DockerContainer( + container_engine=container_engine, docker_image=DEFAULT_IMAGE + ) as container: assert ( container.call( ["sh", "-c", "echo $TEST_VAR"], env={"TEST_VAR": "1"}, capture_output=True @@ -221,22 +77,20 @@ def test_environment(container_kwargs, monkeypatch): ) -@pytest.mark.docker -@pytest.mark.parametrize("container_kwargs", basis_container_kwargs()) -def test_cwd(container_kwargs, monkeypatch): - for k, v in container_kwargs.pop("env", {}).items(): - monkeypatch.setenv(k, v) - with DockerContainer(cwd="/cibuildwheel/working_directory", **container_kwargs) as container: +def test_cwd(container_engine): + with DockerContainer( + container_engine=container_engine, + docker_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" -@pytest.mark.docker -@pytest.mark.parametrize("container_kwargs", basis_container_kwargs()) -def test_container_removed(container_kwargs, monkeypatch): - for k, v in container_kwargs.pop("env", {}).items(): - monkeypatch.setenv(k, v) - with DockerContainer(**container_kwargs) as container: +def test_container_removed(container_engine): + with DockerContainer( + container_engine=container_engine, docker_image=DEFAULT_IMAGE + ) as container: docker_containers_listing = subprocess.run( f"{container.container_engine} container ls", shell=True, @@ -258,11 +112,7 @@ def test_container_removed(container_kwargs, monkeypatch): assert old_container_name not in docker_containers_listing -@pytest.mark.docker -@pytest.mark.parametrize("container_kwargs", basis_container_kwargs()) -def test_large_environment(container_kwargs, monkeypatch): - for k, v in container_kwargs.pop("env", {}).items(): - monkeypatch.setenv(k, v) +def test_large_environment(container_engine): # max environment variable size is 128kB long_env_var_length = 127 * 1024 large_environment = { @@ -272,7 +122,9 @@ def test_large_environment(container_kwargs, monkeypatch): "d": "0" * long_env_var_length, } - with DockerContainer(**container_kwargs) as container: + with DockerContainer( + container_engine=container_engine, docker_image=DEFAULT_IMAGE + ) as container: # check the length of d assert ( container.call(["sh", "-c", "echo ${#d}"], env=large_environment, capture_output=True) @@ -280,12 +132,10 @@ def test_large_environment(container_kwargs, monkeypatch): ) -@pytest.mark.docker -@pytest.mark.parametrize("container_kwargs", basis_container_kwargs()) -def test_binary_output(container_kwargs, monkeypatch): - for k, v in container_kwargs.pop("env", {}).items(): - monkeypatch.setenv(k, v) - with DockerContainer(**container_kwargs) as container: +def test_binary_output(container_engine): + with DockerContainer( + container_engine=container_engine, docker_image=DEFAULT_IMAGE + ) as container: # note: the below embedded snippets are in python2 # check that we can pass though arbitrary binary data without erroring @@ -334,12 +184,10 @@ def test_binary_output(container_kwargs, monkeypatch): assert output == binary_data_string -@pytest.mark.docker -@pytest.mark.parametrize("container_kwargs", basis_container_kwargs()) -def test_file_operation(tmp_path: Path, container_kwargs, monkeypatch): - for k, v in container_kwargs.pop("env", {}).items(): - monkeypatch.setenv(k, v) - with DockerContainer(**container_kwargs) as container: +def test_file_operation(tmp_path: Path, container_engine): + with DockerContainer( + container_engine=container_engine, docker_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" @@ -353,12 +201,10 @@ def test_file_operation(tmp_path: Path, container_kwargs, monkeypatch): assert test_binary_data == bytes(output, encoding="utf8", errors="surrogateescape") -@pytest.mark.docker -@pytest.mark.parametrize("container_kwargs", basis_container_kwargs()) -def test_dir_operations(tmp_path: Path, container_kwargs, monkeypatch): - for k, v in container_kwargs.pop("env", {}).items(): - monkeypatch.setenv(k, v) - with DockerContainer(**container_kwargs) as container: +def test_dir_operations(tmp_path: Path, container_engine): + with DockerContainer( + container_engine=container_engine, docker_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) @@ -386,11 +232,90 @@ def test_dir_operations(tmp_path: Path, container_kwargs, monkeypatch): assert test_binary_data == (new_test_dir / "test.dat").read_bytes() -@pytest.mark.docker -@pytest.mark.parametrize("container_kwargs", basis_container_kwargs()) -def test_environment_executor(container_kwargs, monkeypatch): - for k, v in container_kwargs.pop("env", {}).items(): - monkeypatch.setenv(k, v) - with DockerContainer(**container_kwargs) as container: +def test_environment_executor(container_engine): + with DockerContainer( + container_engine=container_engine, docker_image=DEFAULT_IMAGE + ) as container: assignment = EnvironmentAssignmentBash("TEST=$(echo 42)") assert assignment.evaluated_value({}, container.environment_executor) == "42" + + +def test_podman_vfs(container_engine, tmp_path: Path, monkeypatch): + # Tests podman VFS, for the podman in docker use-case + if container_engine != "podman": + pytest.skip("podman is the only supported container engine for this test") + + # create the VFS configuration + vfs_path = tmp_path / "podman_vfs" + vfs_path.mkdir() + + # This requires that we write configuration files and point to them + # with environment variables before we run podman + # https://github.com/containers/common/blob/main/docs/containers.conf.5.md + vfs_containers_conf_data = { + "containers": { + "default_capabilities": [ + "CHOWN", + "DAC_OVERRIDE", + "FOWNER", + "FSETID", + "KILL", + "NET_BIND_SERVICE", + "SETFCAP", + "SETGID", + "SETPCAP", + "SETUID", + "SYS_CHROOT", + ] + }, + "engine": {"cgroup_manager": "cgroupfs", "events_logger": "file"}, + } + # https://github.com/containers/storage/blob/main/docs/containers-storage.conf.5.md + storage_root = vfs_path / ".local/share/containers/vfs-storage" + run_root = vfs_path / ".local/share/containers/vfs-runroot" + storage_root.mkdir(parents=True, exist_ok=True) + run_root.mkdir(parents=True, exist_ok=True) + vfs_containers_storage_conf_data = { + "storage": { + "driver": "vfs", + "graphroot": os.fspath(storage_root), + "runroot": os.fspath(run_root), + "rootless_storage_path": os.fspath(storage_root), + "options": { + # "remap-user": "containers", + "aufs": {"mountopt": "rw"}, + "overlay": {"mountopt": "rw", "force_mask": "shared"}, + # "vfs": {"ignore_chown_errors": "true"}, + }, + } + } + + vfs_containers_conf_fpath = vfs_path / "temp_vfs_containers.conf" + vfs_containers_storage_conf_fpath = vfs_path / "temp_vfs_containers_storage.conf" + with open(vfs_containers_conf_fpath, "w") as file: + toml.dump(vfs_containers_conf_data, file) + + with open(vfs_containers_storage_conf_fpath, "w") as file: + toml.dump(vfs_containers_storage_conf_data, file) + + 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: + # test running a command + assert container.call(["echo", "hello"], capture_output=True) == "hello\n" + + # test copying a file into the container + (tmp_path / "some_file.txt").write_text("1234") + container.copy_into(tmp_path / "some_file.txt", PurePosixPath("some_file.txt")) + assert container.call(["cat", "some_file.txt"], capture_output=True) == "1234" + + # Clean up + + # When using the VFS, user is not given write permissions by default in + # new directories. As a workaround we use 'podman unshare' to delete them + # as UID 0. The reason why permission errors occur on podman is documented + # in https://podman.io/blogs/2018/10/03/podman-remove-content-homedir.html + subprocess.run(["podman", "unshare", "rm", "-rf", vfs_path], check=True) From 38faa279433f8b1bec0a82edf9293505ab9cf505 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 27 Jun 2022 15:47:31 +0000 Subject: [PATCH 33/86] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- unit_test/docker_container_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unit_test/docker_container_test.py b/unit_test/docker_container_test.py index d8d1f7fb..adbc4b55 100644 --- a/unit_test/docker_container_test.py +++ b/unit_test/docker_container_test.py @@ -4,10 +4,10 @@ import platform import random import shutil import subprocess -from tabnanny import check import tempfile import textwrap from pathlib import Path, PurePath, PurePosixPath +from tabnanny import check import pytest import toml From de3144a947575da0a13eee4cff82592a35d94c8a Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Mon, 27 Jun 2022 16:51:45 +0100 Subject: [PATCH 34/86] Remove unused imports --- unit_test/docker_container_test.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/unit_test/docker_container_test.py b/unit_test/docker_container_test.py index adbc4b55..59c9fe5e 100644 --- a/unit_test/docker_container_test.py +++ b/unit_test/docker_container_test.py @@ -1,13 +1,10 @@ -import atexit import os import platform import random import shutil import subprocess -import tempfile import textwrap from pathlib import Path, PurePath, PurePosixPath -from tabnanny import check import pytest import toml From 3bd759f50c9f0aa3fcfcf51c6720a202d42d2469 Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Mon, 27 Jun 2022 17:26:31 +0100 Subject: [PATCH 35/86] Add some type safety to the container_engine option --- cibuildwheel/docker_container.py | 10 ++++++---- cibuildwheel/options.py | 13 +++++++++++-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/cibuildwheel/docker_container.py b/cibuildwheel/docker_container.py index de41ded9..7f01b2fe 100644 --- a/cibuildwheel/docker_container.py +++ b/cibuildwheel/docker_container.py @@ -13,7 +13,9 @@ from typing import IO, Dict, List, Optional, Sequence, Type, cast from cibuildwheel.util import CIProvider, detect_ci_provider -from .typing import PathOrStr, PopenBytes +from .typing import Literal, PathOrStr, PopenBytes + +ContainerEngine = Literal["docker", "podman"] class DockerContainer: @@ -54,7 +56,7 @@ class DockerContainer: docker_image: str, simulate_32_bit: bool = False, cwd: Optional[PathOrStr] = None, - container_engine: str = "docker", + container_engine: ContainerEngine = "docker", ): if not docker_image: raise ValueError("Must have a non-empty docker image to run.") @@ -193,8 +195,6 @@ class DockerContainer: to_path.mkdir(parents=True, exist_ok=True) if self.container_engine == "podman": - # There is a bug in docker that prevents this simple implementation - # from working https://github.com/moby/moby/issues/38995 subprocess.run( [ self.container_engine, @@ -206,6 +206,8 @@ class DockerContainer: cwd=to_path, ) elif self.container_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 -" subprocess.run( command, diff --git a/cibuildwheel/options.py b/cibuildwheel/options.py index 80ee5327..e30cd47f 100644 --- a/cibuildwheel/options.py +++ b/cibuildwheel/options.py @@ -16,6 +16,7 @@ from typing import ( Set, Tuple, Union, + cast, ) if sys.version_info >= (3, 11): @@ -26,6 +27,7 @@ else: from packaging.specifiers import SpecifierSet from .architecture import Architecture +from .docker_container import ContainerEngine from .environment import EnvironmentParseError, ParsedEnvironment, parse_environment from .projectfiles import get_requires_python_str from .typing import PLATFORMS, Literal, PlatformName, TypedDict @@ -79,7 +81,7 @@ class BuildOptions(NamedTuple): test_extras: str build_verbosity: int build_frontend: BuildFrontend - container_engine: str + container_engine: ContainerEngine @property def package_dir(self) -> Path: @@ -423,7 +425,14 @@ class Options: test_requires = self.reader.get("test-requires", sep=" ").split() test_extras = self.reader.get("test-extras", sep=",") build_verbosity_str = self.reader.get("build-verbosity") - container_engine = self.reader.get("container-engine") + container_engine_str = self.reader.get("container-engine") + + if container_engine_str not in ["docker", "podman"]: + msg = f"cibuildwheel: Unrecognised container_engine '{container_engine_str}', only 'docker' and 'podman' are supported" + print(msg, file=sys.stderr) + sys.exit(2) + + container_engine = cast(ContainerEngine, container_engine_str) build_frontend: BuildFrontend if build_frontend_str == "build": From 2457006796a8dec7fe92b51075c237109d2e348b Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Mon, 27 Jun 2022 17:32:40 +0100 Subject: [PATCH 36/86] Make container-engine a global option, since that's how its being used --- cibuildwheel/linux.py | 21 +++++++++++++-------- cibuildwheel/options.py | 21 +++++++++++---------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/cibuildwheel/linux.py b/cibuildwheel/linux.py index e89a35b6..2939bd18 100644 --- a/cibuildwheel/linux.py +++ b/cibuildwheel/linux.py @@ -16,6 +16,7 @@ from .util import ( get_build_verbosity_extra_flags, prepare_command, read_python_configs, + unwrap, ) @@ -320,18 +321,22 @@ def build_on_docker( def build(options: Options, tmp_path: Path) -> None: # pylint: disable=unused-argument - - build_opts = options.build_options(None) try: - # check docker is installed + # check the container engine is installed subprocess.run( - [build_opts.container_engine, "--version"], check=True, stdout=subprocess.DEVNULL + [options.globals.container_engine, "--version"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError: print( - f"cibuildwheel: {build_opts.container_engine} not found. An OCI exe like Docker or Podman is required to run Linux builds " - "If you're building on Travis CI, add `services: [docker]` to your .travis.yml." - "If you're building on Circle CI in Linux, add a `setup_remote_docker` step to your .circleci/config.yml", + unwrap( + f""" + cibuildwheel: {options.globals.container_engine} not found. An + OCI exe like Docker or Podman is required to run Linux builds. + If you're building on Travis CI, add `services: [docker]` to + your .travis.yml. If you're building on Circle CI in Linux, + add a `setup_remote_docker` step to your .circleci/config.yml. + """ + ), file=sys.stderr, ) sys.exit(2) @@ -359,7 +364,7 @@ def build(options: Options, tmp_path: Path) -> None: # pylint: disable=unused-a docker_image=build_step.docker_image, simulate_32_bit=build_step.platform_tag.endswith("i686"), cwd=container_project_path, - container_engine=build_opts.container_engine, + container_engine=options.globals.container_engine, ) as docker: build_on_docker( diff --git a/cibuildwheel/options.py b/cibuildwheel/options.py index e30cd47f..4bed523d 100644 --- a/cibuildwheel/options.py +++ b/cibuildwheel/options.py @@ -64,6 +64,7 @@ class GlobalOptions(NamedTuple): build_selector: BuildSelector test_selector: TestSelector architectures: Set[Architecture] + container_engine: ContainerEngine class BuildOptions(NamedTuple): @@ -81,7 +82,6 @@ class BuildOptions(NamedTuple): test_extras: str build_verbosity: int build_frontend: BuildFrontend - container_engine: ContainerEngine @property def package_dir(self) -> Path: @@ -395,12 +395,22 @@ class Options: archs_config_str = args.archs or self.reader.get("archs", sep=" ") architectures = Architecture.parse_config(archs_config_str, platform=self.platform) + container_engine_str = self.reader.get("container-engine") + + if container_engine_str not in ["docker", "podman"]: + msg = f"cibuildwheel: Unrecognised container_engine '{container_engine_str}', only 'docker' and 'podman' are supported" + print(msg, file=sys.stderr) + sys.exit(2) + + container_engine = cast(ContainerEngine, container_engine_str) + return GlobalOptions( package_dir=package_dir, output_dir=output_dir, build_selector=build_selector, test_selector=test_selector, architectures=architectures, + container_engine=container_engine, ) def build_options(self, identifier: Optional[str]) -> BuildOptions: @@ -425,14 +435,6 @@ class Options: test_requires = self.reader.get("test-requires", sep=" ").split() test_extras = self.reader.get("test-extras", sep=",") build_verbosity_str = self.reader.get("build-verbosity") - container_engine_str = self.reader.get("container-engine") - - if container_engine_str not in ["docker", "podman"]: - msg = f"cibuildwheel: Unrecognised container_engine '{container_engine_str}', only 'docker' and 'podman' are supported" - print(msg, file=sys.stderr) - sys.exit(2) - - container_engine = cast(ContainerEngine, container_engine_str) build_frontend: BuildFrontend if build_frontend_str == "build": @@ -531,7 +533,6 @@ class Options: manylinux_images=manylinux_images or None, musllinux_images=musllinux_images or None, build_frontend=build_frontend, - container_engine=container_engine, ) def check_for_invalid_configuration(self, identifiers: List[str]) -> None: From 1d2e5d5d8ff5aba545aa582d22221272be934abf Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Mon, 27 Jun 2022 17:46:22 +0100 Subject: [PATCH 37/86] 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' --- cibuildwheel/docker_container.py | 57 +++++++++++------------ cibuildwheel/linux.py | 24 +++++----- cibuildwheel/options.py | 16 +++---- unit_test/docker_container_test.py | 54 +++++++-------------- unit_test/linux_build_steps_test.py | 14 +++--- unit_test/main_tests/main_options_test.py | 4 +- unit_test/option_prepare_test.py | 22 ++++----- unit_test/options_test.py | 10 ++-- 8 files changed, 89 insertions(+), 112 deletions(-) diff --git a/cibuildwheel/docker_container.py b/cibuildwheel/docker_container.py index 7f01b2fe..b910c497 100644 --- a/cibuildwheel/docker_container.py +++ b/cibuildwheel/docker_container.py @@ -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, diff --git a/cibuildwheel/linux.py b/cibuildwheel/linux.py index 2939bd18..d4eacaef 100644 --- a/cibuildwheel/linux.py +++ b/cibuildwheel/linux.py @@ -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( diff --git a/cibuildwheel/options.py b/cibuildwheel/options.py index 4bed523d..df4114e2 100644 --- a/cibuildwheel/options.py +++ b/cibuildwheel/options.py @@ -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: diff --git a/unit_test/docker_container_test.py b/unit_test/docker_container_test.py index 59c9fe5e..e4252b03 100644 --- a/unit_test/docker_container_test.py +++ b/unit_test/docker_container_test.py @@ -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" diff --git a/unit_test/linux_build_steps_test.py b/unit_test/linux_build_steps_test.py index 29bc65a4..fd8f1788 100644 --- a/unit_test/linux_build_steps_test.py +++ b/unit_test/linux_build_steps_test.py @@ -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'"] diff --git a/unit_test/main_tests/main_options_test.py b/unit_test/main_tests/main_options_test.py index 27a97a2e..59368de5 100644 --- a/unit_test/main_tests/main_options_test.py +++ b/unit_test/main_tests/main_options_test.py @@ -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 diff --git a/unit_test/option_prepare_test.py b/unit_test/option_prepare_test.py index 5f2fecfd..903746d4 100644 --- a/unit_test/option_prepare_test.py +++ b/unit_test/option_prepare_test.py @@ -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"] diff --git a/unit_test/options_test.py b/unit_test/options_test.py index fd8a102f..3ce8b214 100644 --- a/unit_test/options_test.py +++ b/unit_test/options_test.py @@ -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): From d66c1e92bfce01eddb245714c83948400fcbab3a Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Mon, 27 Jun 2022 18:30:49 +0100 Subject: [PATCH 38/86] Lots more naming changes to reflect that containers are not necessarily 'docker' --- cibuildwheel/__main__.py | 5 +- cibuildwheel/architecture.py | 2 +- cibuildwheel/linux.py | 86 ++++++++-------- .../{docker_container.py => oci_container.py} | 18 ++-- cibuildwheel/options.py | 2 +- docs/diagram.md | 6 +- docs/faq.md | 10 +- docs/options.md | 18 ++-- ...ker_images.py => test_container_images.py} | 0 test/test_manylinuxXXXX_only.py | 2 +- unit_test/linux_build_steps_test.py | 4 +- ...ontainer_test.py => oci_container_test.py} | 2 +- unit_test/option_prepare_test.py | 98 ++++++++++--------- 13 files changed, 129 insertions(+), 124 deletions(-) rename cibuildwheel/{docker_container.py => oci_container.py} (95%) rename test/{test_docker_images.py => test_container_images.py} (100%) rename unit_test/{docker_container_test.py => oci_container_test.py} (99%) diff --git a/cibuildwheel/__main__.py b/cibuildwheel/__main__.py index f8158b31..03b18a20 100644 --- a/cibuildwheel/__main__.py +++ b/cibuildwheel/__main__.py @@ -46,7 +46,7 @@ def main() -> None: auto-detected platform or to run cibuildwheel on your development machine. Specifying "macos" or "windows" only works on that operating system, but "linux" works on all three, as long as - Docker is installed. Default: auto. + Docker/Podman is installed. Default: auto. """, ) @@ -91,7 +91,7 @@ def main() -> None: Path to the package that you want wheels for. Default: the working directory. Can be a directory inside the working directory, or an sdist. When set to a directory, the working directory is still - considered the 'project' and is copied into the Docker container + considered the 'project' and is copied into the build container on Linux. When set to a tar.gz sdist file, --config-file and --output-dir are relative to the current directory, and other paths are relative to the expanded SDist directory. @@ -208,7 +208,6 @@ def build_in_directory(args: CommandLineArguments) -> None: sys.exit(0) # Add CIBUILDWHEEL environment variable - # This needs to be passed on to the docker container in linux.py os.environ["CIBUILDWHEEL"] = "1" # Python is buffering by default when running on the CI platforms, giving problems interleaving subprocess call output with unflushed calls to 'print' diff --git a/cibuildwheel/architecture.py b/cibuildwheel/architecture.py index 437ff5e8..be87f321 100644 --- a/cibuildwheel/architecture.py +++ b/cibuildwheel/architecture.py @@ -59,7 +59,7 @@ class Architecture(Enum): result = {native_architecture} if platform == "linux" and native_architecture == Architecture.x86_64: - # x86_64 machines can run i686 docker containers + # x86_64 machines can run i686 containers result.add(Architecture.i686) if platform == "windows" and native_architecture == Architecture.AMD64: diff --git a/cibuildwheel/linux.py b/cibuildwheel/linux.py index d4eacaef..fe694a7f 100644 --- a/cibuildwheel/linux.py +++ b/cibuildwheel/linux.py @@ -5,8 +5,8 @@ from pathlib import Path, PurePath, PurePosixPath from typing import Iterator, List, NamedTuple, Set, Tuple from .architecture import Architecture -from .docker_container import OCIContainer from .logger import log +from .oci_container import OCIContainer from .options import Options from .typing import OrderedDict, PathOrStr, assert_never from .util import ( @@ -79,7 +79,7 @@ def get_build_steps( ) -> Iterator[BuildStep]: """ Groups PythonConfigurations into BuildSteps. Each BuildStep represents a - separate Docker container. + separate container instance. """ steps = OrderedDict[Tuple[str, str, str], BuildStep]() @@ -103,18 +103,18 @@ def get_build_steps( yield from steps.values() -def build_on_docker( +def build_in_container( *, options: Options, platform_configs: List[PythonConfiguration], - docker: OCIContainer, + container: OCIContainer, container_project_path: PurePath, container_package_dir: PurePath, ) -> None: container_output_dir = PurePosixPath("/output") - log.step("Copying project into Docker...") - docker.copy_into(Path.cwd(), container_project_path) + log.step("Copying project into container...") + container.copy_into(Path.cwd(), container_project_path) before_all_options_identifier = platform_configs[0].identifier before_all_options = options.build_options(before_all_options_identifier) @@ -122,11 +122,11 @@ def build_on_docker( if before_all_options.before_all: log.step("Running before_all...") - env = docker.get_environment() + env = container.get_environment() env["PATH"] = f'/opt/python/cp38-cp38/bin:{env["PATH"]}' env["PIP_DISABLE_PIP_VERSION_CHECK"] = "1" env = before_all_options.environment.as_dictionary( - env, executor=docker.environment_executor + env, executor=container.environment_executor ) before_all_prepared = prepare_command( @@ -134,7 +134,7 @@ def build_on_docker( project=container_project_path, package=container_package_dir, ) - docker.call(["sh", "-c", before_all_prepared], env=env) + container.call(["sh", "-c", before_all_prepared], env=env) built_wheels: List[PurePosixPath] = [] @@ -150,21 +150,21 @@ def build_on_docker( ) container_constraints_file = PurePath("/constraints.txt") - docker.copy_into(constraints_file, container_constraints_file) + container.copy_into(constraints_file, container_constraints_file) dependency_constraint_flags = ["-c", container_constraints_file] log.step("Setting up build environment...") - env = docker.get_environment() + env = container.get_environment() # put this config's python top of the list python_bin = config.path / "bin" env["PATH"] = f'{python_bin}:{env["PATH"]}' - env = build_options.environment.as_dictionary(env, executor=docker.environment_executor) + env = build_options.environment.as_dictionary(env, executor=container.environment_executor) # check config python is still on PATH - which_python = docker.call(["which", "python"], env=env, capture_output=True).strip() + which_python = container.call(["which", "python"], env=env, capture_output=True).strip() if PurePosixPath(which_python) != python_bin / "python": print( "cibuildwheel: python available on PATH doesn't match our installed instance. If you have modified PATH, ensure that you don't overwrite cibuildwheel's entry or insert python above it.", @@ -172,7 +172,7 @@ def build_on_docker( ) sys.exit(1) - which_pip = docker.call(["which", "pip"], env=env, capture_output=True).strip() + which_pip = container.call(["which", "pip"], env=env, capture_output=True).strip() if PurePosixPath(which_pip) != python_bin / "pip": print( "cibuildwheel: pip available on PATH doesn't match our installed instance. If you have modified PATH, ensure that you don't overwrite cibuildwheel's entry or insert pip above it.", @@ -196,19 +196,19 @@ def build_on_docker( project=container_project_path, package=container_package_dir, ) - docker.call(["sh", "-c", before_build_prepared], env=env) + container.call(["sh", "-c", before_build_prepared], env=env) log.step("Building wheel...") temp_dir = PurePosixPath("/tmp/cibuildwheel") built_wheel_dir = temp_dir / "built_wheel" - docker.call(["rm", "-rf", built_wheel_dir]) - docker.call(["mkdir", "-p", built_wheel_dir]) + container.call(["rm", "-rf", built_wheel_dir]) + container.call(["mkdir", "-p", built_wheel_dir]) verbosity_flags = get_build_verbosity_extra_flags(build_options.build_verbosity) if build_options.build_frontend == "pip": - docker.call( + container.call( [ "python", "-m", @@ -223,7 +223,7 @@ def build_on_docker( ) elif build_options.build_frontend == "build": config_setting = " ".join(verbosity_flags) - docker.call( + container.call( [ "python", "-m", @@ -238,11 +238,11 @@ def build_on_docker( else: assert_never(build_options.build_frontend) - built_wheel = docker.glob(built_wheel_dir, "*.whl")[0] + built_wheel = container.glob(built_wheel_dir, "*.whl")[0] repaired_wheel_dir = temp_dir / "repaired_wheel" - docker.call(["rm", "-rf", repaired_wheel_dir]) - docker.call(["mkdir", "-p", repaired_wheel_dir]) + container.call(["rm", "-rf", repaired_wheel_dir]) + container.call(["mkdir", "-p", repaired_wheel_dir]) if built_wheel.name.endswith("none-any.whl"): raise NonPlatformWheelError() @@ -252,21 +252,23 @@ def build_on_docker( repair_command_prepared = prepare_command( build_options.repair_command, wheel=built_wheel, dest_dir=repaired_wheel_dir ) - docker.call(["sh", "-c", repair_command_prepared], env=env) + container.call(["sh", "-c", repair_command_prepared], env=env) else: - docker.call(["mv", built_wheel, repaired_wheel_dir]) + container.call(["mv", built_wheel, repaired_wheel_dir]) - repaired_wheels = docker.glob(repaired_wheel_dir, "*.whl") + repaired_wheels = container.glob(repaired_wheel_dir, "*.whl") if build_options.test_command and build_options.test_selector(config.identifier): log.step("Testing wheel...") # set up a virtual environment to install and test from, to make sure # there are no dependencies that were pulled in at build time. - docker.call(["pip", "install", "virtualenv", *dependency_constraint_flags], env=env) - venv_dir = PurePath(docker.call(["mktemp", "-d"], capture_output=True).strip()) / "venv" + container.call(["pip", "install", "virtualenv", *dependency_constraint_flags], env=env) + venv_dir = ( + PurePath(container.call(["mktemp", "-d"], capture_output=True).strip()) / "venv" + ) - docker.call(["python", "-m", "virtualenv", "--no-download", venv_dir], env=env) + container.call(["python", "-m", "virtualenv", "--no-download", venv_dir], env=env) virtualenv_env = env.copy() virtualenv_env["PATH"] = f"{venv_dir / 'bin'}:{virtualenv_env['PATH']}" @@ -277,7 +279,7 @@ def build_on_docker( project=container_project_path, package=container_package_dir, ) - docker.call(["sh", "-c", before_test_prepared], env=virtualenv_env) + container.call(["sh", "-c", before_test_prepared], env=virtualenv_env) # Install the wheel we just built # Note: If auditwheel produced two wheels, it's because the earlier produced wheel @@ -286,14 +288,14 @@ def build_on_docker( # different external shared libraries. so it doesn't matter which one we run the tests on. # Let's just pick the first one. wheel_to_test = repaired_wheels[0] - docker.call( + container.call( ["pip", "install", str(wheel_to_test) + build_options.test_extras], env=virtualenv_env, ) # Install any requirements to run the tests if build_options.test_requires: - docker.call(["pip", "install", *build_options.test_requires], env=virtualenv_env) + container.call(["pip", "install", *build_options.test_requires], env=virtualenv_env) # Run the tests from a different directory test_command_prepared = prepare_command( @@ -301,15 +303,15 @@ def build_on_docker( project=container_project_path, package=container_package_dir, ) - docker.call(["sh", "-c", test_command_prepared], cwd="/root", env=virtualenv_env) + container.call(["sh", "-c", test_command_prepared], cwd="/root", env=virtualenv_env) # clean up test environment - docker.call(["rm", "-rf", venv_dir]) + container.call(["rm", "-rf", venv_dir]) # move repaired wheels to output if abi3_wheel is None: - docker.call(["mkdir", "-p", container_output_dir]) - docker.call(["mv", *repaired_wheels, container_output_dir]) + container.call(["mkdir", "-p", container_output_dir]) + container.call(["mv", *repaired_wheels, container_output_dir]) built_wheels.extend( container_output_dir / repaired_wheel.name for repaired_wheel in repaired_wheels ) @@ -318,7 +320,7 @@ def build_on_docker( log.step("Copying wheels back to host...") # copy the output back into the host - docker.copy_out(container_output_dir, options.globals.output_dir) + container.copy_out(container_output_dir, options.globals.output_dir) log.step_end() @@ -358,21 +360,21 @@ def build(options: Options, tmp_path: Path) -> None: # pylint: disable=unused-a for build_step in get_build_steps(options, python_configurations): try: ids_to_build = [x.identifier for x in build_step.platform_configs] - log.step( - f"Starting Docker image {build_step.container_image} for {', '.join(ids_to_build)}..." - ) + log.step(f"Starting container image {build_step.container_image}...") + + print(f"info: This container will host the build for {', '.join(ids_to_build)}...") with OCIContainer( image=build_step.container_image, simulate_32_bit=build_step.platform_tag.endswith("i686"), cwd=container_project_path, engine=options.globals.container_engine, - ) as docker: + ) as container: - build_on_docker( + build_in_container( options=options, platform_configs=build_step.platform_configs, - docker=docker, + container=container, container_project_path=container_project_path, container_package_dir=container_package_dir, ) diff --git a/cibuildwheel/docker_container.py b/cibuildwheel/oci_container.py similarity index 95% rename from cibuildwheel/docker_container.py rename to cibuildwheel/oci_container.py index b910c497..2d79720f 100644 --- a/cibuildwheel/docker_container.py +++ b/cibuildwheel/oci_container.py @@ -56,7 +56,7 @@ class OCIContainer: engine: ContainerEngine = "docker", ): if not image: - raise ValueError("Must have a non-empty docker image to run.") + raise ValueError("Must have a non-empty image to run.") self.image = image self.simulate_32_bit = simulate_32_bit @@ -175,17 +175,19 @@ class OCIContainer: f"cat > {shell_quote(to_path)}", ], stdin=subprocess.PIPE, - ) as docker: - docker.stdin = cast(IO[bytes], docker.stdin) + ) as exec_process: + exec_process.stdin = cast(IO[bytes], exec_process.stdin) with open(from_path, "rb") as from_file: - shutil.copyfileobj(from_file, docker.stdin) + shutil.copyfileobj(from_file, exec_process.stdin) - docker.stdin.close() - docker.wait() + exec_process.stdin.close() + exec_process.wait() - if docker.returncode: - raise subprocess.CalledProcessError(docker.returncode, docker.args, None, None) + if exec_process.returncode: + raise subprocess.CalledProcessError( + exec_process.returncode, exec_process.args, None, None + ) def copy_out(self, from_path: PurePath, to_path: Path) -> None: # note: we assume from_path is a dir diff --git a/cibuildwheel/options.py b/cibuildwheel/options.py index df4114e2..8a5e75c3 100644 --- a/cibuildwheel/options.py +++ b/cibuildwheel/options.py @@ -27,8 +27,8 @@ else: from packaging.specifiers import SpecifierSet from .architecture import Architecture -from .docker_container import ContainerEngine from .environment import EnvironmentParseError, ParsedEnvironment, parse_environment +from .oci_container import ContainerEngine from .projectfiles import get_requires_python_str from .typing import PLATFORMS, Literal, PlatformName, TypedDict from .util import ( diff --git a/docs/diagram.md b/docs/diagram.md index d0557b4f..fe542997 100644 --- a/docs/diagram.md +++ b/docs/diagram.md @@ -8,7 +8,7 @@
- Manylinux Docker container + Manylinux container
@@ -76,7 +76,7 @@ steps: [ [ { - label: 'copy project into docker', + label: 'copy project into container', platforms: ['linux'], style: 'block', width: 2, @@ -204,7 +204,7 @@ ], [ { - label: 'Copy wheels out of Docker', + label: 'Copy wheels out of container', platforms: ['linux'], style: 'block', width: 2, diff --git a/docs/faq.md b/docs/faq.md index 66c05618..fbbf4c67 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -4,15 +4,15 @@ title: Tips and tricks ## Tips -### Linux builds on Docker +### Linux builds in containers -Linux wheels are built in the [`manylinux`/`musllinux` docker images](https://github.com/pypa/manylinux) to provide binary compatible wheels on Linux, according to [PEP 600](https://www.python.org/dev/peps/pep-0600/) / [PEP 656](https://www.python.org/dev/peps/pep-0656/). Because of this, when building with `cibuildwheel` on Linux, a few things should be taken into account: +Linux wheels are built in [`manylinux`/`musllinux` containers](https://github.com/pypa/manylinux) to provide binary compatible wheels on Linux, according to [PEP 600](https://www.python.org/dev/peps/pep-0600/) / [PEP 656](https://www.python.org/dev/peps/pep-0656/). Because of this, when building with `cibuildwheel` on Linux, a few things should be taken into account: -- Programs and libraries are not installed on the CI runner host, but rather should be installed inside of the Docker image - using `yum` for `manylinux2010` or `manylinux2014`, `apt-get` for `manylinux_2_24` and `apk` for `musllinux_1_1`, or manually. The same goes for environment variables that are potentially needed to customize the wheel building. +- Programs and libraries are not installed on the CI runner host, but rather should be installed inside the container - using `yum` for `manylinux2010` or `manylinux2014`, `apt-get` for `manylinux_2_24` and `apk` for `musllinux_1_1`, or manually. The same goes for environment variables that are potentially needed to customize the wheel building. - `cibuildwheel` supports this by providing the [`CIBW_ENVIRONMENT`](options.md#environment) and [`CIBW_BEFORE_ALL`](options.md#before-all) options to setup the build environment inside the running Docker image. + `cibuildwheel` supports this by providing the [`CIBW_ENVIRONMENT`](options.md#environment) and [`CIBW_BEFORE_ALL`](options.md#before-all) options to setup the build environment inside the running container. -- The project directory is mounted in the running Docker instance as `/project`, the output directory for the wheels as `/output`. In general, this is handled transparently by `cibuildwheel`. For a more finegrained level of control however, the root of the host file system is mounted as `/host`, allowing for example to access shared files, caches, etc. on the host file system. Note that `/host` is not available on CircleCI due to their Docker policies. +- The project directory is mounted inside the container as `/project`, the output directory for the wheels as `/output`. In general, this is handled transparently by `cibuildwheel`. For a more finegrained level of control however, the root of the host file system is mounted as `/host`, allowing for example to access shared files, caches, etc. on the host file system. Note that `/host` is not available on CircleCI due to their Docker policies. - Alternative Docker images can be specified with the `CIBW_MANYLINUX_*_IMAGE`/`CIBW_MUSLLINUX_*_IMAGE` options to allow for a custom, preconfigured build environment for the Linux builds. See [options](options.md#linux-image) for more details. diff --git a/docs/options.md b/docs/options.md index f72b388a..fbd03796 100644 --- a/docs/options.md +++ b/docs/options.md @@ -117,9 +117,9 @@ matches overriding earlier ones if multiple selectors match. Environment variables always override static configuration. A few of the options below have special handling in overrides. A different -`before-all` will trigger a new docker launch on Linux, and cannot be +`before-all` will trigger a new container to launch on Linux, and cannot be overridden on macOS or Windows. Overriding the image on linux will also -generate new docker launches, one per image. Some commands are not supported; +trigger new containers, one per image. Some commands are not supported; `output-dir`, build/skip/test_skip selectors, and architectures cannot be overridden. @@ -174,7 +174,7 @@ Default: `auto` `auto` will auto-detect platform using environment variables, such as `TRAVIS_OS_NAME`/`APPVEYOR`/`CIRCLECI`. -- For `linux`, you need Docker running, on Linux, macOS, or Windows. +- For `linux`, you need [Docker or Podman](#container-engine) running, on Linux, macOS, or Windows. - For `macos` and `windows`, you need to be running on the respective system, with a working compiler toolchain installed - Xcode Command Line tools for macOS, and MSVC for Windows. This option can also be set using the [command-line option](#command-line) `--platform`. This option is not available in the `pyproject.toml` config. @@ -523,7 +523,7 @@ Choose which build backend to use. Can either be "pip", which will run A list of environment variables to set during the build. Bash syntax should be used, even on Windows. -You must set this variable to pass variables to Linux builds (since they execute in a Docker container). It also works for the other platforms. +You must set this variable to pass variables to Linux builds (since they execute in a container). It also works for the other platforms. You can use `$PATH` syntax to insert other variables, or the `$(pwd)` syntax to insert the output of other shell commands. @@ -637,14 +637,14 @@ To specify more than one environment variable, separate the variable names by sp Shell command to prepare a common part of the project (e.g. build or install libraries which does not depend on the specific version of Python). -This option is very useful for the Linux build, where builds take place in isolated Docker containers managed by cibuildwheel. This command will run inside the container before the wheel builds start. Note, if you're building both `x86_64` and `i686` wheels (the default), your build uses two different Docker images. In that case, this command will execute twice - once per build container. +This option is very useful for the Linux build, where builds take place in isolated containers managed by cibuildwheel. This command will run inside the container before the wheel builds start. Note, if you're building both `x86_64` and `i686` wheels (the default), your build uses two different container images. In that case, this command will execute twice - once per build container. The placeholder `{package}` can be used here; it will be replaced by the path to the package being built by cibuildwheel. On Windows and macOS, the version of Python available inside `CIBW_BEFORE_ALL` is whatever is available on the host machine. On Linux, a modern Python version is available on PATH. This option has special behavior in the overrides section in `pyproject.toml`. -On linux, overriding it triggers a new docker launch. It cannot be overridden +On linux, overriding it triggers a new container launch. It cannot be overridden on macOS and Windows. Platform-specific environment variables also available:
@@ -866,7 +866,7 @@ Platform-specific environment variables are also available:
### `CIBW_MANYLINUX_*_IMAGE`, `CIBW_MUSLLINUX_*_IMAGE` {: #linux-image} -> Specify alternative manylinux / musllinux Docker images +> Specify alternative manylinux / musllinux container images The available options are (default value): @@ -893,9 +893,9 @@ For `CIBW_MUSLLINUX_*_IMAGE`, the value of this option can either be set to `mus If this option is blank, it will fall though to the next available definition (environment variable -> pyproject.toml -> default). -If setting a custom Docker image, you'll need to make sure it can be used in the same way as the official, default Docker images: all necessary Python and pip versions need to be present in `/opt/python/`, and the auditwheel tool needs to be present for cibuildwheel to work. Apart from that, the architecture and relevant shared system libraries need to be compatible to the relevant standard to produce valid manylinux1/manylinux2010/manylinux2014/manylinux_2_24/manylinux_2_28/musllinux_1_1 wheels (see [pypa/manylinux on GitHub](https://github.com/pypa/manylinux), [PEP 513](https://www.python.org/dev/peps/pep-0513/), [PEP 571](https://www.python.org/dev/peps/pep-0571/), [PEP 599](https://www.python.org/dev/peps/pep-0599/), [PEP 600](https://www.python.org/dev/peps/pep-0600/) and [PEP 656](https://www.python.org/dev/peps/pep-0656/) for more details). +If setting a custom image, you'll need to make sure it can be used in the same way as the default images: all necessary Python and pip versions need to be present in `/opt/python/`, and the auditwheel tool needs to be present for cibuildwheel to work. Apart from that, the architecture and relevant shared system libraries need to be compatible to the relevant standard to produce valid manylinux1/manylinux2010/manylinux2014/manylinux_2_24/manylinux_2_28/musllinux_1_1 wheels (see [pypa/manylinux on GitHub](https://github.com/pypa/manylinux), [PEP 513](https://www.python.org/dev/peps/pep-0513/), [PEP 571](https://www.python.org/dev/peps/pep-0571/), [PEP 599](https://www.python.org/dev/peps/pep-0599/), [PEP 600](https://www.python.org/dev/peps/pep-0600/) and [PEP 656](https://www.python.org/dev/peps/pep-0656/) for more details). -Auditwheel detects the version of the manylinux / musllinux standard in the Docker image through the `AUDITWHEEL_PLAT` environment variable, as cibuildwheel has no way of detecting the correct `--plat` command line argument to pass to auditwheel for a custom image. If a Docker image does not correctly set this `AUDITWHEEL_PLAT` environment variable, the `CIBW_ENVIRONMENT` option can be used to do so (e.g., `CIBW_ENVIRONMENT='AUDITWHEEL_PLAT="manylinux2010_$(uname -m)"'`). +Auditwheel detects the version of the manylinux / musllinux standard in the image through the `AUDITWHEEL_PLAT` environment variable, as cibuildwheel has no way of detecting the correct `--plat` command line argument to pass to auditwheel for a custom image. If a custom image does not correctly set this `AUDITWHEEL_PLAT` environment variable, the `CIBW_ENVIRONMENT` option can be used to do so (e.g., `CIBW_ENVIRONMENT='AUDITWHEEL_PLAT="manylinux2010_$(uname -m)"'`). #### Examples diff --git a/test/test_docker_images.py b/test/test_container_images.py similarity index 100% rename from test/test_docker_images.py rename to test/test_container_images.py diff --git a/test/test_manylinuxXXXX_only.py b/test/test_manylinuxXXXX_only.py index 2a80cbb3..935aa592 100644 --- a/test/test_manylinuxXXXX_only.py +++ b/test/test_manylinuxXXXX_only.py @@ -53,7 +53,7 @@ project_with_manylinux_symbols = test_projects.new_c_project( ) def test(manylinux_image, tmp_path): if utils.platform != "linux": - pytest.skip("the docker test is only relevant to the linux build") + pytest.skip("the container image test is only relevant to the linux build") elif platform.machine() not in ["x86_64", "i686"]: if manylinux_image in ["manylinux1", "manylinux2010"]: pytest.skip("manylinux1 and 2010 doesn't exist for non-x86 architectures") diff --git a/unit_test/linux_build_steps_test.py b/unit_test/linux_build_steps_test.py index fd8f1788..36aaebb7 100644 --- a/unit_test/linux_build_steps_test.py +++ b/unit_test/linux_build_steps_test.py @@ -2,8 +2,8 @@ import textwrap from pathlib import Path from pprint import pprint -import cibuildwheel.docker_container import cibuildwheel.linux +import cibuildwheel.oci_container from cibuildwheel.options import Options from .utils import get_default_command_line_arguments @@ -11,7 +11,7 @@ from .utils import get_default_command_line_arguments def test_linux_container_split(tmp_path: Path, monkeypatch): """ - Tests splitting linux builds by docker image and before_all + Tests splitting linux builds by container image and before_all """ args = get_default_command_line_arguments() diff --git a/unit_test/docker_container_test.py b/unit_test/oci_container_test.py similarity index 99% rename from unit_test/docker_container_test.py rename to unit_test/oci_container_test.py index e4252b03..ca629119 100644 --- a/unit_test/docker_container_test.py +++ b/unit_test/oci_container_test.py @@ -9,8 +9,8 @@ from pathlib import Path, PurePath, PurePosixPath import pytest import toml -from cibuildwheel.docker_container import OCIContainer from cibuildwheel.environment import EnvironmentAssignmentBash +from cibuildwheel.oci_container import OCIContainer # Test utilities diff --git a/unit_test/option_prepare_test.py b/unit_test/option_prepare_test.py index 903746d4..10bca432 100644 --- a/unit_test/option_prepare_test.py +++ b/unit_test/option_prepare_test.py @@ -15,7 +15,7 @@ ALL_IDS = {"cp36", "cp37", "cp38", "cp39", "cp310", "pp37", "pp38", "pp39"} @pytest.fixture -def mock_build_docker(monkeypatch): +def mock_build_container(monkeypatch): def fail_on_call(*args, **kwargs): raise RuntimeError("This should never be called") @@ -37,56 +37,58 @@ def mock_build_docker(monkeypatch): monkeypatch.setattr(util, "download", fail_on_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_in_container", mock.Mock(spec=linux.build_in_container) + ) monkeypatch.setattr("cibuildwheel.util.print_new_wheels", ignore_context_call) -def test_build_default_launches(mock_build_docker, fake_package_dir, monkeypatch): +def test_build_default_launches(mock_build_container, fake_package_dir, monkeypatch): monkeypatch.setattr(sys, "argv", ["cibuildwheel", "--platform=linux"]) main() - build_on_docker = cast(mock.Mock, linux.build_on_docker) + build_in_container = cast(mock.Mock, linux.build_in_container) - assert build_on_docker.call_count == 4 + assert build_in_container.call_count == 4 # 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"]["image"] - assert kwargs["docker"]["cwd"] == PurePosixPath("/project") - assert not kwargs["docker"]["simulate_32_bit"] + kwargs = build_in_container.call_args_list[0][1] + assert "quay.io/pypa/manylinux2014_x86_64" in kwargs["container"]["image"] + assert kwargs["container"]["cwd"] == PurePosixPath("/project") + assert not kwargs["container"]["simulate_32_bit"] identifiers = {x.identifier for x in kwargs["platform_configs"]} 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"]["image"] - assert kwargs["docker"]["cwd"] == PurePosixPath("/project") - assert kwargs["docker"]["simulate_32_bit"] + kwargs = build_in_container.call_args_list[1][1] + assert "quay.io/pypa/manylinux2014_i686" in kwargs["container"]["image"] + assert kwargs["container"]["cwd"] == PurePosixPath("/project") + assert kwargs["container"]["simulate_32_bit"] identifiers = {x.identifier for x in kwargs["platform_configs"]} 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"]["image"] - assert kwargs["docker"]["cwd"] == PurePosixPath("/project") - assert not kwargs["docker"]["simulate_32_bit"] + kwargs = build_in_container.call_args_list[2][1] + assert "quay.io/pypa/musllinux_1_1_x86_64" in kwargs["container"]["image"] + assert kwargs["container"]["cwd"] == PurePosixPath("/project") + assert not kwargs["container"]["simulate_32_bit"] identifiers = {x.identifier for x in kwargs["platform_configs"]} assert identifiers == { f"{x}-musllinux_x86_64" for x in ALL_IDS for x in ALL_IDS if "pp" not in x } - kwargs = build_on_docker.call_args_list[3][1] - assert "quay.io/pypa/musllinux_1_1_i686" in kwargs["docker"]["image"] - assert kwargs["docker"]["cwd"] == PurePosixPath("/project") - assert kwargs["docker"]["simulate_32_bit"] + kwargs = build_in_container.call_args_list[3][1] + assert "quay.io/pypa/musllinux_1_1_i686" in kwargs["container"]["image"] + assert kwargs["container"]["cwd"] == PurePosixPath("/project") + assert kwargs["container"]["simulate_32_bit"] identifiers = {x.identifier for x in kwargs["platform_configs"]} assert identifiers == {f"{x}-musllinux_i686" for x in ALL_IDS if "pp" not in x} -def test_build_with_override_launches(mock_build_docker, monkeypatch, tmp_path): +def test_build_with_override_launches(mock_build_container, monkeypatch, tmp_path): pkg_dir = tmp_path / "cibw_package" pkg_dir.mkdir() @@ -113,23 +115,23 @@ before-all = "true" main() - build_on_docker = cast(mock.Mock, linux.build_on_docker) + build_in_container = cast(mock.Mock, linux.build_in_container) - assert build_on_docker.call_count == 6 + assert build_in_container.call_count == 6 - kwargs = build_on_docker.call_args_list[0][1] - assert "quay.io/pypa/manylinux2014_x86_64" in kwargs["docker"]["image"] - assert kwargs["docker"]["cwd"] == PurePosixPath("/project") - assert not kwargs["docker"]["simulate_32_bit"] + kwargs = build_in_container.call_args_list[0][1] + assert "quay.io/pypa/manylinux2014_x86_64" in kwargs["container"]["image"] + assert kwargs["container"]["cwd"] == PurePosixPath("/project") + assert not kwargs["container"]["simulate_32_bit"] identifiers = {x.identifier for x in kwargs["platform_configs"]} assert identifiers == {"cp36-manylinux_x86_64"} 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"]["image"] - assert kwargs["docker"]["cwd"] == PurePosixPath("/project") - assert not kwargs["docker"]["simulate_32_bit"] + kwargs = build_in_container.call_args_list[1][1] + assert "quay.io/pypa/manylinux2014_x86_64" in kwargs["container"]["image"] + assert kwargs["container"]["cwd"] == PurePosixPath("/project") + assert not kwargs["container"]["simulate_32_bit"] identifiers = {x.identifier for x in kwargs["platform_configs"]} assert identifiers == { @@ -137,10 +139,10 @@ 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"]["image"] - assert kwargs["docker"]["cwd"] == PurePosixPath("/project") - assert not kwargs["docker"]["simulate_32_bit"] + kwargs = build_in_container.call_args_list[2][1] + assert "quay.io/pypa/manylinux_2_24_x86_64" in kwargs["container"]["image"] + assert kwargs["container"]["cwd"] == PurePosixPath("/project") + assert not kwargs["container"]["simulate_32_bit"] identifiers = {x.identifier for x in kwargs["platform_configs"]} assert identifiers == { "cp310-manylinux_x86_64", @@ -149,28 +151,28 @@ before-all = "true" "pp39-manylinux_x86_64", } - kwargs = build_on_docker.call_args_list[3][1] - assert "quay.io/pypa/manylinux2014_i686" in kwargs["docker"]["image"] - assert kwargs["docker"]["cwd"] == PurePosixPath("/project") - assert kwargs["docker"]["simulate_32_bit"] + kwargs = build_in_container.call_args_list[3][1] + assert "quay.io/pypa/manylinux2014_i686" in kwargs["container"]["image"] + assert kwargs["container"]["cwd"] == PurePosixPath("/project") + assert kwargs["container"]["simulate_32_bit"] identifiers = {x.identifier for x in kwargs["platform_configs"]} 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"]["image"] - assert kwargs["docker"]["cwd"] == PurePosixPath("/project") - assert not kwargs["docker"]["simulate_32_bit"] + kwargs = build_in_container.call_args_list[4][1] + assert "quay.io/pypa/musllinux_1_1_x86_64" in kwargs["container"]["image"] + assert kwargs["container"]["cwd"] == PurePosixPath("/project") + assert not kwargs["container"]["simulate_32_bit"] identifiers = {x.identifier for x in kwargs["platform_configs"]} assert identifiers == { f"{x}-musllinux_x86_64" for x in ALL_IDS for x in ALL_IDS if "pp" not in x } - kwargs = build_on_docker.call_args_list[5][1] - assert "quay.io/pypa/musllinux_1_1_i686" in kwargs["docker"]["image"] - assert kwargs["docker"]["cwd"] == PurePosixPath("/project") - assert kwargs["docker"]["simulate_32_bit"] + kwargs = build_in_container.call_args_list[5][1] + assert "quay.io/pypa/musllinux_1_1_i686" in kwargs["container"]["image"] + assert kwargs["container"]["cwd"] == PurePosixPath("/project") + assert kwargs["container"]["simulate_32_bit"] identifiers = {x.identifier for x in kwargs["platform_configs"]} assert identifiers == {f"{x}-musllinux_i686" for x in ALL_IDS if "pp" not in x} From e5ef3c1b7616446bbdeb8da2b0bbb203ccb582dd Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Mon, 27 Jun 2022 18:35:28 +0100 Subject: [PATCH 39/86] Tweak test config to remove always-skipped test --- unit_test/oci_container_test.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/unit_test/oci_container_test.py b/unit_test/oci_container_test.py index ca629119..baee3c3d 100644 --- a/unit_test/oci_container_test.py +++ b/unit_test/oci_container_test.py @@ -217,10 +217,10 @@ def test_environment_executor(container_engine): assert assignment.evaluated_value({}, container.environment_executor) == "42" -def test_podman_vfs(container_engine, tmp_path: Path, monkeypatch): +def test_podman_vfs(tmp_path: Path, monkeypatch, request): # Tests podman VFS, for the podman in docker use-case - if container_engine != "podman": - pytest.skip("podman is the only supported container engine for this test") + if not request.config.getoption("--run-podman"): + pytest.skip("need --run-podman option to run") # create the VFS configuration vfs_path = tmp_path / "podman_vfs" @@ -278,7 +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 OCIContainer(engine=container_engine, image=DEFAULT_IMAGE) as container: + with OCIContainer(engine="podman", image=DEFAULT_IMAGE) as container: # test running a command assert container.call(["echo", "hello"], capture_output=True) == "hello\n" From f23d8aaae56a36dbb1b73e89757003804001794f Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Mon, 27 Jun 2022 19:08:46 +0100 Subject: [PATCH 40/86] Add an integration test for a podman build --- .github/workflows/test.yml | 2 +- bin/run_tests.py | 44 +++++++++++++++++++++++--------------- test/conftest.py | 15 +------------ test/test_emulation.py | 6 ++++-- test/test_podman.py | 37 ++++++++++++++++++++++++++++++++ 5 files changed, 70 insertions(+), 34 deletions(-) create mode 100644 test/test_podman.py diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 63f3f5d4..8b565e36 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -75,7 +75,7 @@ jobs: - name: Test cibuildwheel run: | - python ./bin/run_tests.py + python ./bin/run_tests.py --run-podman test-emulated: name: Test emulated cibuildwheel using qemu diff --git a/bin/run_tests.py b/bin/run_tests.py index 44c6d302..5f3a3606 100755 --- a/bin/run_tests.py +++ b/bin/run_tests.py @@ -1,33 +1,43 @@ #!/usr/bin/env python3 +import argparse import os import subprocess import sys from pathlib import Path if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--run-podman", action="store_true", default=False, help="run podman tests") + args = parser.parse_args() + # move cwd to the project root os.chdir(Path(__file__).resolve().parents[1]) - # run the unit tests + # unit tests unit_test_args = [sys.executable, "-m", "pytest", "unit_test"] - # run the docker unit tests only on Linux + if sys.platform.startswith("linux"): + # run the docker unit tests only on Linux unit_test_args += ["--run-docker"] + if args.run_podman: + unit_test_args += ["--run-podman"] + subprocess.run(unit_test_args, check=True) - # run the integration tests - subprocess.run( - [ - sys.executable, - "-m", - "pytest", - "--numprocesses=2", - "-x", - "--durations", - "0", - "--timeout=2400", - "test", - ], - check=True, - ) + # integration tests + integration_test_args = [ + sys.executable, + "-m", + "pytest", + "--numprocesses=2", + "-x", + "--durations", + "0", + "--timeout=2400", + "test", + ] + if args.run_podman: + integration_test_args += ["--run-podman"] + + subprocess.run(integration_test_args, check=True) diff --git a/test/conftest.py b/test/conftest.py index d8ff2f62..e7c42112 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -7,20 +7,7 @@ def pytest_addoption(parser) -> None: parser.addoption( "--run-emulation", action="store_true", default=False, help="run emulation tests" ) - - -def pytest_configure(config): - config.addinivalue_line("markers", "emulation: mark test requiring qemu binfmt_misc to run") - - -def pytest_collection_modifyitems(config, items) -> None: - if config.getoption("--run-emulation"): - # --run-emulation given in cli: do not skip emulation tests - return - skip_emulation = pytest.mark.skip(reason="need --run-emulation option to run") - for item in items: - if "emulation" in item.keywords: - item.add_marker(skip_emulation) + parser.addoption("--run-podman", action="store_true", default=False, help="run podman tests") @pytest.fixture( diff --git a/test/test_emulation.py b/test/test_emulation.py index dd76ab36..95b574dd 100644 --- a/test/test_emulation.py +++ b/test/test_emulation.py @@ -17,8 +17,10 @@ def test_spam(): """ -@pytest.mark.emulation -def test(tmp_path): +def test(tmp_path, request): + if not request.config.getoption("--run-emulation"): + pytest.skip("needs --run-emulation option to run") + project_dir = tmp_path / "project" project_with_a_test.generate(project_dir) diff --git a/test/test_podman.py b/test/test_podman.py new file mode 100644 index 00000000..d4bdf556 --- /dev/null +++ b/test/test_podman.py @@ -0,0 +1,37 @@ +import pytest + +from . import test_projects, utils + +basic_project = test_projects.new_c_project() + + +def test(tmp_path, capfd, request): + if utils.platform != "linux": + pytest.skip("the test is only relevant to the linux build") + + if not request.config.getoption("--run-podman"): + pytest.skip("needs --run-podman option to run") + + project_dir = tmp_path / "project" + basic_project.generate(project_dir) + + # build some musllinux and manylinux wheels (ensuring that we use two containers) + actual_wheels = utils.cibuildwheel_run( + project_dir, + add_env={ + "CIBW_BUILD": "cp310-*{manylinux,musllinux}_x86_64", + "CIBW_BEFORE_ALL": "echo 'test log statement from before-all'", + }, + ) + + # check that the expected wheels are produced + expected_wheels = [ + w + for w in utils.expected_wheels("spam", "0.1.0") + if ("-cp310-" in w) and ("x86_64" in w) and ("manylinux" in w or "musllinux" in w) + ] + assert set(actual_wheels) == set(expected_wheels) + + # check that stdout is bring passed-though from container correctly + captured = capfd.readouterr() + assert "test log statement from before-all" in captured.out From b612a6c9936161840bbf316dde6f51fb50781ece Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Mon, 27 Jun 2022 19:19:00 +0100 Subject: [PATCH 41/86] Actually run the podman integration test on podman :) --- test/test_podman.py | 1 + 1 file changed, 1 insertion(+) diff --git a/test/test_podman.py b/test/test_podman.py index d4bdf556..dd07572b 100644 --- a/test/test_podman.py +++ b/test/test_podman.py @@ -21,6 +21,7 @@ def test(tmp_path, capfd, request): add_env={ "CIBW_BUILD": "cp310-*{manylinux,musllinux}_x86_64", "CIBW_BEFORE_ALL": "echo 'test log statement from before-all'", + "CIBW_CONTAINER_ENGINE": "podman", }, ) From 22ba00bb4619787fe2892dd89286a5052f44f821 Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Mon, 27 Jun 2022 19:32:35 +0100 Subject: [PATCH 42/86] Fix missing rename --- cibuildwheel/oci_container.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cibuildwheel/oci_container.py b/cibuildwheel/oci_container.py index 2d79720f..3550a88c 100644 --- a/cibuildwheel/oci_container.py +++ b/cibuildwheel/oci_container.py @@ -30,7 +30,7 @@ class OCIContainer: back to cibuildwheel. Example: - >>> from cibuildwheel.docker_container import * # NOQA + >>> from cibuildwheel.oci_container import * # NOQA >>> from cibuildwheel.options import _get_pinned_container_images >>> image = _get_pinned_container_images()['x86_64']['manylinux2014'] >>> # Test the default container From e7de8a47607f09b4e063b93ccfcfc70c8e914b17 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 27 Jun 2022 18:35:29 +0000 Subject: [PATCH 43/86] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/hadialqattan/pycln: v1.3.3 → v1.3.5](https://github.com/hadialqattan/pycln/compare/v1.3.3...v1.3.5) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 679254fd..89126ed2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -27,7 +27,7 @@ repos: # Autoremoves unused imports - repo: https://github.com/hadialqattan/pycln - rev: v1.3.3 + rev: v1.3.5 hooks: - id: pycln args: [--all] From 12a3fa2d3e6e232b3114679730436df7d7add175 Mon Sep 17 00:00:00 2001 From: joncrall Date: Mon, 27 Jun 2022 16:23:02 -0400 Subject: [PATCH 44/86] Use tomli_w instead of toml --- setup.py | 2 +- unit_test/oci_container_test.py | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index ad32d3f3..2ceaa359 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ extras = { "pytest-timeout", "pytest-xdist", "build", - "toml", + "toml_w", ], "bin": [ "click", diff --git a/unit_test/oci_container_test.py b/unit_test/oci_container_test.py index baee3c3d..838c72bd 100644 --- a/unit_test/oci_container_test.py +++ b/unit_test/oci_container_test.py @@ -7,7 +7,8 @@ import textwrap from pathlib import Path, PurePath, PurePosixPath import pytest -import toml + +import tomli_w from cibuildwheel.environment import EnvironmentAssignmentBash from cibuildwheel.oci_container import OCIContainer @@ -269,11 +270,11 @@ def test_podman_vfs(tmp_path: Path, monkeypatch, request): vfs_containers_conf_fpath = vfs_path / "temp_vfs_containers.conf" vfs_containers_storage_conf_fpath = vfs_path / "temp_vfs_containers_storage.conf" - with open(vfs_containers_conf_fpath, "w") as file: - toml.dump(vfs_containers_conf_data, file) + with open(vfs_containers_conf_fpath, "wb") as file: + tomli_w.dump(vfs_containers_conf_data, file) - with open(vfs_containers_storage_conf_fpath, "w") as file: - toml.dump(vfs_containers_storage_conf_data, file) + with open(vfs_containers_storage_conf_fpath, "wb") as file: + tomli_w.dump(vfs_containers_storage_conf_data, file) monkeypatch.setenv("CONTAINERS_CONF", str(vfs_containers_conf_fpath)) monkeypatch.setenv("CONTAINERS_STORAGE_CONF", str(vfs_containers_storage_conf_fpath)) From 46678e24e312ff75bd479bab53160172d0ebf6b9 Mon Sep 17 00:00:00 2001 From: joncrall Date: Mon, 27 Jun 2022 16:24:00 -0400 Subject: [PATCH 45/86] Inlined podman install --- .github/install_latest_podman.sh | 12 ------------ .github/workflows/test.yml | 7 ++++++- 2 files changed, 6 insertions(+), 13 deletions(-) delete mode 100755 .github/install_latest_podman.sh diff --git a/.github/install_latest_podman.sh b/.github/install_latest_podman.sh deleted file mode 100755 index 42eca8b9..00000000 --- a/.github/install_latest_podman.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -__doc__=" -Based on code in: https://github.com/redhat-actions/podman-login/blob/main/.github/install_latest_podman.sh -" -# https://podman.io/getting-started/installation -# shellcheck source=/dev/null -. /etc/os-release -echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/ /" | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list -curl -sSfL "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/Release.key" | sudo apt-key add - -sudo apt-get update -sudo apt-get -y upgrade -sudo apt-get -y install podman diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8b565e36..20217b16 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -50,7 +50,12 @@ jobs: - name: Install latest podman if: runner.os == 'Linux' run: | - bash .github/install_latest_podman.sh + . /etc/os-release + echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/ /" | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list + curl -sSfL "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/Release.key" | sudo apt-key add - + sudo apt-get update + sudo apt-get -y upgrade + sudo apt-get -y install podman - name: Install dependencies run: | From 062ab6cb93e035cff13f7abc842effa11be16181 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 27 Jun 2022 20:24:14 +0000 Subject: [PATCH 46/86] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- unit_test/oci_container_test.py | 1 - 1 file changed, 1 deletion(-) diff --git a/unit_test/oci_container_test.py b/unit_test/oci_container_test.py index 838c72bd..2f425daf 100644 --- a/unit_test/oci_container_test.py +++ b/unit_test/oci_container_test.py @@ -7,7 +7,6 @@ import textwrap from pathlib import Path, PurePath, PurePosixPath import pytest - import tomli_w from cibuildwheel.environment import EnvironmentAssignmentBash From f182ed3cfaa13a2b90d1f9a21cfb59df8f2098be Mon Sep 17 00:00:00 2001 From: joncrall Date: Mon, 27 Jun 2022 23:40:41 -0400 Subject: [PATCH 47/86] Fix spelling --- .pre-commit-config.yaml | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e54c6d3b..e93e3dc8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -61,13 +61,13 @@ repos: - pygithub - rich - tomli + - tomli_w - types-certifi - types-click - types-dataclasses - types-jinja2 - types-pyyaml - types-requests - - types-toml - bracex - dataclasses - id: mypy diff --git a/setup.py b/setup.py index 2ceaa359..cd4956e1 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ extras = { "pytest-timeout", "pytest-xdist", "build", - "toml_w", + "tomli_w", ], "bin": [ "click", From f69fa19d071e7429e1036fbbe26c1b9741a88a78 Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Wed, 29 Jun 2022 20:18:08 +0100 Subject: [PATCH 48/86] Run podman tests only on linux --- bin/run_tests.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/bin/run_tests.py b/bin/run_tests.py index 5f3a3606..82e193c3 100755 --- a/bin/run_tests.py +++ b/bin/run_tests.py @@ -8,7 +8,9 @@ from pathlib import Path if __name__ == "__main__": parser = argparse.ArgumentParser() - parser.add_argument("--run-podman", action="store_true", default=False, help="run podman tests") + parser.add_argument( + "--run-podman", action="store_true", default=False, help="run podman tests (linux only)" + ) args = parser.parse_args() # move cwd to the project root @@ -20,8 +22,9 @@ if __name__ == "__main__": if sys.platform.startswith("linux"): # run the docker unit tests only on Linux unit_test_args += ["--run-docker"] - if args.run_podman: - unit_test_args += ["--run-podman"] + + if args.run_podman: + unit_test_args += ["--run-podman"] subprocess.run(unit_test_args, check=True) @@ -37,7 +40,8 @@ if __name__ == "__main__": "--timeout=2400", "test", ] - if args.run_podman: + + if sys.platform.startswith("linux") and args.run_podman: integration_test_args += ["--run-podman"] subprocess.run(integration_test_args, check=True) From c4bb04567baaba1c8b5ffd24cb08fc4442c968af Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Wed, 29 Jun 2022 21:06:24 +0100 Subject: [PATCH 49/86] Add docs for CIBW_CONTAINER_ENGINE --- README.md | 1 + docs/options.md | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/README.md b/README.md index 74f2adf4..fb40fc7f 100644 --- a/README.md +++ b/README.md @@ -130,6 +130,7 @@ Options | | [`CIBW_BEFORE_BUILD`](https://cibuildwheel.readthedocs.io/en/stable/options/#before-build) | Execute a shell command preparing each wheel's build | | | [`CIBW_REPAIR_WHEEL_COMMAND`](https://cibuildwheel.readthedocs.io/en/stable/options/#repair-wheel-command) | Execute a shell command to repair each built wheel | | | [`CIBW_MANYLINUX_*_IMAGE`
`CIBW_MUSLLINUX_*_IMAGE`](https://cibuildwheel.readthedocs.io/en/stable/options/#linux-image) | Specify alternative manylinux / musllinux Docker images | +| | [`CIBW_CONTAINER_ENGINE`](https://cibuildwheel.readthedocs.io/en/stable/options/#container-engine) | Specify which container engine to use when building Linux wheels | | | [`CIBW_DEPENDENCY_VERSIONS`](https://cibuildwheel.readthedocs.io/en/stable/options/#dependency-versions) | Specify how cibuildwheel controls the versions of the tools it uses | | **Testing** | [`CIBW_TEST_COMMAND`](https://cibuildwheel.readthedocs.io/en/stable/options/#test-command) | Execute a shell command to test each built wheel | | | [`CIBW_BEFORE_TEST`](https://cibuildwheel.readthedocs.io/en/stable/options/#before-test) | Execute a shell command before testing each wheel | diff --git a/docs/options.md b/docs/options.md index 01ac29b0..6b899654 100644 --- a/docs/options.md +++ b/docs/options.md @@ -964,6 +964,44 @@ Auditwheel detects the version of the manylinux / musllinux standard in the imag Like any other option, these can be placed in `[tool.cibuildwheel.linux]` if you prefer; they have no effect on `macos` and `windows`. + +### `CIBW_CONTAINER_ENGINE` {: #container-engine} +> Specify which container engine to use when building Linux wheels + +Options: `docker` `podman` + +Default: `docker` + +Set the container engine to use. Docker is the default, or you can switch to +[Podman](https://podman.io/). To use Docker, you need to have a Docker daemon +running and `docker` available on PATH. To use Podman, it needs to be +installed and `podman` available on PATH. + +!!! tip + + While most users will stick with Docker, Podman is available in different + contexts - for example, it can be run inside a Docker container, or without + root access. Thanks to the [OCI], images are compatible between engines, so + you can still use the regular manylinux/musllinux containers. + +[OCI]: https://opencontainers.org/ + +#### Examples + +!!! tab examples "Environment variables" + + ```yaml + CIBW_CONTAINER_ENGINE: podman + ``` + +!!! tab examples "pyproject.toml" + + ```toml + [tool.cibuildwheel] + container-engine = "podman" + ``` + + ### `CIBW_DEPENDENCY_VERSIONS` {: #dependency-versions} > Specify how cibuildwheel controls the versions of the tools it uses @@ -1029,6 +1067,7 @@ Platform-specific environment variables are also available:
dependency-versions = "./constraints.txt" ``` + ## Testing ### `CIBW_TEST_COMMAND` {: #test-command} From 25c1bf53d079d1fa52a5144b63bca3e66d8e21d4 Mon Sep 17 00:00:00 2001 From: mayeut Date: Sun, 22 May 2022 14:32:04 +0200 Subject: [PATCH 50/86] action: use the most recent python from tool cache to run the GitHub Action --- .github/workflows/test.yml | 13 +++++++++++++ action.yml | 7 +++++++ 2 files changed, 20 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a588b526..af03e3f4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -66,6 +66,19 @@ jobs: name: sample_wheels path: wheelhouse + - name: Get some sample wheels (GitHub Action) + uses: ./ + with: + package-dir: sample_proj + output-dir: wheelhouse_action + env: + CIBW_ARCHS_MACOS: x86_64 universal2 arm64 + + - uses: actions/upload-artifact@v3 + with: + name: sample_wheels_action + path: wheelhouse_action + - name: Test cibuildwheel run: | python ./bin/run_tests.py diff --git a/action.yml b/action.yml index 703cb33a..677883a2 100644 --- a/action.yml +++ b/action.yml @@ -20,10 +20,17 @@ branding: runs: using: composite steps: + # Set up a non-EOL, cibuildwheel & pipx supported Python version + - uses: actions/setup-python@766e8c60885ef280a3e447209d1f1083b3c7039d + id: python + with: + python-version: "3.7 - 3.10" + update-environment: false # Redirecting stderr to stdout to fix interleaving issue in Actions. - run: > pipx run + --python '${{ steps.python.outputs.python-path }}' --spec '${{ github.action_path }}' cibuildwheel ${{ inputs.package-dir }} From 075792473a7e6ffa59040b0dc66dc2b4d85b3e77 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Wed, 29 Jun 2022 18:10:35 -0400 Subject: [PATCH 51/86] chore: simpler dependabot (#1165) * chore: simpler dependabot Ignores no longer needed after April 2022. Dependabot keeps the same style pinning now. * Update faq.md --- .github/dependabot.yml | 3 --- docs/faq.md | 4 ---- 2 files changed, 7 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index ce05ac5c..6fddca0d 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,6 +5,3 @@ updates: directory: "/" schedule: interval: "weekly" - ignore: - - dependency-name: "actions/*" - update-types: ["version-update:semver-minor", "version-update:semver-patch"] diff --git a/docs/faq.md b/docs/faq.md index 66c05618..b66bd0e4 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -147,10 +147,6 @@ updates: directory: "/" schedule: interval: "weekly" - ignore: - # Optional: Official actions have moving tags like v1; - # if you use those, you don't need updates. - - dependency-name: "actions/*" ``` #### Option 2: Requirement files From a3616700f5246548220fab6afc19b44535520bdb Mon Sep 17 00:00:00 2001 From: joncrall Date: Wed, 29 Jun 2022 21:00:15 -0400 Subject: [PATCH 52/86] Pass cwd to first two calls --- cibuildwheel/oci_container.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cibuildwheel/oci_container.py b/cibuildwheel/oci_container.py index 3550a88c..c02f7678 100644 --- a/cibuildwheel/oci_container.py +++ b/cibuildwheel/oci_container.py @@ -110,13 +110,13 @@ class OCIContainer: self.bash_stdout = self.process.stdout # run a noop command to block until the container is responding - self.call(["/bin/true"]) + self.call(["/bin/true"], cwd="/") if self.cwd: # Although `docker create -w` does create the working dir if it # does not exist, podman does not. There does not seem to be a way # to setup a workdir for a container running in podman. - self.call(["mkdir", "-p", os.fspath(self.cwd)]) + self.call(["mkdir", "-p", os.fspath(self.cwd)], cwd="/") return self From 9a537512c141c050e89f7b6e251f6dfb9b0898a7 Mon Sep 17 00:00:00 2001 From: Matthieu Darbois Date: Sun, 3 Jul 2022 20:00:00 +0200 Subject: [PATCH 53/86] feat: add support for `py3-none-{platform}` wheels (#1151) * feature: add support for `py3-none-{platform}` wheels This extends the mechanism introduced in #1091 for `abi3` wheels. Most of the mentions to `abi3` have been removed and replaced by a more generic `compatible_wheel`. This allows to build a wheel `foo-0.1-py3-none-win_amd64.whl` only once and still test with every configured python. * Add integration test for py3-none abi wheels * Fix expected_wheels for py3-none abi * Limit test to three pythons and check for certain log messages * chore: add some comments to explain filter process Co-authored-by: Joe Rickerby Co-authored-by: Henry Schreiner --- cibuildwheel/linux.py | 12 +-- cibuildwheel/macos.py | 12 +-- cibuildwheel/util.py | 37 +++++--- cibuildwheel/windows.py | 12 +-- setup.cfg | 4 +- test/test_abi_variants.py | 179 ++++++++++++++++++++++++++++++++++++++ test/test_limited_api.py | 50 ----------- test/utils.py | 34 ++++---- unit_test/utils_test.py | 44 +++++++++- 9 files changed, 284 insertions(+), 100 deletions(-) create mode 100644 test/test_abi_variants.py delete mode 100644 test/test_limited_api.py diff --git a/cibuildwheel/linux.py b/cibuildwheel/linux.py index b278d48b..70f91c10 100644 --- a/cibuildwheel/linux.py +++ b/cibuildwheel/linux.py @@ -13,7 +13,7 @@ from .typing import OrderedDict, PathOrStr, assert_never from .util import ( BuildSelector, NonPlatformWheelError, - find_compatible_abi3_wheel, + find_compatible_wheel, get_build_verbosity_extra_flags, prepare_command, read_python_configs, @@ -180,13 +180,13 @@ def build_on_docker( ) sys.exit(1) - abi3_wheel = find_compatible_abi3_wheel(built_wheels, config.identifier) - if abi3_wheel: + compatible_wheel = find_compatible_wheel(built_wheels, config.identifier) + if compatible_wheel: log.step_end() print( - f"\nFound previously built wheel {abi3_wheel.name}, that's compatible with {config.identifier}. Skipping build step..." + f"\nFound previously built wheel {compatible_wheel.name}, that's compatible with {config.identifier}. Skipping build step..." ) - repaired_wheels = [abi3_wheel] + repaired_wheels = [compatible_wheel] else: if build_options.before_build: @@ -307,7 +307,7 @@ def build_on_docker( docker.call(["rm", "-rf", venv_dir]) # move repaired wheels to output - if abi3_wheel is None: + if compatible_wheel is None: docker.call(["mkdir", "-p", container_output_dir]) docker.call(["mv", *repaired_wheels, container_output_dir]) built_wheels.extend( diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index 2da719ea..22213de8 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -24,7 +24,7 @@ from .util import ( call, detect_ci_provider, download, - find_compatible_abi3_wheel, + find_compatible_wheel, get_build_verbosity_extra_flags, get_pip_version, install_certifi_script, @@ -323,13 +323,13 @@ def build(options: Options, tmp_path: Path) -> None: build_options.build_frontend, ) - abi3_wheel = find_compatible_abi3_wheel(built_wheels, config.identifier) - if abi3_wheel: + compatible_wheel = find_compatible_wheel(built_wheels, config.identifier) + if compatible_wheel: log.step_end() print( - f"\nFound previously built wheel {abi3_wheel.name}, that's compatible with {config.identifier}. Skipping build step..." + f"\nFound previously built wheel {compatible_wheel.name}, that's compatible with {config.identifier}. Skipping build step..." ) - repaired_wheel = abi3_wheel + repaired_wheel = compatible_wheel else: if build_options.before_build: log.step("Running before_build...") @@ -536,7 +536,7 @@ def build(options: Options, tmp_path: Path) -> None: ) # we're all done here; move it to output (overwrite existing) - if abi3_wheel is None: + if compatible_wheel is None: try: (build_options.output_dir / repaired_wheel.name).unlink() except FileNotFoundError: diff --git a/cibuildwheel/util.py b/cibuildwheel/util.py index 9bc151cc..d3f42bda 100644 --- a/cibuildwheel/util.py +++ b/cibuildwheel/util.py @@ -53,7 +53,7 @@ __all__ = [ "MANYLINUX_ARCHS", "call", "shell", - "find_compatible_abi3_wheel", + "find_compatible_wheel", "format_safe", "prepare_command", "get_build_verbosity_extra_flags", @@ -575,36 +575,47 @@ def virtualenv( T = TypeVar("T", bound=PurePath) -def find_compatible_abi3_wheel(wheels: Sequence[T], identifier: str) -> Optional[T]: +def find_compatible_wheel(wheels: Sequence[T], identifier: str) -> Optional[T]: """ - Finds an ABI3 wheel in `wheels` compatible with the Python interpreter - specified by `identifier`. + Finds a wheel with an abi3 or a none ABI tag in `wheels` compatible with the Python interpreter + specified by `identifier` that is previously built. """ interpreter, platform = identifier.split("-") - if not interpreter.startswith("cp3"): - return None for wheel in wheels: _, _, _, tags = parse_wheel_filename(wheel.name) for tag in tags: - if tag.abi != "abi3": + if tag.abi == "abi3": + # ABI3 wheels must start with cp3 for impl and tag + if not (interpreter.startswith("cp3") and tag.interpreter.startswith("cp3")): + continue + elif tag.abi == "none": + # CPythonless wheels must include py3 tag + if tag.interpreter[:3] != "py3": + continue + else: + # Other types of wheels are not detected, this is looking for previously built wheels. continue - if not tag.interpreter.startswith("cp3"): - continue - if int(tag.interpreter[3:]) > int(interpreter[3:]): + + if tag.interpreter != "py3" and int(tag.interpreter[3:]) > int(interpreter[3:]): + # If a minor version number is given, it has to be lower than the current one. continue + if platform.startswith(("manylinux", "musllinux", "macosx")): - # Linux, macOS + # Linux, macOS require the beginning and ending match (macos/manylinux version doesn't need to) os_, arch = platform.split("_", 1) if not tag.platform.startswith(os_): continue - if not tag.platform.endswith("_" + arch): + if not tag.platform.endswith(f"_{arch}"): continue else: - # Windows + # Windows should exactly match if not tag.platform == platform: continue + + # If all the filters above pass, then the wheel is a previously built compatible wheel. return wheel + return None diff --git a/cibuildwheel/windows.py b/cibuildwheel/windows.py index 0ad2e2ae..46b8bf90 100644 --- a/cibuildwheel/windows.py +++ b/cibuildwheel/windows.py @@ -23,7 +23,7 @@ from .util import ( NonPlatformWheelError, call, download, - find_compatible_abi3_wheel, + find_compatible_wheel, get_build_verbosity_extra_flags, get_pip_version, prepare_command, @@ -279,13 +279,13 @@ def build(options: Options, tmp_path: Path) -> None: build_options.build_frontend, ) - abi3_wheel = find_compatible_abi3_wheel(built_wheels, config.identifier) - if abi3_wheel: + compatible_wheel = find_compatible_wheel(built_wheels, config.identifier) + if compatible_wheel: log.step_end() print( - f"\nFound previously built wheel {abi3_wheel.name}, that's compatible with {config.identifier}. Skipping build step..." + f"\nFound previously built wheel {compatible_wheel.name}, that's compatible with {config.identifier}. Skipping build step..." ) - repaired_wheel = abi3_wheel + repaired_wheel = compatible_wheel else: # run the before_build command if build_options.before_build: @@ -420,7 +420,7 @@ def build(options: Options, tmp_path: Path) -> None: shell(test_command_prepared, cwd="c:\\", env=virtualenv_env) # we're all done here; move it to output (remove if already exists) - if abi3_wheel is None: + if compatible_wheel is None: shutil.move(str(repaired_wheel), build_options.output_dir) built_wheels.append(build_options.output_dir / repaired_wheel.name) diff --git a/setup.cfg b/setup.cfg index 4f91bf92..838631e0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -56,8 +56,8 @@ console_scripts = cibuildwheel = resources/* [flake8] -extend-ignore = E203,E501,B950 -extend-select = B,B9 +extend-ignore = E203,E501,B950,B023 +extend-select = B9 application-import-names = cibuildwheel exclude = cibuildwheel/resources/, diff --git a/test/test_abi_variants.py b/test/test_abi_variants.py new file mode 100644 index 00000000..932a2ec0 --- /dev/null +++ b/test/test_abi_variants.py @@ -0,0 +1,179 @@ +import textwrap + +from . import test_projects, utils + +limited_api_project = test_projects.new_c_project( + setup_py_add=textwrap.dedent( + r""" + cmdclass = {} + extension_kwargs = {} + if sys.version_info[:2] >= (3, 8): + from wheel.bdist_wheel import bdist_wheel as _bdist_wheel + + class bdist_wheel_abi3(_bdist_wheel): + def finalize_options(self): + _bdist_wheel.finalize_options(self) + self.root_is_pure = False + + def get_tag(self): + python, abi, plat = _bdist_wheel.get_tag(self) + return python, "abi3", plat + + cmdclass["bdist_wheel"] = bdist_wheel_abi3 + extension_kwargs["define_macros"] = [("Py_LIMITED_API", "0x03080000")] + extension_kwargs["py_limited_api"] = True + """ + ), + setup_py_extension_args_add="**extension_kwargs", + setup_py_setup_args_add="cmdclass=cmdclass", +) + + +def test_abi3(tmp_path): + project_dir = tmp_path / "project" + limited_api_project.generate(project_dir) + + # build the wheels + actual_wheels = utils.cibuildwheel_run( + project_dir, + add_env={ + "CIBW_SKIP": "pp* ", # PyPy does not have a Py_LIMITED_API equivalent + }, + ) + + # check that the expected wheels are produced + expected_wheels = [ + w.replace("cp38-cp38", "cp38-abi3") + for w in utils.expected_wheels("spam", "0.1.0") + if "-pp" not in w and "-cp39" not in w and "-cp310" not in w and "-cp311" not in w + ] + assert set(actual_wheels) == set(expected_wheels) + + +ctypes_project = test_projects.TestProject() +ctypes_project.files["setup.py"] = textwrap.dedent( + """ + from setuptools import setup, Extension + + from distutils.command.build_ext import build_ext as _build_ext + class CTypesExtension(Extension): pass + class build_ext(_build_ext): + def build_extension(self, ext): + self._ctypes = isinstance(ext, CTypesExtension) + return super().build_extension(ext) + + def get_export_symbols(self, ext): + if self._ctypes: + return ext.export_symbols + return super().get_export_symbols(ext) + + def get_ext_filename(self, ext_name): + if self._ctypes: + return ext_name + '.so' + return super().get_ext_filename(ext_name) + + from wheel.bdist_wheel import bdist_wheel as _bdist_wheel + class bdist_wheel_abi_none(_bdist_wheel): + def finalize_options(self): + _bdist_wheel.finalize_options(self) + self.root_is_pure = False + + def get_tag(self): + python, abi, plat = _bdist_wheel.get_tag(self) + return "py3", "none", plat + + setup( + name="ctypesexample", + version="1.0.0", + py_modules = ["ctypesexample.summing"], + ext_modules=[ + CTypesExtension( + "ctypesexample.csumlib", + ["ctypesexample/csumlib.c"], + ), + ], + cmdclass={'build_ext': build_ext, 'bdist_wheel': bdist_wheel_abi_none}, + ) + """ +) +ctypes_project.files["ctypesexample/csumlib.c"] = textwrap.dedent( + """ + #ifdef _WIN32 + #define LIBRARY_API __declspec(dllexport) + #else + #define LIBRARY_API + #endif + + #include + + + LIBRARY_API double *add_vec3(double *a, double *b) + { + double *res = malloc(sizeof(double) * 3); + + for (int i = 0; i < 3; ++i) + { + res[i] = a[i] + b[i]; + } + + return res; + } + """ +) +ctypes_project.files["ctypesexample/summing.py"] = textwrap.dedent( + """ + import ctypes + import pathlib + + # path of the shared library + libfile = pathlib.Path(__file__).parent / "csumlib.so" + csumlib = ctypes.CDLL(str(libfile)) + + type_vec3 = ctypes.POINTER(ctypes.c_double * 3) + + csumlib.add_vec3.restype = type_vec3 + csumlib.add_vec3.argtypes = [type_vec3, type_vec3] + def add(a: list, b: list) -> list: + a_p = (ctypes.c_double * 3)(*a) + b_p = (ctypes.c_double * 3)(*b) + r_p = csumlib.add_vec3(a_p,b_p) + + return [l for l in r_p.contents] + """ +) + +ctypes_project.files["test/add_test.py"] = textwrap.dedent( + """ + import ctypesexample.summing + + def test(): + a = [1, 2, 3] + b = [4, 5, 6] + assert ctypesexample.summing.add(a, b) == [5, 7, 9] + """ +) + + +def test_abi_none(tmp_path, capfd): + project_dir = tmp_path / "project" + ctypes_project.generate(project_dir) + + # build the wheels + actual_wheels = utils.cibuildwheel_run( + project_dir, + add_env={ + "CIBW_TEST_REQUIRES": "pytest", + "CIBW_TEST_COMMAND": "pytest {project}/test", + # limit the number of builds for test performance reasons + "CIBW_BUILD": "cp38-* cp310-* pp39-*", + }, + ) + + # check that the expected wheels are produced + expected_wheels = utils.expected_wheels("ctypesexample", "1.0.0", python_abi_tags=["py3-none"]) + assert set(actual_wheels) == set(expected_wheels) + + # check that each wheel was built once, and reused + captured = capfd.readouterr() + assert "Building wheel..." in captured.out + assert "Found previously built wheel" in captured.out diff --git a/test/test_limited_api.py b/test/test_limited_api.py deleted file mode 100644 index ea173bf5..00000000 --- a/test/test_limited_api.py +++ /dev/null @@ -1,50 +0,0 @@ -import textwrap - -from . import test_projects, utils - -limited_api_project = test_projects.new_c_project( - setup_py_add=textwrap.dedent( - r""" - cmdclass = {} - extension_kwargs = {} - if sys.version_info[:2] >= (3, 8): - from wheel.bdist_wheel import bdist_wheel as _bdist_wheel - - class bdist_wheel_abi3(_bdist_wheel): - def finalize_options(self): - _bdist_wheel.finalize_options(self) - self.root_is_pure = False - - def get_tag(self): - python, abi, plat = _bdist_wheel.get_tag(self) - return python, "abi3", plat - - cmdclass["bdist_wheel"] = bdist_wheel_abi3 - extension_kwargs["define_macros"] = [("Py_LIMITED_API", "0x03080000")] - extension_kwargs["py_limited_api"] = True - """ - ), - setup_py_extension_args_add="**extension_kwargs", - setup_py_setup_args_add="cmdclass=cmdclass", -) - - -def test(tmp_path): - project_dir = tmp_path / "project" - limited_api_project.generate(project_dir) - - # build the wheels - actual_wheels = utils.cibuildwheel_run( - project_dir, - add_env={ - "CIBW_SKIP": "pp* ", # PyPy does not have a Py_LIMITED_API equivalent - }, - ) - - # check that the expected wheels are produced - expected_wheels = [ - w.replace("cp38-cp38", "cp38-abi3") - for w in utils.expected_wheels("spam", "0.1.0") - if "-pp" not in w and "-cp39" not in w and "-cp310" not in w and "-cp311" not in w - ] - assert set(actual_wheels) == set(expected_wheels) diff --git a/test/utils.py b/test/utils.py index b6212021..d325be68 100644 --- a/test/utils.py +++ b/test/utils.py @@ -113,6 +113,7 @@ def expected_wheels( musllinux_versions=None, macosx_deployment_target="10.9", machine_arch=None, + python_abi_tags=None, ): """ Returns a list of expected wheels from a run of cibuildwheel. @@ -139,21 +140,22 @@ def expected_wheels( if musllinux_versions is None: musllinux_versions = ["musllinux_1_1"] - python_abi_tags = [ - "cp36-cp36m", - "cp37-cp37m", - "cp38-cp38", - "cp39-cp39", - "cp310-cp310", - "cp311-cp311", - ] + if python_abi_tags is None: + python_abi_tags = [ + "cp36-cp36m", + "cp37-cp37m", + "cp38-cp38", + "cp39-cp39", + "cp310-cp310", + "cp311-cp311", + ] - if machine_arch in ["x86_64", "AMD64", "x86", "aarch64"]: - python_abi_tags += ["pp37-pypy37_pp73", "pp38-pypy38_pp73", "pp39-pypy39_pp73"] + if machine_arch in ["x86_64", "AMD64", "x86", "aarch64"]: + python_abi_tags += ["pp37-pypy37_pp73", "pp38-pypy38_pp73", "pp39-pypy39_pp73"] - if platform == "macos" and machine_arch == "arm64": - # currently, arm64 macs are only supported by cp39, cp310 & cp311 - python_abi_tags = ["cp39-cp39", "cp310-cp310", "cp311-cp311"] + if platform == "macos" and machine_arch == "arm64": + # currently, arm64 macs are only supported by cp39, cp310 & cp311 + python_abi_tags = ["cp39-cp39", "cp310-cp310", "cp311-cp311"] wheels = [] @@ -185,10 +187,10 @@ def expected_wheels( ) elif platform == "windows": - if python_abi_tag.startswith("cp"): - platform_tags = ["win32", "win_amd64"] - else: + if python_abi_tag.startswith("pp"): platform_tags = ["win_amd64"] + else: + platform_tags = ["win32", "win_amd64"] elif platform == "macos": if python_abi_tag == "cp39-cp39" and machine_arch == "arm64": diff --git a/unit_test/utils_test.py b/unit_test/utils_test.py index 41e376fa..7f949a73 100644 --- a/unit_test/utils_test.py +++ b/unit_test/utils_test.py @@ -1,4 +1,8 @@ -from cibuildwheel.util import format_safe, prepare_command +from pathlib import PurePath + +import pytest + +from cibuildwheel.util import find_compatible_wheel, format_safe, prepare_command def test_format_safe(): @@ -46,3 +50,41 @@ def test_prepare_command(): prepare_command("{a}{a,b}{b:.2e}{c}{d%s}{e:3}{f[0]}", a="42", b="3.14159") == "42{a,b}{b:.2e}{c}{d%s}{e:3}{f[0]}" ) + + +@pytest.mark.parametrize( + "wheel,identifier", + ( + ("foo-0.1-cp38-abi3-win_amd64.whl", "cp310-win_amd64"), + ("foo-0.1-cp38-abi3-macosx_11_0_x86_64.whl", "cp310-macosx_x86_64"), + ("foo-0.1-cp38-abi3-manylinux2014_x86_64.whl", "cp310-manylinux_x86_64"), + ("foo-0.1-cp38-abi3-musllinux_1_1_x86_64.whl", "cp310-musllinux_x86_64"), + ("foo-0.1-py2.py3-none-win_amd64.whl", "cp310-win_amd64"), + ("foo-0.1-py2.py3-none-win_amd64.whl", "pp310-win_amd64"), + ("foo-0.1-py3-none-win_amd64.whl", "cp310-win_amd64"), + ("foo-0.1-py38-none-win_amd64.whl", "cp310-win_amd64"), + ("foo-0.1-py38-none-win_amd64.whl", "pp310-win_amd64"), + ), +) +def test_find_compatible_wheel_found(wheel: str, identifier: str): + wheel_ = PurePath(wheel) + found = find_compatible_wheel([wheel_], identifier) + assert found is wheel_ + + +@pytest.mark.parametrize( + "wheel,identifier", + ( + ("foo-0.1-cp38-abi3-win_amd64.whl", "cp310-win32"), + ("foo-0.1-cp38-abi3-win_amd64.whl", "cp37-win_amd64"), + ("foo-0.1-cp38-abi3-macosx_11_0_x86_64.whl", "cp310-macosx_universal2"), + ("foo-0.1-cp38-abi3-manylinux2014_x86_64.whl", "cp310-musllinux_x86_64"), + ("foo-0.1-cp38-abi3-musllinux_1_1_x86_64.whl", "cp310-manylinux_x86_64"), + ("foo-0.1-py2-none-win_amd64.whl", "cp310-win_amd64"), + ("foo-0.1-py38-none-win_amd64.whl", "cp37-win_amd64"), + ("foo-0.1-py38-none-win_amd64.whl", "pp37-win_amd64"), + ("foo-0.1-cp38-cp38-win_amd64.whl", "cp310-win_amd64"), + ), +) +def test_find_compatible_wheel_not_found(wheel: str, identifier: str): + assert find_compatible_wheel([PurePath(wheel)], identifier) is None From d02366f547da8b363d9bd2cf3bdefc7f17090cc8 Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Sun, 3 Jul 2022 19:00:19 +0100 Subject: [PATCH 54/86] fix: multiple version tags per release bug in release tooling (#1166) --- bin/bump_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/bump_version.py b/bin/bump_version.py index 7e2b1b30..cab036ca 100755 --- a/bin/bump_version.py +++ b/bin/bump_version.py @@ -184,7 +184,7 @@ def bump_version() -> None: print() release_url = "https://github.com/pypa/cibuildwheel/releases/new?" + urllib.parse.urlencode( - {"tag": new_version} + {"tag": f"v{new_version}"} ) print("Then create a release at the URL:") print(f" {release_url}") From c4f1c31ccc68bd3311a0e84e861993c771641bba Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 5 Jul 2022 09:13:25 -0400 Subject: [PATCH 55/86] chore(deps): bump actions/setup-python from 3 to 4 (#1134) * chore(deps): bump actions/setup-python from 3 to 4 Bumps [actions/setup-python](https://github.com/actions/setup-python) from 3 to 4. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] * Apply suggestions from code review Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Henry Schreiner --- .github/workflows/test.yml | 10 +++++++--- .github/workflows/update-dependencies.yml | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a588b526..b142f1c7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,7 +20,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: actions/setup-python@v3 + - uses: actions/setup-python@v4 + with: + python-version: "3.x" - uses: pre-commit/action@v3.0.0 - name: Check manifest run: pipx run nox -s check_manifest @@ -40,7 +42,7 @@ jobs: timeout-minutes: 180 steps: - uses: actions/checkout@v3 - - uses: actions/setup-python@v3 + - uses: actions/setup-python@v4 name: Install Python ${{ matrix.python_version }} with: python-version: ${{ matrix.python_version }} @@ -77,7 +79,9 @@ jobs: timeout-minutes: 180 steps: - uses: actions/checkout@v3 - - uses: actions/setup-python@v3 + - uses: actions/setup-python@v4 + with: + python-version: "3.x" - name: Install dependencies run: | python -m pip install ".[test]" diff --git a/.github/workflows/update-dependencies.yml b/.github/workflows/update-dependencies.yml index 40af3595..208b36c4 100644 --- a/.github/workflows/update-dependencies.yml +++ b/.github/workflows/update-dependencies.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: actions/setup-python@v3 + - uses: actions/setup-python@v4 with: python-version: "3.11-dev" - uses: excitedleigh/setup-nox@v2.1.0 From 227125cdf8633b7935ef468b760cf5ce2dfb07a6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 5 Jul 2022 09:13:34 -0400 Subject: [PATCH 56/86] [pre-commit.ci] pre-commit autoupdate (#1167) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 22.3.0 → 22.6.0](https://github.com/psf/black/compare/22.3.0...22.6.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 89126ed2..1b4863c0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -39,7 +39,7 @@ repos: - id: isort - repo: https://github.com/psf/black - rev: 22.3.0 + rev: 22.6.0 hooks: - id: black From 40f92bd1bc2e2218ff7af41be677aaecdc14f8ac Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Tue, 5 Jul 2022 17:15:09 +0100 Subject: [PATCH 57/86] Proposal to improve this doc entry --- docs/options.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/options.md b/docs/options.md index d3b4c107..416763e5 100644 --- a/docs/options.md +++ b/docs/options.md @@ -635,7 +635,7 @@ To specify more than one environment variable, separate the variable names by sp ### `CIBW_BEFORE_ALL` {: #before-all} > Execute a shell command on the build system before any wheels are built. -Shell command that runs before creating Python environment, to build or install parts that do not depend on the specific version of Python. +Shell command that runs before any builds are run, to build or install parts that do not depend on the specific version of Python. This option is very useful for the Linux build, where builds take place in isolated Docker containers managed by cibuildwheel. This command will run inside the container before the wheel builds start. Note, if you're building both `x86_64` and `i686` wheels (the default), your build uses two different Docker images. In that case, this command will execute twice - once per build container. @@ -650,6 +650,10 @@ on macOS and Windows. Platform-specific environment variables also available:
`CIBW_BEFORE_ALL_MACOS` | `CIBW_BEFORE_ALL_WINDOWS` | `CIBW_BEFORE_ALL_LINUX` +!!! note + + This command is executed in a different Python environment from the builds themselves. So you can't `pip install` a Python dependency in CIBW_BEFORE_ALL and use it in the build. Instead, look at [`CIBW_BEFORE_BUILD`](#before-build), or, if your project uses pyproject.toml, the [build-system.requires](https://peps.python.org/pep-0518/#build-system-table) field. + #### Examples !!! tab examples "Environment variables" From 5ef488ba307a34c0e4bf4e55384ff8dbe470226a Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Tue, 5 Jul 2022 18:33:12 +0100 Subject: [PATCH 58/86] Bump version: v2.8.0 --- README.md | 24 ++++++++++-------------- cibuildwheel/__init__.py | 2 +- docs/changelog.md | 9 +++++++++ docs/faq.md | 4 ++-- docs/setup.md | 4 ++-- examples/appveyor-minimal.yml | 2 +- examples/azure-pipelines-minimal.yml | 6 +++--- examples/circleci-minimal.yml | 4 ++-- examples/github-apple-silicon.yml | 2 +- examples/github-deploy.yml | 2 +- examples/github-minimal.yml | 2 +- examples/github-with-qemu.yml | 2 +- examples/gitlab-minimal.yml | 2 +- examples/travis-ci-deploy.yml | 2 +- examples/travis-ci-minimal.yml | 2 +- examples/travis-ci-test-and-deploy.yml | 4 ++-- setup.cfg | 2 +- 17 files changed, 40 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index fb40fc7f..5d51e90c 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,7 @@ jobs: - uses: actions/setup-python@v3 - name: Install cibuildwheel - run: python -m pip install cibuildwheel==2.7.0 + run: python -m pip install cibuildwheel==2.8.0 - name: Build wheels run: python -m cibuildwheel --output-dir wheelhouse @@ -204,6 +204,15 @@ Changelog +### v2.8.0 + +_5 July 2022_ + +- ✨ You can now run cibuildwheel on Podman, as an alternate container engine to Docker, which remains the default. This is useful in environments where a Docker daemon isn't available, for example, it can be run inside a Docker container, or without root access. To use Podman, set the [`CIBW_CONTAINER_ENGINE`](https://cibuildwheel.readthedocs.io/en/stable/options/#container-engine) option. (#966) +- ✨ Adds support for building `py3-none-{platform}` wheels. These wheels contain native extension code, but don't use the Python APIs. Typically, they're bridged to Python using a FFI module like [ctypes](https://docs.python.org/3/library/ctypes.html) or [cffi](https://cffi.readthedocs.io/en/latest/). Because they don't use Python ABI, the wheels are more compatible - they work across many Python versions. Check out this [example ctypes project](https://github.com/joerick/python-ctypes-package-sample) to see an example of how it works. (#1151) +- 🛠 cibuildwheel will now error if multiple builds in a single run produce the same wheel filename, as this indicates a misconfiguration. (#1152) +- 📚 A few docs improvements and updates to keep things up-to-date. + ### v2.7.0 _17 June 2022_ @@ -236,19 +245,6 @@ _29 April 2022_ - 🐛 Workaround a permissions issue on Linux relating to newer versions of git and setuptools_scm (#1095) - 📚 Minor docs improvements -### v2.4.0 - -_2 April 2022_ - -- ✨ cibuildwheel now supports running locally on Windows and macOS (as well as Linux). On macOS, you'll have to install the versions of Pythons that you want to use from Python.org, and cibuildwheel will use them. On Windows, cibuildwheel will install it's own versions of Python. Check out [the documentation](https://cibuildwheel.readthedocs.io/en/stable/setup/#local) for instructions. (#974) -- ✨ Added support for building PyPy 3.9 wheels. (#1031) -- ✨ Listing at the end of the build now displays the size of each wheel (#975) -- 🐛 Workaround a connection timeout bug on Travis CI ppc64le runners (#906) -- 🐛 Fix an encoding error when reading setup.py in the wrong encoding (#977) -- 🛠 Setuptools updated to 61.3.0, including experimental support for reading config from pyproject.toml(PEP 621). This could change the behaviour of your build if you have a pyproject.toml with a `[project]` table, because that takes precedence over setup.py and setup.cfg. Check out the [setuptools docs](https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html) and the [project metadata specification](https://packaging.python.org/en/latest/specifications/declaring-project-metadata/) for more info. -- 🛠 Many other dependency updates. -- 📚 Minor docs improvements - --- diff --git a/cibuildwheel/__init__.py b/cibuildwheel/__init__.py index 2614ce9d..892994aa 100644 --- a/cibuildwheel/__init__.py +++ b/cibuildwheel/__init__.py @@ -1 +1 @@ -__version__ = "2.7.0" +__version__ = "2.8.0" diff --git a/docs/changelog.md b/docs/changelog.md index 29928223..16015c49 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -2,6 +2,15 @@ title: Changelog --- +### v2.8.0 + +_5 July 2022_ + +- ✨ You can now run cibuildwheel on Podman, as an alternate container engine to Docker, which remains the default. This is useful in environments where a Docker daemon isn't available, for example, it can be run inside a Docker container, or without root access. To use Podman, set the [`CIBW_CONTAINER_ENGINE`](https://cibuildwheel.readthedocs.io/en/stable/options/#container-engine) option. (#966) +- ✨ Adds support for building `py3-none-{platform}` wheels. These wheels contain native extension code, but don't use the Python APIs. Typically, they're bridged to Python using a FFI module like [ctypes](https://docs.python.org/3/library/ctypes.html) or [cffi](https://cffi.readthedocs.io/en/latest/). Because they don't use Python ABI, the wheels are more compatible - they work across many Python versions. Check out this [example ctypes project](https://github.com/joerick/python-ctypes-package-sample) to see an example of how it works. (#1151) +- 🛠 cibuildwheel will now error if multiple builds in a single run produce the same wheel filename, as this indicates a misconfiguration. (#1152) +- 📚 A few docs improvements and updates to keep things up-to-date. + ### v2.7.0 _17 June 2022_ diff --git a/docs/faq.md b/docs/faq.md index 114df06d..18756756 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -133,7 +133,7 @@ There are two suggested methods for keeping cibuildwheel up to date that instead If you use GitHub Actions for builds, you can use cibuildwheel as an action: ```yaml -uses: pypa/cibuildwheel@v2.7.0 +uses: pypa/cibuildwheel@v2.8.0 ``` This is a composite step that just runs cibuildwheel using pipx. You can set command-line options as `with:` parameters, and use `env:` as normal. @@ -155,7 +155,7 @@ The second option, and the only one that supports other CI systems, is using a ` ```bash # requirements-cibw.txt -cibuildwheel==2.7.0 +cibuildwheel==2.8.0 ``` Then your install step would have `python -m pip install -r requirements-cibw.txt` in it. Your `.github/dependabot.yml` file could look like this: diff --git a/docs/setup.md b/docs/setup.md index 5af62a5f..73aa8619 100644 --- a/docs/setup.md +++ b/docs/setup.md @@ -182,7 +182,7 @@ To build Linux, Mac, and Windows wheels using GitHub Actions, create a `.github/ - uses: actions/checkout@v3 - name: Build wheels - run: pipx run cibuildwheel==2.7.0 + run: pipx run cibuildwheel==2.8.0 - uses: actions/upload-artifact@v3 with: @@ -217,7 +217,7 @@ To build Linux, Mac, and Windows wheels using GitHub Actions, create a `.github/ - uses: actions/setup-python@v3 - name: Install cibuildwheel - run: python -m pip install cibuildwheel==2.7.0 + run: python -m pip install cibuildwheel==2.8.0 - name: Build wheels run: python -m cibuildwheel --output-dir wheelhouse diff --git a/examples/appveyor-minimal.yml b/examples/appveyor-minimal.yml index a943ac36..2d12d54e 100644 --- a/examples/appveyor-minimal.yml +++ b/examples/appveyor-minimal.yml @@ -12,7 +12,7 @@ stack: python 3.7 init: - cmd: set PATH=C:\Python37;C:\Python37\Scripts;%PATH% -install: python -m pip install cibuildwheel==2.7.0 +install: python -m pip install cibuildwheel==2.8.0 build_script: python -m cibuildwheel --output-dir wheelhouse diff --git a/examples/azure-pipelines-minimal.yml b/examples/azure-pipelines-minimal.yml index 4a275835..de1847e6 100644 --- a/examples/azure-pipelines-minimal.yml +++ b/examples/azure-pipelines-minimal.yml @@ -6,7 +6,7 @@ jobs: - bash: | set -o errexit python3 -m pip install --upgrade pip - pip3 install cibuildwheel==2.7.0 + pip3 install cibuildwheel==2.8.0 displayName: Install dependencies - bash: cibuildwheel --output-dir wheelhouse . displayName: Build wheels @@ -20,7 +20,7 @@ jobs: - bash: | set -o errexit python3 -m pip install --upgrade pip - python3 -m pip install cibuildwheel==2.7.0 + python3 -m pip install cibuildwheel==2.8.0 displayName: Install dependencies - bash: cibuildwheel --output-dir wheelhouse . displayName: Build wheels @@ -34,7 +34,7 @@ jobs: - bash: | set -o errexit python -m pip install --upgrade pip - pip install cibuildwheel==2.7.0 + pip install cibuildwheel==2.8.0 displayName: Install dependencies - bash: cibuildwheel --output-dir wheelhouse . displayName: Build wheels diff --git a/examples/circleci-minimal.yml b/examples/circleci-minimal.yml index 95eb1bcc..d490077f 100644 --- a/examples/circleci-minimal.yml +++ b/examples/circleci-minimal.yml @@ -11,7 +11,7 @@ jobs: - run: name: Build the Linux wheels. command: | - pip3 install --user cibuildwheel==2.7.0 + pip3 install --user cibuildwheel==2.8.0 cibuildwheel --output-dir wheelhouse - store_artifacts: path: wheelhouse/ @@ -25,7 +25,7 @@ jobs: - run: name: Build the OS X wheels. command: | - pip3 install cibuildwheel==2.7.0 + pip3 install cibuildwheel==2.8.0 cibuildwheel --output-dir wheelhouse - store_artifacts: path: wheelhouse/ diff --git a/examples/github-apple-silicon.yml b/examples/github-apple-silicon.yml index dd695220..eafdf216 100644 --- a/examples/github-apple-silicon.yml +++ b/examples/github-apple-silicon.yml @@ -10,7 +10,7 @@ jobs: - uses: actions/checkout@v3 - name: Build wheels - uses: pypa/cibuildwheel@v2.7.0 + uses: pypa/cibuildwheel@v2.8.0 env: CIBW_ARCHS_MACOS: x86_64 universal2 diff --git a/examples/github-deploy.yml b/examples/github-deploy.yml index df2e846c..bb4a4e31 100644 --- a/examples/github-deploy.yml +++ b/examples/github-deploy.yml @@ -22,7 +22,7 @@ jobs: - uses: actions/checkout@v3 - name: Build wheels - uses: pypa/cibuildwheel@v2.7.0 + uses: pypa/cibuildwheel@v2.8.0 - uses: actions/upload-artifact@v3 with: diff --git a/examples/github-minimal.yml b/examples/github-minimal.yml index a4c4a13b..8d6ce692 100644 --- a/examples/github-minimal.yml +++ b/examples/github-minimal.yml @@ -14,7 +14,7 @@ jobs: - uses: actions/checkout@v3 - name: Build wheels - uses: pypa/cibuildwheel@v2.7.0 + uses: pypa/cibuildwheel@v2.8.0 # env: # CIBW_SOME_OPTION: value # ... diff --git a/examples/github-with-qemu.yml b/examples/github-with-qemu.yml index 38fe7248..dcdcdbea 100644 --- a/examples/github-with-qemu.yml +++ b/examples/github-with-qemu.yml @@ -25,7 +25,7 @@ jobs: platforms: all - name: Build wheels - uses: pypa/cibuildwheel@v2.7.0 + uses: pypa/cibuildwheel@v2.8.0 env: # configure cibuildwheel to build native archs ('auto'), and some # emulated ones diff --git a/examples/gitlab-minimal.yml b/examples/gitlab-minimal.yml index 1a3d3b6b..8971b8fa 100644 --- a/examples/gitlab-minimal.yml +++ b/examples/gitlab-minimal.yml @@ -12,7 +12,7 @@ linux: DOCKER_TLS_CERTDIR: "" script: - curl -sSL https://get.docker.com/ | sh - - python -m pip install cibuildwheel==2.7.0 + - python -m pip install cibuildwheel==2.8.0 - cibuildwheel --output-dir wheelhouse artifacts: paths: diff --git a/examples/travis-ci-deploy.yml b/examples/travis-ci-deploy.yml index 9ad49bc6..6a26d576 100644 --- a/examples/travis-ci-deploy.yml +++ b/examples/travis-ci-deploy.yml @@ -19,7 +19,7 @@ jobs: - ln -s /c/Python38/python.exe /c/Python38/python3.exe install: - - python3 -m pip install cibuildwheel==2.7.0 + - python3 -m pip install cibuildwheel==2.8.0 script: # build the wheels, put them into './dist' diff --git a/examples/travis-ci-minimal.yml b/examples/travis-ci-minimal.yml index 4ff2971f..bbfabdb4 100644 --- a/examples/travis-ci-minimal.yml +++ b/examples/travis-ci-minimal.yml @@ -25,7 +25,7 @@ jobs: - ln -s /c/Python38/python.exe /c/Python38/python3.exe install: - - python3 -m pip install cibuildwheel==2.7.0 + - python3 -m pip install cibuildwheel==2.8.0 script: # build the wheels, put them into './wheelhouse' diff --git a/examples/travis-ci-test-and-deploy.yml b/examples/travis-ci-test-and-deploy.yml index db739623..61a34ce7 100644 --- a/examples/travis-ci-test-and-deploy.yml +++ b/examples/travis-ci-test-and-deploy.yml @@ -55,7 +55,7 @@ jobs: - stage: deploy name: Build and deploy Linux wheels services: docker - install: python3 -m pip install cibuildwheel==2.7.0 twine + install: python3 -m pip install cibuildwheel==2.8.0 twine script: python3 -m cibuildwheel --output-dir wheelhouse after_success: python3 -m twine upload --skip-existing wheelhouse/*.whl # Deploy on windows @@ -63,7 +63,7 @@ jobs: name: Build and deploy Windows wheels os: windows language: shell - install: python3 -m pip install cibuildwheel==2.7.0 twine + install: python3 -m pip install cibuildwheel==2.8.0 twine script: python3 -m cibuildwheel --output-dir wheelhouse after_success: python3 -m twine upload --skip-existing wheelhouse/*.whl diff --git a/setup.cfg b/setup.cfg index 838631e0..dab4ab94 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = cibuildwheel -version = 2.7.0 +version = 2.8.0 description = Build Python wheels on CI with minimal configuration. long_description = file: README.md long_description_content_type = text/markdown From f349304eb7f9f723a011a6d09cf261bec463a985 Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Tue, 5 Jul 2022 18:36:03 +0100 Subject: [PATCH 59/86] Small changelog wording changes --- README.md | 8 ++++++-- docs/changelog.md | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5d51e90c..84f1947b 100644 --- a/README.md +++ b/README.md @@ -208,8 +208,12 @@ Changelog _5 July 2022_ -- ✨ You can now run cibuildwheel on Podman, as an alternate container engine to Docker, which remains the default. This is useful in environments where a Docker daemon isn't available, for example, it can be run inside a Docker container, or without root access. To use Podman, set the [`CIBW_CONTAINER_ENGINE`](https://cibuildwheel.readthedocs.io/en/stable/options/#container-engine) option. (#966) -- ✨ Adds support for building `py3-none-{platform}` wheels. These wheels contain native extension code, but don't use the Python APIs. Typically, they're bridged to Python using a FFI module like [ctypes](https://docs.python.org/3/library/ctypes.html) or [cffi](https://cffi.readthedocs.io/en/latest/). Because they don't use Python ABI, the wheels are more compatible - they work across many Python versions. Check out this [example ctypes project](https://github.com/joerick/python-ctypes-package-sample) to see an example of how it works. (#1151) +- ✨ You can now run cibuildwheel on Podman, as an alternate container engine to Docker (which remains the default). This is useful in environments where a Docker daemon isn't available, for example, it can be run inside a Docker container, or without root access. To use Podman, set the [`CIBW_CONTAINER_ENGINE`](https://cibuildwheel.readthedocs.io/en/stable/options/#container-engine) option. (#966) +- ✨ Adds support for building `py3-none-{platform}` wheels. This works the same as ABI3 - wheels won't be rebuilt, but tests will still be run across all selected versions of Python. + + > These wheels contain native extension code, but don't use the Python APIs. Typically, they're bridged to Python using a FFI module like [ctypes](https://docs.python.org/3/library/ctypes.html) or [cffi](https://cffi.readthedocs.io/en/latest/). Because they don't use Python ABI, the wheels are more compatible - they work across many Python versions. + + Check out this [example ctypes project](https://github.com/joerick/python-ctypes-package-sample) to see an example of how it works. (#1151) - 🛠 cibuildwheel will now error if multiple builds in a single run produce the same wheel filename, as this indicates a misconfiguration. (#1152) - 📚 A few docs improvements and updates to keep things up-to-date. diff --git a/docs/changelog.md b/docs/changelog.md index 16015c49..f5f655fe 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -6,8 +6,12 @@ title: Changelog _5 July 2022_ -- ✨ You can now run cibuildwheel on Podman, as an alternate container engine to Docker, which remains the default. This is useful in environments where a Docker daemon isn't available, for example, it can be run inside a Docker container, or without root access. To use Podman, set the [`CIBW_CONTAINER_ENGINE`](https://cibuildwheel.readthedocs.io/en/stable/options/#container-engine) option. (#966) -- ✨ Adds support for building `py3-none-{platform}` wheels. These wheels contain native extension code, but don't use the Python APIs. Typically, they're bridged to Python using a FFI module like [ctypes](https://docs.python.org/3/library/ctypes.html) or [cffi](https://cffi.readthedocs.io/en/latest/). Because they don't use Python ABI, the wheels are more compatible - they work across many Python versions. Check out this [example ctypes project](https://github.com/joerick/python-ctypes-package-sample) to see an example of how it works. (#1151) +- ✨ You can now run cibuildwheel on Podman, as an alternate container engine to Docker (which remains the default). This is useful in environments where a Docker daemon isn't available, for example, it can be run inside a Docker container, or without root access. To use Podman, set the [`CIBW_CONTAINER_ENGINE`](https://cibuildwheel.readthedocs.io/en/stable/options/#container-engine) option. (#966) +- ✨ Adds support for building `py3-none-{platform}` wheels. This works the same as ABI3 - wheels won't be rebuilt, but tests will still be run across all selected versions of Python. + + > These wheels contain native extension code, but don't use the Python APIs. Typically, they're bridged to Python using a FFI module like [ctypes](https://docs.python.org/3/library/ctypes.html) or [cffi](https://cffi.readthedocs.io/en/latest/). Because they don't use Python ABI, the wheels are more compatible - they work across many Python versions. + + Check out this [example ctypes project](https://github.com/joerick/python-ctypes-package-sample) to see an example of how it works. (#1151) - 🛠 cibuildwheel will now error if multiple builds in a single run produce the same wheel filename, as this indicates a misconfiguration. (#1152) - 📚 A few docs improvements and updates to keep things up-to-date. From f423b51ea6fda66e9fafdc776fac6f14a488bee6 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Mon, 11 Jul 2022 09:34:04 -0500 Subject: [PATCH 60/86] Update action.yml --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 677883a2..a27269dd 100644 --- a/action.yml +++ b/action.yml @@ -21,7 +21,7 @@ runs: using: composite steps: # Set up a non-EOL, cibuildwheel & pipx supported Python version - - uses: actions/setup-python@766e8c60885ef280a3e447209d1f1083b3c7039d + - uses: actions/setup-python@v4 id: python with: python-version: "3.7 - 3.10" From d76bbb60465fecde81deb65b7e2263e912470a24 Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Mon, 11 Jul 2022 18:29:09 +0200 Subject: [PATCH 61/86] Consolidate Github Actions sample builds --- .github/workflows/test.yml | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index af03e3f4..18ab5739 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -49,35 +49,22 @@ jobs: run: | python -m pip install ".[test]" - - name: Sample build - if: "contains(github.event.pull_request.labels.*.name, 'CI: Sample build')" - run: | - python bin/sample_build.py - - - name: Get some sample wheels + - name: Generate a sample project run: | python -m test.test_projects test.test_0_basic.basic_project sample_proj - cibuildwheel --output-dir wheelhouse sample_proj - env: - CIBW_ARCHS_MACOS: x86_64 universal2 arm64 - - uses: actions/upload-artifact@v3 - with: - name: sample_wheels - path: wheelhouse - - - name: Get some sample wheels (GitHub Action) + - name: Run a sample build (GitHub Action) uses: ./ with: package-dir: sample_proj - output-dir: wheelhouse_action + output-dir: wheelhouse env: CIBW_ARCHS_MACOS: x86_64 universal2 arm64 - uses: actions/upload-artifact@v3 with: name: sample_wheels_action - path: wheelhouse_action + path: wheelhouse - name: Test cibuildwheel run: | From de53d483733914936efffd0ebe658f4b96f18b28 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Tue, 12 Jul 2022 08:46:45 -0500 Subject: [PATCH 62/86] ci: try ubuntu 18.04 --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9bcf4187..6861e96f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -37,7 +37,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, windows-latest, macos-11] + os: [ubuntu-18.04, windows-latest, macos-11] python_version: ['3.10'] timeout-minutes: 180 steps: From 9f526509d73fef7a0ce95d1c1b520e04f1460f4c Mon Sep 17 00:00:00 2001 From: Bill Little Date: Wed, 13 Jul 2022 15:01:30 +0100 Subject: [PATCH 63/86] docs: add cf-units to working examples docs (#1170) * add cf-units to working examples docs * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * review action - remove notes Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- docs/data/projects.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/data/projects.yml b/docs/data/projects.yml index 7e8c544a..b08d6fc4 100644 --- a/docs/data/projects.yml +++ b/docs/data/projects.yml @@ -589,3 +589,8 @@ gh: MarshalX/python-webrtc ci: [github] os: [windows, apple, linux] + +- name: cf-units + gh: SciTools/cf-units + ci: [github] + os: [apple, linux] From 6afe95e6aeeaa62e1e29fa9b966c0edbb06dc5cf Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 13 Jul 2022 09:01:52 -0500 Subject: [PATCH 64/86] [pre-commit.ci] pre-commit autoupdate (#1172) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/asottile/pyupgrade: v2.34.0 → v2.37.1](https://github.com/asottile/pyupgrade/compare/v2.34.0...v2.37.1) - [github.com/hadialqattan/pycln: v1.3.5 → v2.0.1](https://github.com/hadialqattan/pycln/compare/v1.3.5...v2.0.1) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f3b0564f..28355fee 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,7 +14,7 @@ repos: - id: trailing-whitespace - repo: https://github.com/asottile/pyupgrade - rev: v2.34.0 + rev: v2.37.1 hooks: - id: pyupgrade name: PyUpgrade 3.6+ @@ -27,7 +27,7 @@ repos: # Autoremoves unused imports - repo: https://github.com/hadialqattan/pycln - rev: v1.3.5 + rev: v2.0.1 hooks: - id: pycln args: [--all] From e50075b96f3161ddf53825e9670a9ba618759d24 Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Wed, 13 Jul 2022 16:02:32 +0200 Subject: [PATCH 65/86] fix: expand the catch statement on util.download to be more robust (#1173) URLError and SSLError both subclass OSError. Should prevent random network errors like this from breaking the build https://app.circleci.com/pipelines/github/pypa/cibuildwheel/3668/workflows/6a3b6066-e892-48c4-bb6b-4c094b1c814e/jobs/9933?invite=true#step-103-623 --- cibuildwheel/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cibuildwheel/util.py b/cibuildwheel/util.py index f164b91a..d2287a05 100644 --- a/cibuildwheel/util.py +++ b/cibuildwheel/util.py @@ -316,7 +316,7 @@ def download(url: str, dest: Path) -> None: dest.write_bytes(response.read()) return - except urllib.error.URLError: + except OSError: if i == repeat_num - 1: raise sleep(3) From 57800921c558489919c17341227ed60884c0e75a Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Thu, 14 Jul 2022 11:42:40 +0200 Subject: [PATCH 66/86] Don't attempt to test CPython 3.8 wheels on Apple Silicon. (#1171) I've added a warning for users, so they know that it doesn't get tested. See discussion in #1169 for the reason why. Fixes #1168, fixes #1169 --- cibuildwheel/macos.py | 17 +++++++++++++++++ test/test_macos_archs.py | 33 +++++++++++++++++++++++++++++++++ test/utils.py | 6 +++--- 3 files changed, 53 insertions(+), 3 deletions(-) diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index 8cc2e80d..beb4d32e 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -465,6 +465,23 @@ def build(options: Options, tmp_path: Path) -> None: # skip this test continue + if testing_arch == "arm64" and config.identifier.startswith("cp38-"): + log.warning( + unwrap( + """ + While cibuildwheel can build CPython 3.8 universal2/arm64 wheels, we + cannot test the arm64 part of them, even when running on an Apple + Silicon machine. This is because we use the x86_64 installer of + CPython 3.8. See the discussion in + https://github.com/pypa/cibuildwheel/pull/1169 for the details. To + silence this warning, set `CIBW_TEST_SKIP: cp38-macosx_*:arm64`. + """ + ) + ) + + # skip this test + continue + log.step( "Testing wheel..." if testing_arch == machine_arch diff --git a/test/test_macos_archs.py b/test/test_macos_archs.py index 3f427250..a5db09f8 100644 --- a/test/test_macos_archs.py +++ b/test/test_macos_archs.py @@ -133,3 +133,36 @@ def test_universal2_testing(tmp_path, capfd, skip_arm64_test): expected_wheels = [w for w in ALL_MACOS_WHEELS if "cp39" in w and "universal2" in w] assert set(actual_wheels) == set(expected_wheels) + + +def test_cp38_arm64_testing(tmp_path, capfd): + if utils.platform != "macos": + pytest.skip("this test is only relevant to macos") + if get_xcode_version() < (12, 2): + pytest.skip("this test only works with Xcode 12.2 or greater") + if platform.machine() != "arm64": + pytest.skip("this test only works on arm64") + + project_dir = tmp_path / "project" + basic_project.generate(project_dir) + + actual_wheels = utils.cibuildwheel_run( + project_dir, + add_env={ + "CIBW_BUILD": "cp38-*", + "CIBW_TEST_COMMAND": '''python -c "import platform; print('running tests on ' + platform.machine())"''', + "CIBW_ARCHS": "x86_64,universal2,arm64", + }, + ) + + captured = capfd.readouterr() + + assert "running tests on x86_64" in captured.out + assert "running tests on arm64" not in captured.out + + warning_message = "While cibuildwheel can build CPython 3.8 universal2/arm64 wheels, we cannot test the arm64 part of them" + assert warning_message in captured.err + + expected_wheels = [w for w in ALL_MACOS_WHEELS if "cp38" in w] + + assert set(actual_wheels) == set(expected_wheels) diff --git a/test/utils.py b/test/utils.py index d325be68..22fe4c1a 100644 --- a/test/utils.py +++ b/test/utils.py @@ -154,8 +154,8 @@ def expected_wheels( python_abi_tags += ["pp37-pypy37_pp73", "pp38-pypy38_pp73", "pp39-pypy39_pp73"] if platform == "macos" and machine_arch == "arm64": - # currently, arm64 macs are only supported by cp39, cp310 & cp311 - python_abi_tags = ["cp39-cp39", "cp310-cp310", "cp311-cp311"] + # arm64 macs are only supported by cp38+ + python_abi_tags = ["cp38-cp38", "cp39-cp39", "cp310-cp310", "cp311-cp311"] wheels = [] @@ -193,7 +193,7 @@ def expected_wheels( platform_tags = ["win32", "win_amd64"] elif platform == "macos": - if python_abi_tag == "cp39-cp39" and machine_arch == "arm64": + if machine_arch == "arm64": arm64_macosx_deployment_target = _get_arm64_macosx_deployment_target( macosx_deployment_target ) From 0b1e5818ba69504386cb14e07b62c1c898d83def Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Thu, 14 Jul 2022 22:23:04 -0400 Subject: [PATCH 67/86] doc: typo manylinux_2_24 (#1178) * DOC: Typo manylinux_2_24 * FIX: Need to quote the braces --- docs/options.md | 4 ++-- examples/github-minimal.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/options.md b/docs/options.md index 6b899654..d2c0fb9d 100644 --- a/docs/options.md +++ b/docs/options.md @@ -700,9 +700,9 @@ Platform-specific environment variables also available:
In configuration files, you can use a TOML array, and each line will be run sequentially - joined with `&&`. -Note that manylinux2_24 builds occur inside a Debian9 docker, where +Note that manylinux_2_24 builds occur inside a Debian9 docker, where manylinux2010 and manylinux2014 builds occur inside a CentOS one. So for -`manylinux2_24` the `CIBW_BEFORE_ALL_LINUX` command must use `apt-get -y` +`manylinux_2_24` the `CIBW_BEFORE_ALL_LINUX` command must use `apt-get -y` instead. ### `CIBW_BEFORE_BUILD` {: #before-build} diff --git a/examples/github-minimal.yml b/examples/github-minimal.yml index 8d6ce692..3862aed8 100644 --- a/examples/github-minimal.yml +++ b/examples/github-minimal.yml @@ -21,7 +21,7 @@ jobs: # with: # package-dir: . # output-dir: wheelhouse - # config-file: {package}/pyproject.toml + # config-file: "{package}/pyproject.toml" - uses: actions/upload-artifact@v3 with: From ee85748505405c49486b930fc9145f6bfbddd72c Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 15 Jul 2022 07:57:22 -0500 Subject: [PATCH 68/86] ci: fix update script (#1179) --- bin/update_virtualenv.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/update_virtualenv.py b/bin/update_virtualenv.py index 8dd9c5ef..3704463d 100755 --- a/bin/update_virtualenv.py +++ b/bin/update_virtualenv.py @@ -36,7 +36,7 @@ GET_VIRTUALENV_URL_TEMPLATE: Final[ ] = f"{GET_VIRTUALENV_GITHUB}/blob/{{version}}/public/virtualenv.pyz?raw=true" -@dataclass(frozen=True) +@dataclass(frozen=True, order=True) class VersionTuple: version: Version version_string: str From 0e1878bcdbf78bc8651303c56e871d79946efd01 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Sun, 17 Jul 2022 14:31:45 -0400 Subject: [PATCH 69/86] DOC: Bump to non-deprecated image --- README.md | 2 +- azure-pipelines.yml | 2 +- docs/setup.md | 4 ++-- examples/azure-pipelines-minimal.yml | 2 +- examples/github-apple-silicon.yml | 4 ++-- examples/github-deploy.yml | 2 +- examples/github-minimal.yml | 2 +- examples/github-with-qemu.yml | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 84f1947b..6994ff80 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-20.04, windows-2019, macOS-10.15] + os: [ubuntu-20.04, windows-2019, macOS-11.0] steps: - uses: actions/checkout@v3 diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a5497a46..56131899 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -11,7 +11,7 @@ jobs: python ./bin/run_tests.py - job: macos_38 - pool: {vmImage: 'macOS-10.15'} + pool: {vmImage: 'macOS-11'} steps: - task: UsePythonVersion@0 inputs: diff --git a/docs/setup.md b/docs/setup.md index 73aa8619..9d5e4a8c 100644 --- a/docs/setup.md +++ b/docs/setup.md @@ -176,7 +176,7 @@ To build Linux, Mac, and Windows wheels using GitHub Actions, create a `.github/ runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-20.04, windows-2019, macos-10.15] + os: [ubuntu-20.04, windows-2019, macos-11] steps: - uses: actions/checkout@v3 @@ -208,7 +208,7 @@ To build Linux, Mac, and Windows wheels using GitHub Actions, create a `.github/ runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-20.04, windows-2019, macos-10.15] + os: [ubuntu-20.04, windows-2019, macos-11] steps: - uses: actions/checkout@v3 diff --git a/examples/azure-pipelines-minimal.yml b/examples/azure-pipelines-minimal.yml index de1847e6..119bd8f4 100644 --- a/examples/azure-pipelines-minimal.yml +++ b/examples/azure-pipelines-minimal.yml @@ -14,7 +14,7 @@ jobs: inputs: {pathtoPublish: 'wheelhouse'} - job: macos - pool: {vmImage: 'macOS-10.15'} + pool: {vmImage: 'macOS-11'} steps: - task: UsePythonVersion@0 - bash: | diff --git a/examples/github-apple-silicon.yml b/examples/github-apple-silicon.yml index eafdf216..af0b993f 100644 --- a/examples/github-apple-silicon.yml +++ b/examples/github-apple-silicon.yml @@ -4,8 +4,8 @@ on: [push, pull_request] jobs: build_wheels_macos: - name: Build wheels on macos-10.15 - runs-on: macos-10.15 + name: Build wheels on macos-11 + runs-on: macos-11 steps: - uses: actions/checkout@v3 diff --git a/examples/github-deploy.yml b/examples/github-deploy.yml index bb4a4e31..1ec1385c 100644 --- a/examples/github-deploy.yml +++ b/examples/github-deploy.yml @@ -16,7 +16,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-20.04, windows-2019, macos-10.15] + os: [ubuntu-20.04, windows-2019, macos-11] steps: - uses: actions/checkout@v3 diff --git a/examples/github-minimal.yml b/examples/github-minimal.yml index 3862aed8..963e5258 100644 --- a/examples/github-minimal.yml +++ b/examples/github-minimal.yml @@ -8,7 +8,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-20.04, windows-2019, macos-10.15] + os: [ubuntu-20.04, windows-2019, macos-11] steps: - uses: actions/checkout@v3 diff --git a/examples/github-with-qemu.yml b/examples/github-with-qemu.yml index dcdcdbea..01426723 100644 --- a/examples/github-with-qemu.yml +++ b/examples/github-with-qemu.yml @@ -8,7 +8,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-20.04, windows-2019, macos-10.15] + os: [ubuntu-20.04, windows-2019, macos-11] steps: - uses: actions/checkout@v3 From a7b7d146b9af37d81c008b27cfc3db7a36aff2c9 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Sun, 17 Jul 2022 15:26:34 -0400 Subject: [PATCH 70/86] FIX: Name --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6994ff80..50558d91 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-20.04, windows-2019, macOS-11.0] + os: [ubuntu-20.04, windows-2019, macOS-11] steps: - uses: actions/checkout@v3 From 61821a8473d0fe92f3ded1d4690a7aec4a0efcb9 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Mon, 18 Jul 2022 09:14:51 -0500 Subject: [PATCH 71/86] fix(docs): pin things due to the mkdocs pin (#1181) Signed-off-by: Henry Schreiner --- noxfile.py | 3 ++- setup.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/noxfile.py b/noxfile.py index e5f749f0..f045e616 100644 --- a/noxfile.py +++ b/noxfile.py @@ -92,12 +92,13 @@ def update_proj(session: nox.Session) -> None: ) -@nox.session +@nox.session(python="3.9") def docs(session: nox.Session) -> None: """ Build the docs. """ session.install("-e", ".[docs]") + session.run("pip", "list") if session.posargs: if "serve" in session.posargs: diff --git a/setup.py b/setup.py index cd4956e1..6c08425d 100644 --- a/setup.py +++ b/setup.py @@ -3,10 +3,11 @@ from setuptools import setup extras = { "docs": [ "mkdocs-include-markdown-plugin==2.8.0", - "mkdocs==1.0.4", + "mkdocs==1.0.4", # Doesn't support Python 3.10+ "jinja2==3.0.3", "pymdown-extensions", "mkdocs-macros-plugin", + "markdown<3.4", # Breaks mkdocs 1.0.4 ], "test": [ "jinja2", From 39176acc4b83710c5fe9539d82b262dcd747a6a3 Mon Sep 17 00:00:00 2001 From: "cibuildwheel-bot[bot]" <83877280+cibuildwheel-bot[bot]@users.noreply.github.com> Date: Mon, 18 Jul 2022 16:12:23 +0000 Subject: [PATCH 72/86] Update dependencies --- cibuildwheel/resources/build-platforms.toml | 12 +- .../resources/constraints-python310.txt | 8 +- .../resources/constraints-python311.txt | 8 +- .../resources/constraints-python36.txt | 4 +- .../resources/constraints-python37.txt | 10 +- .../resources/constraints-python38.txt | 8 +- .../resources/constraints-python39.txt | 8 +- cibuildwheel/resources/constraints.txt | 8 +- .../resources/pinned_docker_images.cfg | 64 ++--- cibuildwheel/resources/virtualenv.toml | 4 +- docs/working-examples.md | 237 +++++++++--------- 11 files changed, 187 insertions(+), 184 deletions(-) diff --git a/cibuildwheel/resources/build-platforms.toml b/cibuildwheel/resources/build-platforms.toml index fe8528d3..533c4db6 100644 --- a/cibuildwheel/resources/build-platforms.toml +++ b/cibuildwheel/resources/build-platforms.toml @@ -84,9 +84,9 @@ python_configurations = [ { identifier = "cp310-macosx_x86_64", version = "3.10", url = "https://www.python.org/ftp/python/3.10.5/python-3.10.5-macos11.pkg" }, { identifier = "cp310-macosx_arm64", version = "3.10", url = "https://www.python.org/ftp/python/3.10.5/python-3.10.5-macos11.pkg" }, { identifier = "cp310-macosx_universal2", version = "3.10", url = "https://www.python.org/ftp/python/3.10.5/python-3.10.5-macos11.pkg" }, - { identifier = "cp311-macosx_x86_64", version = "3.11", url = "https://www.python.org/ftp/python/3.11.0/python-3.11.0b3-macos11.pkg" }, - { identifier = "cp311-macosx_arm64", version = "3.11", url = "https://www.python.org/ftp/python/3.11.0/python-3.11.0b3-macos11.pkg" }, - { identifier = "cp311-macosx_universal2", version = "3.11", url = "https://www.python.org/ftp/python/3.11.0/python-3.11.0b3-macos11.pkg" }, + { identifier = "cp311-macosx_x86_64", version = "3.11", url = "https://www.python.org/ftp/python/3.11.0/python-3.11.0b4-macos11.pkg" }, + { identifier = "cp311-macosx_arm64", version = "3.11", url = "https://www.python.org/ftp/python/3.11.0/python-3.11.0b4-macos11.pkg" }, + { identifier = "cp311-macosx_universal2", version = "3.11", url = "https://www.python.org/ftp/python/3.11.0/python-3.11.0b4-macos11.pkg" }, { identifier = "pp37-macosx_x86_64", version = "3.7", url = "https://downloads.python.org/pypy/pypy3.7-v7.3.9-osx64.tar.bz2" }, { identifier = "pp38-macosx_x86_64", version = "3.8", url = "https://downloads.python.org/pypy/pypy3.8-v7.3.9-osx64.tar.bz2" }, { identifier = "pp39-macosx_x86_64", version = "3.9", url = "https://downloads.python.org/pypy/pypy3.9-v7.3.9-osx64.tar.bz2" }, @@ -104,11 +104,11 @@ python_configurations = [ { identifier = "cp39-win_amd64", version = "3.9.13", arch = "64" }, { identifier = "cp310-win32", version = "3.10.5", arch = "32" }, { identifier = "cp310-win_amd64", version = "3.10.5", arch = "64" }, - { identifier = "cp311-win32", version = "3.11.0-b3", arch = "32" }, - { identifier = "cp311-win_amd64", version = "3.11.0-b3", arch = "64" }, + { identifier = "cp311-win32", version = "3.11.0-b4", arch = "32" }, + { identifier = "cp311-win_amd64", version = "3.11.0-b4", arch = "64" }, { identifier = "cp39-win_arm64", version = "3.9.10", arch = "ARM64" }, { identifier = "cp310-win_arm64", version = "3.10.5", arch = "ARM64" }, - { identifier = "cp311-win_arm64", version = "3.11.0-b3", arch = "ARM64" }, + { identifier = "cp311-win_arm64", version = "3.11.0-b4", arch = "ARM64" }, { identifier = "pp37-win_amd64", version = "3.7", arch = "64", url = "https://downloads.python.org/pypy/pypy3.7-v7.3.9-win64.zip" }, { identifier = "pp38-win_amd64", version = "3.8", arch = "64", url = "https://downloads.python.org/pypy/pypy3.8-v7.3.9-win64.zip" }, { identifier = "pp39-win_amd64", version = "3.9", arch = "64", url = "https://downloads.python.org/pypy/pypy3.9-v7.3.9-win64.zip" }, diff --git a/cibuildwheel/resources/constraints-python310.txt b/cibuildwheel/resources/constraints-python310.txt index 6f02809e..1b4a6b31 100644 --- a/cibuildwheel/resources/constraints-python310.txt +++ b/cibuildwheel/resources/constraints-python310.txt @@ -6,7 +6,7 @@ # delocate==0.10.2 # via -r cibuildwheel/resources/constraints.in -distlib==0.3.4 +distlib==0.3.5 # via virtualenv filelock==3.7.1 # via virtualenv @@ -14,9 +14,9 @@ platformdirs==2.5.2 # via virtualenv six==1.16.0 # via virtualenv -typing-extensions==4.2.0 +typing-extensions==4.3.0 # via delocate -virtualenv==20.15.0 +virtualenv==20.15.1 # via -r cibuildwheel/resources/constraints.in wheel==0.37.1 # via @@ -26,5 +26,5 @@ wheel==0.37.1 # The following packages are considered to be unsafe in a requirements file: pip==22.1.2 # via -r cibuildwheel/resources/constraints.in -setuptools==62.6.0 +setuptools==63.2.0 # via -r cibuildwheel/resources/constraints.in diff --git a/cibuildwheel/resources/constraints-python311.txt b/cibuildwheel/resources/constraints-python311.txt index 5d69e081..93901adb 100644 --- a/cibuildwheel/resources/constraints-python311.txt +++ b/cibuildwheel/resources/constraints-python311.txt @@ -6,7 +6,7 @@ # delocate==0.10.2 # via -r cibuildwheel/resources/constraints.in -distlib==0.3.4 +distlib==0.3.5 # via virtualenv filelock==3.7.1 # via virtualenv @@ -14,9 +14,9 @@ platformdirs==2.5.2 # via virtualenv six==1.16.0 # via virtualenv -typing-extensions==4.2.0 +typing-extensions==4.3.0 # via delocate -virtualenv==20.15.0 +virtualenv==20.15.1 # via -r cibuildwheel/resources/constraints.in wheel==0.37.1 # via @@ -26,5 +26,5 @@ wheel==0.37.1 # The following packages are considered to be unsafe in a requirements file: pip==22.1.2 # via -r cibuildwheel/resources/constraints.in -setuptools==62.6.0 +setuptools==63.2.0 # via -r cibuildwheel/resources/constraints.in diff --git a/cibuildwheel/resources/constraints-python36.txt b/cibuildwheel/resources/constraints-python36.txt index e5bc034c..8ab9294a 100644 --- a/cibuildwheel/resources/constraints-python36.txt +++ b/cibuildwheel/resources/constraints-python36.txt @@ -6,7 +6,7 @@ # delocate==0.10.2 # via -r cibuildwheel/resources/constraints.in -distlib==0.3.4 +distlib==0.3.5 # via virtualenv filelock==3.4.1 # via virtualenv @@ -22,7 +22,7 @@ typing-extensions==4.1.1 # via # delocate # importlib-metadata -virtualenv==20.15.0 +virtualenv==20.15.1 # via -r cibuildwheel/resources/constraints.in wheel==0.37.1 # via diff --git a/cibuildwheel/resources/constraints-python37.txt b/cibuildwheel/resources/constraints-python37.txt index 93118618..f5a8ac31 100644 --- a/cibuildwheel/resources/constraints-python37.txt +++ b/cibuildwheel/resources/constraints-python37.txt @@ -6,7 +6,7 @@ # delocate==0.10.2 # via -r cibuildwheel/resources/constraints.in -distlib==0.3.4 +distlib==0.3.5 # via virtualenv filelock==3.7.1 # via virtualenv @@ -16,21 +16,21 @@ platformdirs==2.5.2 # via virtualenv six==1.16.0 # via virtualenv -typing-extensions==4.2.0 +typing-extensions==4.3.0 # via # delocate # importlib-metadata -virtualenv==20.15.0 +virtualenv==20.15.1 # via -r cibuildwheel/resources/constraints.in wheel==0.37.1 # via # -r cibuildwheel/resources/constraints.in # delocate -zipp==3.8.0 +zipp==3.8.1 # via importlib-metadata # The following packages are considered to be unsafe in a requirements file: pip==22.1.2 # via -r cibuildwheel/resources/constraints.in -setuptools==62.6.0 +setuptools==63.2.0 # via -r cibuildwheel/resources/constraints.in diff --git a/cibuildwheel/resources/constraints-python38.txt b/cibuildwheel/resources/constraints-python38.txt index 3de94015..c13a47fa 100644 --- a/cibuildwheel/resources/constraints-python38.txt +++ b/cibuildwheel/resources/constraints-python38.txt @@ -6,7 +6,7 @@ # delocate==0.10.2 # via -r cibuildwheel/resources/constraints.in -distlib==0.3.4 +distlib==0.3.5 # via virtualenv filelock==3.7.1 # via virtualenv @@ -14,9 +14,9 @@ platformdirs==2.5.2 # via virtualenv six==1.16.0 # via virtualenv -typing-extensions==4.2.0 +typing-extensions==4.3.0 # via delocate -virtualenv==20.15.0 +virtualenv==20.15.1 # via -r cibuildwheel/resources/constraints.in wheel==0.37.1 # via @@ -26,5 +26,5 @@ wheel==0.37.1 # The following packages are considered to be unsafe in a requirements file: pip==22.1.2 # via -r cibuildwheel/resources/constraints.in -setuptools==62.6.0 +setuptools==63.2.0 # via -r cibuildwheel/resources/constraints.in diff --git a/cibuildwheel/resources/constraints-python39.txt b/cibuildwheel/resources/constraints-python39.txt index 8c407bb0..f5f35ff1 100644 --- a/cibuildwheel/resources/constraints-python39.txt +++ b/cibuildwheel/resources/constraints-python39.txt @@ -6,7 +6,7 @@ # delocate==0.10.2 # via -r cibuildwheel/resources/constraints.in -distlib==0.3.4 +distlib==0.3.5 # via virtualenv filelock==3.7.1 # via virtualenv @@ -14,9 +14,9 @@ platformdirs==2.5.2 # via virtualenv six==1.16.0 # via virtualenv -typing-extensions==4.2.0 +typing-extensions==4.3.0 # via delocate -virtualenv==20.15.0 +virtualenv==20.15.1 # via -r cibuildwheel/resources/constraints.in wheel==0.37.1 # via @@ -26,5 +26,5 @@ wheel==0.37.1 # The following packages are considered to be unsafe in a requirements file: pip==22.1.2 # via -r cibuildwheel/resources/constraints.in -setuptools==62.6.0 +setuptools==63.2.0 # via -r cibuildwheel/resources/constraints.in diff --git a/cibuildwheel/resources/constraints.txt b/cibuildwheel/resources/constraints.txt index 8c407bb0..f5f35ff1 100644 --- a/cibuildwheel/resources/constraints.txt +++ b/cibuildwheel/resources/constraints.txt @@ -6,7 +6,7 @@ # delocate==0.10.2 # via -r cibuildwheel/resources/constraints.in -distlib==0.3.4 +distlib==0.3.5 # via virtualenv filelock==3.7.1 # via virtualenv @@ -14,9 +14,9 @@ platformdirs==2.5.2 # via virtualenv six==1.16.0 # via virtualenv -typing-extensions==4.2.0 +typing-extensions==4.3.0 # via delocate -virtualenv==20.15.0 +virtualenv==20.15.1 # via -r cibuildwheel/resources/constraints.in wheel==0.37.1 # via @@ -26,5 +26,5 @@ wheel==0.37.1 # The following packages are considered to be unsafe in a requirements file: pip==22.1.2 # via -r cibuildwheel/resources/constraints.in -setuptools==62.6.0 +setuptools==63.2.0 # via -r cibuildwheel/resources/constraints.in diff --git a/cibuildwheel/resources/pinned_docker_images.cfg b/cibuildwheel/resources/pinned_docker_images.cfg index 9d8e6297..4c829bd6 100644 --- a/cibuildwheel/resources/pinned_docker_images.cfg +++ b/cibuildwheel/resources/pinned_docker_images.cfg @@ -1,48 +1,48 @@ [x86_64] -manylinux1 = quay.io/pypa/manylinux1_x86_64:2022-06-26-ddecca8 -manylinux2010 = quay.io/pypa/manylinux2010_x86_64:2022-06-26-9a2ca4b -manylinux2014 = quay.io/pypa/manylinux2014_x86_64:2022-06-26-9a2ca4b -manylinux_2_24 = quay.io/pypa/manylinux_2_24_x86_64:2022-06-26-9a2ca4b -manylinux_2_28 = quay.io/pypa/manylinux_2_28_x86_64:2022-06-26-9a2ca4b -musllinux_1_1 = quay.io/pypa/musllinux_1_1_x86_64:2022-06-26-9a2ca4b +manylinux1 = quay.io/pypa/manylinux1_x86_64:2022-07-17-f8ddacc +manylinux2010 = quay.io/pypa/manylinux2010_x86_64:2022-07-17-51324db +manylinux2014 = quay.io/pypa/manylinux2014_x86_64:2022-07-17-51324db +manylinux_2_24 = quay.io/pypa/manylinux_2_24_x86_64:2022-07-17-51324db +manylinux_2_28 = quay.io/pypa/manylinux_2_28_x86_64:2022-07-17-51324db +musllinux_1_1 = quay.io/pypa/musllinux_1_1_x86_64:2022-07-17-51324db [i686] -manylinux1 = quay.io/pypa/manylinux1_i686:2022-06-26-ddecca8 -manylinux2010 = quay.io/pypa/manylinux2010_i686:2022-06-26-9a2ca4b -manylinux2014 = quay.io/pypa/manylinux2014_i686:2022-06-26-9a2ca4b -manylinux_2_24 = quay.io/pypa/manylinux_2_24_i686:2022-06-26-9a2ca4b -musllinux_1_1 = quay.io/pypa/musllinux_1_1_i686:2022-06-26-9a2ca4b +manylinux1 = quay.io/pypa/manylinux1_i686:2022-07-17-f8ddacc +manylinux2010 = quay.io/pypa/manylinux2010_i686:2022-07-17-51324db +manylinux2014 = quay.io/pypa/manylinux2014_i686:2022-07-17-51324db +manylinux_2_24 = quay.io/pypa/manylinux_2_24_i686:2022-07-17-51324db +musllinux_1_1 = quay.io/pypa/musllinux_1_1_i686:2022-07-17-51324db [pypy_x86_64] -manylinux2010 = quay.io/pypa/manylinux2010_x86_64:2022-06-26-9a2ca4b -manylinux2014 = quay.io/pypa/manylinux2014_x86_64:2022-06-26-9a2ca4b -manylinux_2_24 = quay.io/pypa/manylinux_2_24_x86_64:2022-06-26-9a2ca4b -manylinux_2_28 = quay.io/pypa/manylinux_2_28_x86_64:2022-06-26-9a2ca4b +manylinux2010 = quay.io/pypa/manylinux2010_x86_64:2022-07-17-51324db +manylinux2014 = quay.io/pypa/manylinux2014_x86_64:2022-07-17-51324db +manylinux_2_24 = quay.io/pypa/manylinux_2_24_x86_64:2022-07-17-51324db +manylinux_2_28 = quay.io/pypa/manylinux_2_28_x86_64:2022-07-17-51324db [pypy_i686] -manylinux2010 = quay.io/pypa/manylinux2010_i686:2022-06-26-9a2ca4b -manylinux2014 = quay.io/pypa/manylinux2014_i686:2022-06-26-9a2ca4b -manylinux_2_24 = quay.io/pypa/manylinux_2_24_i686:2022-06-26-9a2ca4b +manylinux2010 = quay.io/pypa/manylinux2010_i686:2022-07-17-51324db +manylinux2014 = quay.io/pypa/manylinux2014_i686:2022-07-17-51324db +manylinux_2_24 = quay.io/pypa/manylinux_2_24_i686:2022-07-17-51324db [aarch64] -manylinux2014 = quay.io/pypa/manylinux2014_aarch64:2022-06-26-9a2ca4b -manylinux_2_24 = quay.io/pypa/manylinux_2_24_aarch64:2022-06-26-9a2ca4b -manylinux_2_28 = quay.io/pypa/manylinux_2_28_aarch64:2022-06-26-9a2ca4b -musllinux_1_1 = quay.io/pypa/musllinux_1_1_aarch64:2022-06-26-9a2ca4b +manylinux2014 = quay.io/pypa/manylinux2014_aarch64:2022-07-17-51324db +manylinux_2_24 = quay.io/pypa/manylinux_2_24_aarch64:2022-07-17-51324db +manylinux_2_28 = quay.io/pypa/manylinux_2_28_aarch64:2022-07-17-51324db +musllinux_1_1 = quay.io/pypa/musllinux_1_1_aarch64:2022-07-17-51324db [ppc64le] -manylinux2014 = quay.io/pypa/manylinux2014_ppc64le:2022-06-26-9a2ca4b -manylinux_2_24 = quay.io/pypa/manylinux_2_24_ppc64le:2022-06-26-9a2ca4b -manylinux_2_28 = quay.io/pypa/manylinux_2_28_ppc64le:2022-06-26-9a2ca4b -musllinux_1_1 = quay.io/pypa/musllinux_1_1_ppc64le:2022-06-26-9a2ca4b +manylinux2014 = quay.io/pypa/manylinux2014_ppc64le:2022-07-17-51324db +manylinux_2_24 = quay.io/pypa/manylinux_2_24_ppc64le:2022-07-17-51324db +manylinux_2_28 = quay.io/pypa/manylinux_2_28_ppc64le:2022-07-17-51324db +musllinux_1_1 = quay.io/pypa/musllinux_1_1_ppc64le:2022-07-17-51324db [s390x] -manylinux2014 = quay.io/pypa/manylinux2014_s390x:2022-06-26-9a2ca4b -manylinux_2_24 = quay.io/pypa/manylinux_2_24_s390x:2022-06-26-9a2ca4b -musllinux_1_1 = quay.io/pypa/musllinux_1_1_s390x:2022-06-26-9a2ca4b +manylinux2014 = quay.io/pypa/manylinux2014_s390x:2022-07-17-51324db +manylinux_2_24 = quay.io/pypa/manylinux_2_24_s390x:2022-07-17-51324db +musllinux_1_1 = quay.io/pypa/musllinux_1_1_s390x:2022-07-17-51324db [pypy_aarch64] -manylinux2014 = quay.io/pypa/manylinux2014_aarch64:2022-06-26-9a2ca4b -manylinux_2_24 = quay.io/pypa/manylinux_2_24_aarch64:2022-06-26-9a2ca4b -manylinux_2_28 = quay.io/pypa/manylinux_2_28_aarch64:2022-06-26-9a2ca4b +manylinux2014 = quay.io/pypa/manylinux2014_aarch64:2022-07-17-51324db +manylinux_2_24 = quay.io/pypa/manylinux_2_24_aarch64:2022-07-17-51324db +manylinux_2_28 = quay.io/pypa/manylinux_2_28_aarch64:2022-07-17-51324db diff --git a/cibuildwheel/resources/virtualenv.toml b/cibuildwheel/resources/virtualenv.toml index 01489be2..c9ae14af 100644 --- a/cibuildwheel/resources/virtualenv.toml +++ b/cibuildwheel/resources/virtualenv.toml @@ -1,2 +1,2 @@ -version = "20.15.0" -url = "https://github.com/pypa/get-virtualenv/blob/20.15.0/public/virtualenv.pyz?raw=true" +version = "20.15.1" +url = "https://github.com/pypa/get-virtualenv/blob/20.15.1/public/virtualenv.pyz?raw=true" diff --git a/docs/working-examples.md b/docs/working-examples.md index a478ee7f..328d1dbb 100644 --- a/docs/working-examples.md +++ b/docs/working-examples.md @@ -33,15 +33,15 @@ title: Working examples | [websockets][] | ![travisci icon][] | ![apple icon][] ![linux icon][] | Library for building WebSocket servers and clients. Mostly written in Python, with a small C 'speedups' extension module. | | [cvxpy][] | ![github icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | A Python-embedded modeling language for convex optimization problems. | | [PyOxidizer][] | ![github icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | A modern Python application packaging and distribution tool | -| [UltraJSON][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Ultra fast JSON decoder and encoder written in C with Python bindings | | [Triton][] | ![github icon][] | ![linux icon][] | Self hosted runners | +| [UltraJSON][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Ultra fast JSON decoder and encoder written in C with Python bindings | | [River][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | 🌊 Online machine learning in Python | | [OpenSpiel][] | ![github icon][] | ![apple icon][] ![linux icon][] | OpenSpiel is a collection of environments and algorithms for research in general reinforcement learning and search/planning in games. | | [pyzmq][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Python bindings for zeromq, the networking library. Uses Cython and CFFI. | | [aiortc][] | ![github icon][] | ![apple icon][] ![linux icon][] | WebRTC and ORTC implementation for Python using asyncio. | | [vispy][] | ![github icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | Main repository for Vispy | -| [Implicit][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Includes GPU support for linux wheels | | [Confluent client for Kafka][] | ![travisci icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | setup in `tools/wheels/build-wheels.bat` | +| [Implicit][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Includes GPU support for linux wheels | | [tinyobjloader][] | ![azurepipelines icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | Tiny but powerful single file wavefront obj loader | | [Dependency Injector][] | ![travisci icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Dependency injection framework for Python, uses Windows TravisCI | | [coverage.py][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | The coverage tool for Python | @@ -72,11 +72,11 @@ title: Working examples | [pybind11 cmake_example][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Example pybind11 module built with a CMake-based build system | | [KDEpy][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Kernel Density Estimation in Python | | [tgcalls][] | ![github icon][] | ![apple icon][] ![windows icon][] | Python `pybind11` binding to Telegram's WebRTC library with third party dependencies like `OpenSSL`, `MozJPEG`, `FFmpeg`, etc. | -| [pybind11 python_example][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Example pybind11 module built with a Python-based build system | | [dd-trace-py][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Uses custom alternate arch emulation on GitHub | +| [pybind11 python_example][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Example pybind11 module built with a Python-based build system | | [sourmash][] | ![github icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | Quickly search, compare, and analyze genomic and metagenomic data sets. | -| [CTranslate2][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Includes libraries from the [Intel oneAPI toolkit](https://www.intel.com/content/www/us/en/developer/tools/oneapi/base-toolkit.html) and CUDA kernels compiled for multiple GPU architectures. | | [time-machine][] | ![github icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | Time mocking library using only the CPython C API. | +| [CTranslate2][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Includes libraries from the [Intel oneAPI toolkit](https://www.intel.com/content/www/us/en/developer/tools/oneapi/base-toolkit.html) and CUDA kernels compiled for multiple GPU architectures. | | [cyvcf2][] | ![github icon][] | ![apple icon][] ![linux icon][] | cython + htslib == fast VCF and BCF processing | | [matrixprofile][] | ![travisci icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | A Python 3 library making time series data mining tasks, utilizing matrix profile algorithms, accessible to everyone. | | [abess][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | A fast best-subset selection library. It uses cibuildwheel to build a large project with C++ extensions. | @@ -86,20 +86,21 @@ title: Working examples | [PyGLM][] | ![github icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | Fast OpenGL Mathematics (GLM) for Python | | [boost-histogram][] | ![github icon][] ![travisci icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Supports full range of wheels, including PyPy and alternate archs. | | [bx-python][] | ![travisci icon][] | ![apple icon][] ![linux icon][] | A library that includes Cython extensions. | -| [iDynTree][] | ![github icon][] | ![linux icon][] | Uses manylinux_2_24 | | [TgCrypto][] | ![travisci icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Includes a Windows Travis build. | +| [iDynTree][] | ![github icon][] | ![linux icon][] | Uses manylinux_2_24 | | [Python-WebRTC][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | a Python extension that provides bindings to WebRTC M92 | | [pybase64][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Fast Base64 encoding/decoding in Python | | [Arbor][] | ![github icon][] | ![apple icon][] ![linux icon][] | Arbor is a multi-compartment neuron simulation library; compatible with next-generation accelerators; best-practices applied to research software; focused on community-driven development. Includes a [small script](https://github.com/arbor-sim/arbor/blob/master/scripts/patchwheel.py) patching `rpath` in bundled libraries. | | [fathon][] | ![travisci icon][] | ![apple icon][] ![linux icon][] | python package for DFA (Detrended Fluctuation Analysis) and related algorithms | | [etebase-py][] | ![travisci icon][] | ![linux icon][] | Python bindings to a Rust library using `setuptools-rust`, and `sccache` for improved speed. | -| [Imagecodecs (fork)][] | ![azurepipelines icon][] | ![apple icon][] ![linux icon][] | Over 20 external dependencies in compiled libraries, custom docker image, `libomp`, `openblas` and `install_name_tool` for macOS. | | [polaroid][] | ![github icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | Full range of wheels for setuptools rust, with auto release and PyPI deploy. | +| [cf-units][] | ![github icon][] | ![apple icon][] ![linux icon][] | Units of measure as required by the Climate and Forecast (CF) Metadata Conventions | +| [Imagecodecs (fork)][] | ![azurepipelines icon][] | ![apple icon][] ![linux icon][] | Over 20 external dependencies in compiled libraries, custom docker image, `libomp`, `openblas` and `install_name_tool` for macOS. | | [clang-format][] | ![github icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | Scikit-build wrapper around LLVM's CMake, all platforms, generic wheels. | -| [numpythia][] | ![github icon][] | ![apple icon][] ![linux icon][] | The interface between PYTHIA and NumPy | -| [power-grid-model][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Python/C++ library for distribution power system analysis | -| [pyjet][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | The interface between FastJet and NumPy | | [pillow-heif][] | ![github icon][] | ![apple icon][] ![linux icon][] | Python CFFI binding to libheif library with third party dependencies like `libde265`, `x265`, `libaom` with test & publishing on PyPi. | +| [power-grid-model][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Python/C++ library for distribution power system analysis | +| [numpythia][] | ![github icon][] | ![apple icon][] ![linux icon][] | The interface between PYTHIA and NumPy | +| [pyjet][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | The interface between FastJet and NumPy | | [pybind11 scikit_build_example][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | An example combining scikit-build and pybind11 | | [ninja][] | ![github icon][] ![travisci icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | Multitagged binary builds for all supported platforms, using cibw 2 config configuration. | | [GSD][] | ![github icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | Cython and NumPy project with 64-bit wheels. | @@ -133,15 +134,15 @@ title: Working examples [websockets]: https://github.com/aaugustin/websockets [cvxpy]: https://github.com/cvxpy/cvxpy [PyOxidizer]: https://github.com/indygreg/PyOxidizer -[UltraJSON]: https://github.com/ultrajson/ultrajson [Triton]: https://github.com/openai/triton +[UltraJSON]: https://github.com/ultrajson/ultrajson [River]: https://github.com/online-ml/river [OpenSpiel]: https://github.com/deepmind/open_spiel [pyzmq]: https://github.com/zeromq/pyzmq [aiortc]: https://github.com/aiortc/aiortc [vispy]: https://github.com/vispy/vispy -[Implicit]: https://github.com/benfred/implicit [Confluent client for Kafka]: https://github.com/confluentinc/confluent-kafka-python +[Implicit]: https://github.com/benfred/implicit [tinyobjloader]: https://github.com/tinyobjloader/tinyobjloader [Dependency Injector]: https://github.com/ets-labs/python-dependency-injector [coverage.py]: https://github.com/nedbat/coveragepy @@ -172,11 +173,11 @@ title: Working examples [pybind11 cmake_example]: https://github.com/pybind/cmake_example [KDEpy]: https://github.com/tommyod/KDEpy [tgcalls]: https://github.com/MarshalX/tgcalls -[pybind11 python_example]: https://github.com/pybind/python_example [dd-trace-py]: https://github.com/DataDog/dd-trace-py +[pybind11 python_example]: https://github.com/pybind/python_example [sourmash]: https://github.com/dib-lab/sourmash -[CTranslate2]: https://github.com/OpenNMT/CTranslate2 [time-machine]: https://github.com/adamchainz/time-machine +[CTranslate2]: https://github.com/OpenNMT/CTranslate2 [cyvcf2]: https://github.com/brentp/cyvcf2 [matrixprofile]: https://github.com/matrix-profile-foundation/matrixprofile [abess]: https://github.com/abess-team/abess @@ -186,20 +187,21 @@ title: Working examples [PyGLM]: https://github.com/Zuzu-Typ/PyGLM [boost-histogram]: https://github.com/scikit-hep/boost-histogram [bx-python]: https://github.com/bxlab/bx-python -[iDynTree]: https://github.com/robotology/idyntree [TgCrypto]: https://github.com/pyrogram/tgcrypto +[iDynTree]: https://github.com/robotology/idyntree [Python-WebRTC]: https://github.com/MarshalX/python-webrtc [pybase64]: https://github.com/mayeut/pybase64 [Arbor]: https://github.com/arbor-sim/arbor [fathon]: https://github.com/stfbnc/fathon [etebase-py]: https://github.com/etesync/etebase-py -[Imagecodecs (fork)]: https://github.com/czaki/imagecodecs_build [polaroid]: https://github.com/daggy1234/polaroid +[cf-units]: https://github.com/SciTools/cf-units +[Imagecodecs (fork)]: https://github.com/czaki/imagecodecs_build [clang-format]: https://github.com/ssciwr/clang-format-wheel -[numpythia]: https://github.com/scikit-hep/numpythia -[power-grid-model]: https://github.com/alliander-opensource/power-grid-model -[pyjet]: https://github.com/scikit-hep/pyjet [pillow-heif]: https://github.com/bigcat88/pillow_heif +[power-grid-model]: https://github.com/alliander-opensource/power-grid-model +[numpythia]: https://github.com/scikit-hep/numpythia +[pyjet]: https://github.com/scikit-hep/pyjet [pybind11 scikit_build_example]: https://github.com/pybind/scikit_build_example [ninja]: https://github.com/scikit-build/ninja-python-distributions [GSD]: https://github.com/glotzerlab/gsd @@ -218,105 +220,106 @@ title: Working examples [apple icon]: data/readme_icons/apple.svg [linux icon]: data/readme_icons/linux.svg - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 8bf28fb1ac731f1b9c1ed4ee29220a7e525e4adb Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 18 Jul 2022 18:44:03 +0000 Subject: [PATCH 73/86] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/hadialqattan/pycln: v2.0.1 → v2.0.3](https://github.com/hadialqattan/pycln/compare/v2.0.1...v2.0.3) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 28355fee..fdd22536 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -27,7 +27,7 @@ repos: # Autoremoves unused imports - repo: https://github.com/hadialqattan/pycln - rev: v2.0.1 + rev: v2.0.3 hooks: - id: pycln args: [--all] From afb4329fe32181c15d34ef94bf64dad7715b44ba Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Mon, 18 Jul 2022 21:41:54 +0100 Subject: [PATCH 74/86] Bump version: v2.8.1 --- README.md | 21 ++++++++++----------- cibuildwheel/__init__.py | 2 +- docs/changelog.md | 9 +++++++++ docs/faq.md | 4 ++-- docs/setup.md | 4 ++-- examples/appveyor-minimal.yml | 2 +- examples/azure-pipelines-minimal.yml | 6 +++--- examples/circleci-minimal.yml | 4 ++-- examples/github-apple-silicon.yml | 2 +- examples/github-deploy.yml | 2 +- examples/github-minimal.yml | 2 +- examples/github-with-qemu.yml | 2 +- examples/gitlab-minimal.yml | 2 +- examples/travis-ci-deploy.yml | 2 +- examples/travis-ci-minimal.yml | 2 +- examples/travis-ci-test-and-deploy.yml | 4 ++-- setup.cfg | 2 +- 17 files changed, 40 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 50558d91..fecef336 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,7 @@ jobs: - uses: actions/setup-python@v3 - name: Install cibuildwheel - run: python -m pip install cibuildwheel==2.8.0 + run: python -m pip install cibuildwheel==2.8.1 - name: Build wheels run: python -m cibuildwheel --output-dir wheelhouse @@ -204,6 +204,15 @@ Changelog +### v2.8.1 + +_18 July 2022_ + +- 🐛 Fix a bug when building CPython 3.8 wheels on an Apple Silicon machine where testing would always fail. cibuildwheel will no longer attempt to test the arm64 part of CPython 3.8 wheels because we use the x86_64 installer of CPython 3.8 due to its macOS system version backward-compatibility. See [#1169](https://github.com/pypa/cibuildwheel/pull/1169) for more details. (#1171) +- 🛠 Update the prerelease CPython 3.11 to 3.11.0b4. (#1180) +- 🛠 The GitHub Action will ensure a compatible version of Python is installed on the runner (#1114) +- 📚 A few docs improvements + ### v2.8.0 _5 July 2022_ @@ -239,16 +248,6 @@ _25 May 2022_ - 🌟 Added the ability to test building wheels on CPython 3.11! Because CPython 3.11 is in beta, these wheels should not be distributed, because they might not be compatible with the final release, but it's available to build for testing purposes. Use the flag [`--prerelease-pythons` or `CIBW_PRERELEASE_PYTHONS`](https://cibuildwheel.readthedocs.io/en/stable/options/#prerelease-pythons) to test. This version of cibuildwheel includes CPython 3.11.0b1. (#1109) - 📚 Added an interactive diagram showing how cibuildwheel works to the [docs](https://cibuildwheel.readthedocs.io/en/stable/#how-it-works) (#1100) -### v2.5.0 - -_29 April 2022_ - -- ✨ Added support for building ABI3 wheels. cibuildwheel will now recognise when an ABI3 wheel was produced, and skip subsequent build steps where the previously built wheel is compatible. Tests still will run on all selected versions of Python, using the ABI3 wheel. Check [this entry](https://cibuildwheel.readthedocs.io/en/stable/faq/#abi3) in the docs for more info. (#1091) -- ✨ You can now build wheels directly from sdist archives, in addition to source directories. Just call cibuildwheel with an sdist argument on the command line, like `cibuildwheel mypackage-1.0.0.tar.gz`. For more details, check the [`--help` output](https://cibuildwheel.readthedocs.io/en/stable/options/#command-line) (#1096) -- 🐛 Fix a bug where cibuildwheel would crash when no builds are selected and `--allow-empty` is passed (#1086) -- 🐛 Workaround a permissions issue on Linux relating to newer versions of git and setuptools_scm (#1095) -- 📚 Minor docs improvements - --- diff --git a/cibuildwheel/__init__.py b/cibuildwheel/__init__.py index 892994aa..b4066b65 100644 --- a/cibuildwheel/__init__.py +++ b/cibuildwheel/__init__.py @@ -1 +1 @@ -__version__ = "2.8.0" +__version__ = "2.8.1" diff --git a/docs/changelog.md b/docs/changelog.md index f5f655fe..6f1da5e4 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -2,6 +2,15 @@ title: Changelog --- +### v2.8.1 + +_18 July 2022_ + +- 🐛 Fix a bug when building CPython 3.8 wheels on an Apple Silicon machine where testing would always fail. cibuildwheel will no longer attempt to test the arm64 part of CPython 3.8 wheels because we use the x86_64 installer of CPython 3.8 due to its macOS system version backward-compatibility. See [#1169](https://github.com/pypa/cibuildwheel/pull/1169) for more details. (#1171) +- 🛠 Update the prerelease CPython 3.11 to 3.11.0b4. (#1180) +- 🛠 The GitHub Action will ensure a compatible version of Python is installed on the runner (#1114) +- 📚 A few docs improvements + ### v2.8.0 _5 July 2022_ diff --git a/docs/faq.md b/docs/faq.md index 18756756..07c5397e 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -133,7 +133,7 @@ There are two suggested methods for keeping cibuildwheel up to date that instead If you use GitHub Actions for builds, you can use cibuildwheel as an action: ```yaml -uses: pypa/cibuildwheel@v2.8.0 +uses: pypa/cibuildwheel@v2.8.1 ``` This is a composite step that just runs cibuildwheel using pipx. You can set command-line options as `with:` parameters, and use `env:` as normal. @@ -155,7 +155,7 @@ The second option, and the only one that supports other CI systems, is using a ` ```bash # requirements-cibw.txt -cibuildwheel==2.8.0 +cibuildwheel==2.8.1 ``` Then your install step would have `python -m pip install -r requirements-cibw.txt` in it. Your `.github/dependabot.yml` file could look like this: diff --git a/docs/setup.md b/docs/setup.md index 9d5e4a8c..91d44960 100644 --- a/docs/setup.md +++ b/docs/setup.md @@ -182,7 +182,7 @@ To build Linux, Mac, and Windows wheels using GitHub Actions, create a `.github/ - uses: actions/checkout@v3 - name: Build wheels - run: pipx run cibuildwheel==2.8.0 + run: pipx run cibuildwheel==2.8.1 - uses: actions/upload-artifact@v3 with: @@ -217,7 +217,7 @@ To build Linux, Mac, and Windows wheels using GitHub Actions, create a `.github/ - uses: actions/setup-python@v3 - name: Install cibuildwheel - run: python -m pip install cibuildwheel==2.8.0 + run: python -m pip install cibuildwheel==2.8.1 - name: Build wheels run: python -m cibuildwheel --output-dir wheelhouse diff --git a/examples/appveyor-minimal.yml b/examples/appveyor-minimal.yml index 2d12d54e..cd47745d 100644 --- a/examples/appveyor-minimal.yml +++ b/examples/appveyor-minimal.yml @@ -12,7 +12,7 @@ stack: python 3.7 init: - cmd: set PATH=C:\Python37;C:\Python37\Scripts;%PATH% -install: python -m pip install cibuildwheel==2.8.0 +install: python -m pip install cibuildwheel==2.8.1 build_script: python -m cibuildwheel --output-dir wheelhouse diff --git a/examples/azure-pipelines-minimal.yml b/examples/azure-pipelines-minimal.yml index 119bd8f4..d9f837f9 100644 --- a/examples/azure-pipelines-minimal.yml +++ b/examples/azure-pipelines-minimal.yml @@ -6,7 +6,7 @@ jobs: - bash: | set -o errexit python3 -m pip install --upgrade pip - pip3 install cibuildwheel==2.8.0 + pip3 install cibuildwheel==2.8.1 displayName: Install dependencies - bash: cibuildwheel --output-dir wheelhouse . displayName: Build wheels @@ -20,7 +20,7 @@ jobs: - bash: | set -o errexit python3 -m pip install --upgrade pip - python3 -m pip install cibuildwheel==2.8.0 + python3 -m pip install cibuildwheel==2.8.1 displayName: Install dependencies - bash: cibuildwheel --output-dir wheelhouse . displayName: Build wheels @@ -34,7 +34,7 @@ jobs: - bash: | set -o errexit python -m pip install --upgrade pip - pip install cibuildwheel==2.8.0 + pip install cibuildwheel==2.8.1 displayName: Install dependencies - bash: cibuildwheel --output-dir wheelhouse . displayName: Build wheels diff --git a/examples/circleci-minimal.yml b/examples/circleci-minimal.yml index d490077f..d8ebea72 100644 --- a/examples/circleci-minimal.yml +++ b/examples/circleci-minimal.yml @@ -11,7 +11,7 @@ jobs: - run: name: Build the Linux wheels. command: | - pip3 install --user cibuildwheel==2.8.0 + pip3 install --user cibuildwheel==2.8.1 cibuildwheel --output-dir wheelhouse - store_artifacts: path: wheelhouse/ @@ -25,7 +25,7 @@ jobs: - run: name: Build the OS X wheels. command: | - pip3 install cibuildwheel==2.8.0 + pip3 install cibuildwheel==2.8.1 cibuildwheel --output-dir wheelhouse - store_artifacts: path: wheelhouse/ diff --git a/examples/github-apple-silicon.yml b/examples/github-apple-silicon.yml index af0b993f..95154a33 100644 --- a/examples/github-apple-silicon.yml +++ b/examples/github-apple-silicon.yml @@ -10,7 +10,7 @@ jobs: - uses: actions/checkout@v3 - name: Build wheels - uses: pypa/cibuildwheel@v2.8.0 + uses: pypa/cibuildwheel@v2.8.1 env: CIBW_ARCHS_MACOS: x86_64 universal2 diff --git a/examples/github-deploy.yml b/examples/github-deploy.yml index 1ec1385c..75b8cd1c 100644 --- a/examples/github-deploy.yml +++ b/examples/github-deploy.yml @@ -22,7 +22,7 @@ jobs: - uses: actions/checkout@v3 - name: Build wheels - uses: pypa/cibuildwheel@v2.8.0 + uses: pypa/cibuildwheel@v2.8.1 - uses: actions/upload-artifact@v3 with: diff --git a/examples/github-minimal.yml b/examples/github-minimal.yml index 963e5258..e1e1f99b 100644 --- a/examples/github-minimal.yml +++ b/examples/github-minimal.yml @@ -14,7 +14,7 @@ jobs: - uses: actions/checkout@v3 - name: Build wheels - uses: pypa/cibuildwheel@v2.8.0 + uses: pypa/cibuildwheel@v2.8.1 # env: # CIBW_SOME_OPTION: value # ... diff --git a/examples/github-with-qemu.yml b/examples/github-with-qemu.yml index 01426723..1ba744d2 100644 --- a/examples/github-with-qemu.yml +++ b/examples/github-with-qemu.yml @@ -25,7 +25,7 @@ jobs: platforms: all - name: Build wheels - uses: pypa/cibuildwheel@v2.8.0 + uses: pypa/cibuildwheel@v2.8.1 env: # configure cibuildwheel to build native archs ('auto'), and some # emulated ones diff --git a/examples/gitlab-minimal.yml b/examples/gitlab-minimal.yml index 8971b8fa..5c987965 100644 --- a/examples/gitlab-minimal.yml +++ b/examples/gitlab-minimal.yml @@ -12,7 +12,7 @@ linux: DOCKER_TLS_CERTDIR: "" script: - curl -sSL https://get.docker.com/ | sh - - python -m pip install cibuildwheel==2.8.0 + - python -m pip install cibuildwheel==2.8.1 - cibuildwheel --output-dir wheelhouse artifacts: paths: diff --git a/examples/travis-ci-deploy.yml b/examples/travis-ci-deploy.yml index 6a26d576..663080ab 100644 --- a/examples/travis-ci-deploy.yml +++ b/examples/travis-ci-deploy.yml @@ -19,7 +19,7 @@ jobs: - ln -s /c/Python38/python.exe /c/Python38/python3.exe install: - - python3 -m pip install cibuildwheel==2.8.0 + - python3 -m pip install cibuildwheel==2.8.1 script: # build the wheels, put them into './dist' diff --git a/examples/travis-ci-minimal.yml b/examples/travis-ci-minimal.yml index bbfabdb4..9ca1fee1 100644 --- a/examples/travis-ci-minimal.yml +++ b/examples/travis-ci-minimal.yml @@ -25,7 +25,7 @@ jobs: - ln -s /c/Python38/python.exe /c/Python38/python3.exe install: - - python3 -m pip install cibuildwheel==2.8.0 + - python3 -m pip install cibuildwheel==2.8.1 script: # build the wheels, put them into './wheelhouse' diff --git a/examples/travis-ci-test-and-deploy.yml b/examples/travis-ci-test-and-deploy.yml index 61a34ce7..837db2eb 100644 --- a/examples/travis-ci-test-and-deploy.yml +++ b/examples/travis-ci-test-and-deploy.yml @@ -55,7 +55,7 @@ jobs: - stage: deploy name: Build and deploy Linux wheels services: docker - install: python3 -m pip install cibuildwheel==2.8.0 twine + install: python3 -m pip install cibuildwheel==2.8.1 twine script: python3 -m cibuildwheel --output-dir wheelhouse after_success: python3 -m twine upload --skip-existing wheelhouse/*.whl # Deploy on windows @@ -63,7 +63,7 @@ jobs: name: Build and deploy Windows wheels os: windows language: shell - install: python3 -m pip install cibuildwheel==2.8.0 twine + install: python3 -m pip install cibuildwheel==2.8.1 twine script: python3 -m cibuildwheel --output-dir wheelhouse after_success: python3 -m twine upload --skip-existing wheelhouse/*.whl diff --git a/setup.cfg b/setup.cfg index dab4ab94..2efc7c51 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = cibuildwheel -version = 2.8.0 +version = 2.8.1 description = Build Python wheels on CI with minimal configuration. long_description = file: README.md long_description_content_type = text/markdown From bc17f103f199366cfe2669b440e0ca4b01695362 Mon Sep 17 00:00:00 2001 From: mayeut Date: Thu, 14 Jul 2022 12:47:01 +0200 Subject: [PATCH 75/86] chore: drop python 3.6 for cibuildwheel driver This drops python 3.6 for cibuildwheel. Building python 3.6 packages is still supported. --- .circleci/config.yml | 10 +++++----- .pre-commit-config.yaml | 17 +++-------------- .travis.yml | 22 +++++++++++----------- CI.md | 12 ++++++------ azure-pipelines.yml | 11 ----------- bin/update_dependencies.py | 1 - cibuildwheel/bashlex_eval.py | 4 +--- docs/contributing.md | 2 -- examples/circleci-minimal.yml | 2 +- examples/travis-ci-test-and-deploy.yml | 1 - pyproject.toml | 4 ++-- setup.cfg | 4 +--- test/test_macos_archs.py | 2 +- test/utils.py | 2 +- unit_test/oci_container_test.py | 4 ++-- 15 files changed, 34 insertions(+), 64 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 62cefcab..3a657f7e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,7 +1,7 @@ version: 2 jobs: - osx-python3.6: + osx-python3.9: macos: xcode: 12.5.1 environment: @@ -17,9 +17,9 @@ jobs: command: venv/bin/python ./bin/run_tests.py no_output_timeout: 30m - linux-python3.6: + linux-python3.9: docker: - - image: circleci/python:3.6 + - image: circleci/python:3.9 environment: PYTHON: python3 # Temporarily restrict the tests that are run on CircleCI to prevent @@ -41,5 +41,5 @@ workflows: version: 2 all-tests: jobs: - - osx-python3.6 - - linux-python3.6 + - osx-python3.9 + - linux-python3.9 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fdd22536..38864019 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,12 +17,6 @@ repos: rev: v2.37.1 hooks: - id: pyupgrade - name: PyUpgrade 3.6+ - args: ["--py36-plus"] - exclude: ^bin/ - - id: pyupgrade - name: PyUpgrade 3.7+ on bin - exclude: ^(cibuildwheel|unit_test|test)/ args: ["--py37-plus"] # Autoremoves unused imports @@ -52,9 +46,9 @@ repos: rev: v0.961 hooks: - id: mypy - name: mypy 3.6 on cibuildwheel/ - exclude: ^(bin|cibuildwheel/resources|docs)/.*py$ - args: ["--python-version=3.6"] + name: mypy 3.7 on cibuildwheel/ + exclude: ^cibuildwheel/resources/.*py$ + args: ["--python-version=3.7"] additional_dependencies: &mypy-dependencies - nox - packaging>=21.0 @@ -70,11 +64,6 @@ repos: - types-requests - bracex - dataclasses - - id: mypy - name: mypy 3.7+ on bin/ - files: ^((bin|docs)/.*py)$ - args: ["--python-version=3.7"] - additional_dependencies: *mypy-dependencies - id: mypy name: mypy 3.10 args: ["--python-version=3.10"] diff --git a/.travis.yml b/.travis.yml index aad9e5a5..4256a69b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,21 +8,21 @@ branches: jobs: include: - - name: Linux | x86_64 + i686 | Python 3.6 - python: 3.6 + - name: Linux | x86_64 + i686 | Python 3.7 + python: 3.7 services: docker env: PYTHON=python - - name: Linux | arm64 | Python 3.6 - python: 3.6 + - name: Linux | arm64 | Python 3.7 + python: 3.7 services: docker arch: arm64-graviton2 group: edge virt: vm env: PYTHON=python - - name: Linux | ppc64le | Python 3.6 - python: 3.6 + - name: Linux | ppc64le | Python 3.7 + python: 3.7 services: docker arch: ppc64le allow_failure: True @@ -32,18 +32,18 @@ jobs: # c.f. https://travis-ci.community/t/running-out-of-disk-space-quota-when-using-docker-on-ppc64le/11634 - PYTEST_ADDOPTS='-k "not test_manylinuxXXXX_only"' - - name: Windows | x86_64 | Python 3.6 + - name: Windows | x86_64 | Python 3.7 os: windows language: shell before_install: - - choco upgrade python3 -y --version 3.6.8 --limit-output + - choco upgrade python3 -y --version 3.7.9 --limit-output # Update root certificates to fix SSL error; see http://www.chawn.com/RootCerts.htm - powershell "md C:\temp\certs; CertUtil -generateSSTFromWU C:\temp\certs\RootStore.sst; Get-ChildItem -Path C:\\temp\certs\Rootstore.sst | Import-Certificate -CertStoreLocation Cert:\\LocalMachine\\Root\\ | out-null" env: - - PYTHON=C:\\Python36\\python + - PYTHON=C:\\Python37\\python - - name: Linux | s390x | Python 3.6 - python: 3.6 + - name: Linux | s390x | Python 3.7 + python: 3.7 services: docker arch: s390x env: PYTHON=python diff --git a/CI.md b/CI.md index 8ac4ada5..76167c35 100644 --- a/CI.md +++ b/CI.md @@ -1,11 +1,11 @@ This is a summary of the Python versions and platforms covered by the different CI platforms: -| | 3.6 | 3.7 | 3.8 | -|----------|------------------------------|-----------------------------|------------------| -| Linux | Travis CI / CircleCI | AppVeyor¹ / GitHub Actions | Azure Pipelines | -| macOS | CircleCI | AppVeyor¹ / GitHub Actions | Azure Pipelines | -| Windows | Travis CI / Azure Pipelines | AppVeyor¹ / GitHub Actions | Azure Pipelines | +| | 3.7 | 3.8 | 3.9 | 3.10 | +|----------|-----------------------|---------------------------|----------|----------------| +| Linux | AppVeyor¹ / Travis CI | Azure Pipelines / GitLab | CircleCI | GitHub Actions | +| macOS | AppVeyor¹ / Travis CI | Azure Pipelines | CircleCI | GitHub Actions | +| Windows | AppVeyor¹ / Travis CI | Azure Pipelines | | GitHub Actions | > ¹ AppVeyor only runs the "basic" test to reduce load. -Non-x86 architectures are covered on Travis CI using Python 3.6. +Non-x86 architectures are covered on Travis CI using Python 3.7. diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 56131899..f8142ce8 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -20,17 +20,6 @@ jobs: python -m pip install -e ".[dev]" pytest-azurepipelines python ./bin/run_tests.py -- job: windows_36 - pool: {vmImage: 'windows-2019'} - timeoutInMinutes: 180 - steps: - - task: UsePythonVersion@0 - inputs: - versionSpec: '3.6' - - bash: | - python -m pip install -e ".[dev]" pytest-azurepipelines - python ./bin/run_tests.py - - job: windows_38 pool: {vmImage: 'windows-2019'} timeoutInMinutes: 180 diff --git a/bin/update_dependencies.py b/bin/update_dependencies.py index 69e62cfa..9dc9f536 100755 --- a/bin/update_dependencies.py +++ b/bin/update_dependencies.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# This file supports 3.6+ import os import shutil diff --git a/cibuildwheel/bashlex_eval.py b/cibuildwheel/bashlex_eval.py index a8b4691c..cd1fa563 100644 --- a/cibuildwheel/bashlex_eval.py +++ b/cibuildwheel/bashlex_eval.py @@ -9,9 +9,7 @@ EnvironmentExecutor = Callable[[List[str], Dict[str, str]], str] def local_environment_executor(command: List[str], env: Dict[str, str]) -> str: - return subprocess.run( - command, env=env, universal_newlines=True, stdout=subprocess.PIPE, check=True - ).stdout + return subprocess.run(command, env=env, text=True, stdout=subprocess.PIPE, check=True).stdout @dataclass(frozen=True) diff --git a/docs/contributing.md b/docs/contributing.md index c6a5b930..24566e4e 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -94,7 +94,6 @@ This has been moved to using docker, so you only need the following instructions The dependency update script in the next section requires multiple python versions installed. One way to do this is to use `pyenv`: ```bash -pyenv install 3.6.11 pyenv install 3.7.8 # Optionally add 3.8 and make it the local version; # otherwise assuming 3.8+ already is your current python version @@ -103,7 +102,6 @@ pyenv install 3.7.8 Then, you need to make the required virtual environments: ```bash -$(pyenv prefix 3.6.11)/bin/python -m venv env36 $(pyenv prefix 3.7.8)/bin/python -m venv env37 ``` diff --git a/examples/circleci-minimal.yml b/examples/circleci-minimal.yml index d8ebea72..3162ceb5 100644 --- a/examples/circleci-minimal.yml +++ b/examples/circleci-minimal.yml @@ -4,7 +4,7 @@ jobs: linux-wheels: working_directory: ~/linux-wheels docker: - - image: circleci/python:3.6 + - image: circleci/python:3.9 steps: - checkout - setup_remote_docker diff --git a/examples/travis-ci-test-and-deploy.yml b/examples/travis-ci-test-and-deploy.yml index 837db2eb..42a27954 100644 --- a/examples/travis-ci-test-and-deploy.yml +++ b/examples/travis-ci-test-and-deploy.yml @@ -9,7 +9,6 @@ os: linux dist: focal language: python python: - - 3.6 - 3.7 - 3.8 diff --git a/pyproject.toml b/pyproject.toml index 40f8dc5a..6c78cdb0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ build-backend = "setuptools.build_meta" [tool.black] line-length = 100 -target-version = ['py36', 'py37', 'py38', 'py39', 'py310'] +target-version = ['py37', 'py38', 'py39', 'py310'] [tool.isort] @@ -88,7 +88,7 @@ ignore = [ ] [tool.pylint] -master.py-version = "3.6" +master.py-version = "3.7" master.jobs = "0" master.fail-on = ["E", "F"] master.fail-under = "9.8" diff --git a/setup.cfg b/setup.cfg index 2efc7c51..51718be9 100644 --- a/setup.cfg +++ b/setup.cfg @@ -16,7 +16,6 @@ classifiers = Natural Language :: English Programming Language :: Python :: 3 Programming Language :: Python :: 3 :: Only - Programming Language :: Python :: 3.6 Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 @@ -37,10 +36,9 @@ install_requires = filelock packaging>=20.9 platformdirs - dataclasses;python_version < '3.7' tomli;python_version < '3.11' typing-extensions>=3.10.0.0;python_version < '3.8' -python_requires = >=3.6 +python_requires = >=3.7 include_package_data = True zip_safe = False diff --git a/test/test_macos_archs.py b/test/test_macos_archs.py index a5db09f8..a85a6b24 100644 --- a/test/test_macos_archs.py +++ b/test/test_macos_archs.py @@ -17,7 +17,7 @@ ALL_MACOS_WHEELS = { def get_xcode_version() -> Tuple[int, int]: output = subprocess.run( ["xcodebuild", "-version"], - universal_newlines=True, + text=True, check=True, stdout=subprocess.PIPE, ).stdout diff --git a/test/utils.py b/test/utils.py index 22fe4c1a..ebe682e3 100644 --- a/test/utils.py +++ b/test/utils.py @@ -35,7 +35,7 @@ def cibuildwheel_get_build_identifiers(project_path, env=None, *, prerelease_pyt cmd_output = subprocess.run( cmd, - universal_newlines=True, + text=True, env=env, check=True, stdout=subprocess.PIPE, diff --git a/unit_test/oci_container_test.py b/unit_test/oci_container_test.py index 2f425daf..05ef24fd 100644 --- a/unit_test/oci_container_test.py +++ b/unit_test/oci_container_test.py @@ -83,7 +83,7 @@ def test_container_removed(container_engine): shell=True, check=True, stdout=subprocess.PIPE, - universal_newlines=True, + text=True, ).stdout assert container.name is not None assert container.name in docker_containers_listing @@ -94,7 +94,7 @@ def test_container_removed(container_engine): shell=True, check=True, stdout=subprocess.PIPE, - universal_newlines=True, + text=True, ).stdout assert old_container_name not in docker_containers_listing From 054230e01ba8d090357f90092eda0078448b0da3 Mon Sep 17 00:00:00 2001 From: mayeut Date: Thu, 14 Jul 2022 15:23:59 +0200 Subject: [PATCH 76/86] fix: test_build_default_launches to use an empty package dir test_build_default_launches was using cibuildwheel setup.cfg which led to the test failing once python 3.6 was dropped. Use an empty package, provided by fake_package_dir, to run the test. --- unit_test/conftest.py | 4 +++- unit_test/option_prepare_test.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/unit_test/conftest.py b/unit_test/conftest.py index cbfdbb72..3d98c30b 100644 --- a/unit_test/conftest.py +++ b/unit_test/conftest.py @@ -12,7 +12,7 @@ def pytest_addoption(parser): @pytest.fixture -def fake_package_dir(monkeypatch): +def fake_package_dir(tmp_path, monkeypatch): """ Monkey-patch enough for the main() function to run """ @@ -25,6 +25,8 @@ def fake_package_dir(monkeypatch): return real_path_exists(path) args = ["cibuildwheel", str(MOCK_PACKAGE_DIR)] + tmp_path.joinpath(MOCK_PACKAGE_DIR).mkdir() monkeypatch.setattr(Path, "exists", mock_path_exists) monkeypatch.setattr(sys, "argv", args) + monkeypatch.chdir(tmp_path) return args diff --git a/unit_test/option_prepare_test.py b/unit_test/option_prepare_test.py index 10bca432..3eef68a7 100644 --- a/unit_test/option_prepare_test.py +++ b/unit_test/option_prepare_test.py @@ -44,7 +44,7 @@ def mock_build_container(monkeypatch): def test_build_default_launches(mock_build_container, fake_package_dir, monkeypatch): - monkeypatch.setattr(sys, "argv", ["cibuildwheel", "--platform=linux"]) + monkeypatch.setattr(sys, "argv", sys.argv + ["--platform=linux"]) main() From 6d27f05c7cc57786febc4eb5894ef27ef078ee0e Mon Sep 17 00:00:00 2001 From: mayeut Date: Thu, 14 Jul 2022 13:36:57 +0200 Subject: [PATCH 77/86] chore: use `from __future__ import annotations` --- .pre-commit-config.yaml | 3 + bin/run_tests.py | 2 + bin/update_dependencies.py | 2 + bin/update_readme_changelog.py | 2 + cibuildwheel/__init__.py | 2 + cibuildwheel/__main__.py | 21 ++--- cibuildwheel/architecture.py | 15 ++-- cibuildwheel/bashlex_eval.py | 12 +-- cibuildwheel/environment.py | 20 ++--- cibuildwheel/extra.py | 5 +- cibuildwheel/functools_cached_property_38.py | 14 ++-- cibuildwheel/linux.py | 20 ++--- cibuildwheel/logger.py | 20 ++--- cibuildwheel/macos.py | 18 +++-- cibuildwheel/oci_container.py | 26 +++--- cibuildwheel/options.py | 81 +++++++++---------- cibuildwheel/projectfiles.py | 10 ++- cibuildwheel/typing.py | 4 +- cibuildwheel/util.py | 48 +++++------ cibuildwheel/windows.py | 16 ++-- docs/main.py | 2 + noxfile.py | 2 + setup.py | 2 + test/conftest.py | 4 +- test/test_0_basic.py | 2 + test/test_abi_variants.py | 2 + test/test_before_all.py | 2 + test/test_before_build.py | 2 + test/test_before_test.py | 2 + test/test_build_skip.py | 2 + test/test_container_images.py | 2 + test/test_cpp_standards.py | 2 + test/test_dependency_versions.py | 2 + test/test_emulation.py | 2 + test/test_environment.py | 2 + test/test_from_sdist.py | 2 + test/test_macos_archs.py | 5 +- test/test_manylinuxXXXX_only.py | 2 + test/test_pep518.py | 2 + test/test_podman.py | 2 + test/test_projects/__init__.py | 2 + test/test_projects/__main__.py | 2 + test/test_projects/base.py | 2 + test/test_projects/c.py | 2 + test/test_pure_wheel.py | 2 + test/test_same_wheel.py | 2 + test/test_ssl.py | 2 + test/test_subdir_package.py | 2 + test/test_testing.py | 2 + test/test_troubleshooting.py | 2 + test/test_wheel_tag.py | 2 + test/utils.py | 2 + unit_test/build_ids_test.py | 5 +- unit_test/build_selector_test.py | 2 + unit_test/conftest.py | 2 + unit_test/dependency_constraints_test.py | 2 + unit_test/download_test.py | 2 + unit_test/environment_test.py | 2 + unit_test/linux_build_steps_test.py | 2 + unit_test/main_tests/conftest.py | 2 + unit_test/main_tests/main_options_test.py | 2 + unit_test/main_tests/main_platform_test.py | 2 + .../main_tests/main_requires_python_test.py | 2 + unit_test/oci_container_test.py | 2 + unit_test/option_prepare_test.py | 2 + unit_test/options_test.py | 2 + unit_test/options_toml_test.py | 2 + unit_test/projectfiles_test.py | 2 + unit_test/utils.py | 2 + unit_test/utils_test.py | 2 + unit_test/wheel_print_test.py | 2 + 71 files changed, 285 insertions(+), 166 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 38864019..271c1019 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,6 +18,7 @@ repos: hooks: - id: pyupgrade args: ["--py37-plus"] + exclude: ^cibuildwheel/resources/.*py$ # Autoremoves unused imports - repo: https://github.com/hadialqattan/pycln @@ -31,6 +32,8 @@ repos: rev: 5.10.1 hooks: - id: isort + args: ["-a", "from __future__ import annotations"] + exclude: ^cibuildwheel/resources/.*py$ - repo: https://github.com/psf/black rev: 22.6.0 diff --git a/bin/run_tests.py b/bin/run_tests.py index 82e193c3..583d13c7 100755 --- a/bin/run_tests.py +++ b/bin/run_tests.py @@ -1,5 +1,7 @@ #!/usr/bin/env python3 +from __future__ import annotations + import argparse import os import subprocess diff --git a/bin/update_dependencies.py b/bin/update_dependencies.py index 9dc9f536..c0d7f200 100755 --- a/bin/update_dependencies.py +++ b/bin/update_dependencies.py @@ -1,5 +1,7 @@ #!/usr/bin/env python3 +from __future__ import annotations + import os import shutil import subprocess diff --git a/bin/update_readme_changelog.py b/bin/update_readme_changelog.py index 90b2ffd8..4a4625ff 100755 --- a/bin/update_readme_changelog.py +++ b/bin/update_readme_changelog.py @@ -1,5 +1,7 @@ #!/usr/bin/env python3 +from __future__ import annotations + import re import sys from pathlib import Path diff --git a/cibuildwheel/__init__.py b/cibuildwheel/__init__.py index b4066b65..b923f228 100644 --- a/cibuildwheel/__init__.py +++ b/cibuildwheel/__init__.py @@ -1 +1,3 @@ +from __future__ import annotations + __version__ = "2.8.1" diff --git a/cibuildwheel/__main__.py b/cibuildwheel/__main__.py index a3b7711f..034673a2 100644 --- a/cibuildwheel/__main__.py +++ b/cibuildwheel/__main__.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import argparse import os import shutil @@ -7,7 +9,6 @@ import tempfile import textwrap from pathlib import Path from tempfile import mkdtemp -from typing import List, Set, Union import cibuildwheel import cibuildwheel.linux @@ -257,7 +258,7 @@ def build_in_directory(args: CommandLineArguments) -> None: log.warning(f"Can't delete temporary folder '{str(tmp_path)}'") -def print_preamble(platform: str, options: Options, identifiers: List[str]) -> None: +def print_preamble(platform: str, options: Options, identifiers: list[str]) -> None: print( textwrap.dedent( """ @@ -287,13 +288,13 @@ def print_preamble(platform: str, options: Options, identifiers: List[str]) -> N def get_build_identifiers( - platform: PlatformName, build_selector: BuildSelector, architectures: Set[Architecture] -) -> List[str]: - python_configurations: Union[ - List[cibuildwheel.linux.PythonConfiguration], - List[cibuildwheel.windows.PythonConfiguration], - List[cibuildwheel.macos.PythonConfiguration], - ] + platform: PlatformName, build_selector: BuildSelector, architectures: set[Architecture] +) -> list[str]: + python_configurations: ( + list[cibuildwheel.linux.PythonConfiguration] + | list[cibuildwheel.windows.PythonConfiguration] + | list[cibuildwheel.macos.PythonConfiguration] + ) if platform == "linux": python_configurations = cibuildwheel.linux.get_python_configurations( @@ -313,7 +314,7 @@ def get_build_identifiers( return [config.identifier for config in python_configurations] -def detect_warnings(*, options: Options, identifiers: List[str]) -> List[str]: +def detect_warnings(*, options: Options, identifiers: list[str]) -> list[str]: warnings = [] # warn about deprecated {python} and {pip} diff --git a/cibuildwheel/architecture.py b/cibuildwheel/architecture.py index be87f321..82a78b30 100644 --- a/cibuildwheel/architecture.py +++ b/cibuildwheel/architecture.py @@ -1,8 +1,9 @@ +from __future__ import annotations + import functools import platform as platform_module import re from enum import Enum -from typing import Set from .typing import Final, Literal, PlatformName, assert_never @@ -32,11 +33,11 @@ class Architecture(Enum): ARM64 = "ARM64" # Allow this to be sorted - def __lt__(self, other: "Architecture") -> bool: + def __lt__(self, other: Architecture) -> bool: return self.value < other.value @staticmethod - def parse_config(config: str, platform: PlatformName) -> "Set[Architecture]": + def parse_config(config: str, platform: PlatformName) -> set[Architecture]: result = set() for arch_str in re.split(r"[\s,]+", config): if arch_str == "auto": @@ -54,7 +55,7 @@ class Architecture(Enum): return result @staticmethod - def auto_archs(platform: PlatformName) -> "Set[Architecture]": + def auto_archs(platform: PlatformName) -> set[Architecture]: native_architecture = Architecture(platform_module.machine()) result = {native_architecture} @@ -72,7 +73,7 @@ class Architecture(Enum): return result @staticmethod - def all_archs(platform: PlatformName) -> "Set[Architecture]": + def all_archs(platform: PlatformName) -> set[Architecture]: all_archs_map = { "linux": { Architecture.x86_64, @@ -87,7 +88,7 @@ class Architecture(Enum): return all_archs_map[platform] @staticmethod - def bitness_archs(platform: PlatformName, bitness: Literal["64", "32"]) -> "Set[Architecture]": + def bitness_archs(platform: PlatformName, bitness: Literal["64", "32"]) -> set[Architecture]: archs_32 = {Architecture.i686, Architecture.x86} auto_archs = Architecture.auto_archs(platform) @@ -101,7 +102,7 @@ class Architecture(Enum): def allowed_architectures_check( platform: PlatformName, - architectures: Set[Architecture], + architectures: set[Architecture], ) -> None: allowed_architectures = Architecture.all_archs(platform) diff --git a/cibuildwheel/bashlex_eval.py b/cibuildwheel/bashlex_eval.py index cd1fa563..47e4aea3 100644 --- a/cibuildwheel/bashlex_eval.py +++ b/cibuildwheel/bashlex_eval.py @@ -1,6 +1,8 @@ +from __future__ import annotations + import subprocess from dataclasses import dataclass -from typing import Callable, Dict, List, Optional, Sequence +from typing import Callable, Dict, List, Sequence import bashlex @@ -8,19 +10,19 @@ import bashlex EnvironmentExecutor = Callable[[List[str], Dict[str, str]], str] -def local_environment_executor(command: List[str], env: Dict[str, str]) -> str: +def local_environment_executor(command: list[str], env: dict[str, str]) -> str: return subprocess.run(command, env=env, text=True, stdout=subprocess.PIPE, check=True).stdout @dataclass(frozen=True) class NodeExecutionContext: - environment: Dict[str, str] + environment: dict[str, str] input: str executor: EnvironmentExecutor def evaluate( - value: str, environment: Dict[str, str], executor: Optional[EnvironmentExecutor] = None + value: str, environment: dict[str, str], executor: EnvironmentExecutor | None = None ) -> str: if not value: # empty string evaluates to empty string @@ -101,7 +103,7 @@ def evaluate_nodes_as_compound_command( def evaluate_nodes_as_simple_command( - nodes: List[bashlex.ast.node], context: NodeExecutionContext + nodes: list[bashlex.ast.node], context: NodeExecutionContext ) -> str: command = [evaluate_node(part, context=context) for part in nodes] return context.executor(command, context.environment) diff --git a/cibuildwheel/environment.py b/cibuildwheel/environment.py index 3bf982d2..a544852a 100644 --- a/cibuildwheel/environment.py +++ b/cibuildwheel/environment.py @@ -1,5 +1,7 @@ +from __future__ import annotations + import dataclasses -from typing import Any, Dict, List, Mapping, Optional, Sequence +from typing import Any, Mapping, Sequence import bashlex @@ -12,7 +14,7 @@ class EnvironmentParseError(Exception): pass -def split_env_items(env_string: str) -> List[str]: +def split_env_items(env_string: str) -> list[str]: """Splits space-separated variable assignments into a list of individual assignments. >>> split_env_items('VAR=abc') @@ -47,8 +49,8 @@ class EnvironmentAssignment(Protocol): def evaluated_value( self, *, - environment: Dict[str, str], - executor: Optional[bashlex_eval.EnvironmentExecutor] = None, + environment: dict[str, str], + executor: bashlex_eval.EnvironmentExecutor | None = None, ) -> str: """Returns the value of this assignment, as evaluated in the environment""" @@ -84,8 +86,8 @@ class EnvironmentAssignmentBash: def evaluated_value( self, - environment: Dict[str, str], - executor: Optional[bashlex_eval.EnvironmentExecutor] = None, + environment: dict[str, str], + executor: bashlex_eval.EnvironmentExecutor | None = None, ) -> str: return bashlex_eval.evaluate(self.value, environment=environment, executor=executor) @@ -100,7 +102,7 @@ class EnvironmentAssignmentBash: @dataclasses.dataclass class ParsedEnvironment: - assignments: List[EnvironmentAssignment] + assignments: list[EnvironmentAssignment] def __init__(self, assignments: Sequence[EnvironmentAssignment]) -> None: self.assignments = list(assignments) @@ -108,8 +110,8 @@ class ParsedEnvironment: def as_dictionary( self, prev_environment: Mapping[str, str], - executor: Optional[bashlex_eval.EnvironmentExecutor] = None, - ) -> Dict[str, str]: + executor: bashlex_eval.EnvironmentExecutor | None = None, + ) -> dict[str, str]: environment = dict(**prev_environment) for assignment in self.assignments: diff --git a/cibuildwheel/extra.py b/cibuildwheel/extra.py index 60eecbad..36389e6f 100644 --- a/cibuildwheel/extra.py +++ b/cibuildwheel/extra.py @@ -2,8 +2,9 @@ These are utilities for the `/bin` scripts, not for the `cibuildwheel` program. """ +from __future__ import annotations + from io import StringIO -from typing import Dict, List from .typing import Protocol @@ -15,7 +16,7 @@ class Printable(Protocol): ... -def dump_python_configurations(inp: Dict[str, Dict[str, List[Dict[str, Printable]]]]) -> str: +def dump_python_configurations(inp: dict[str, dict[str, list[dict[str, Printable]]]]) -> str: output = StringIO() for header, values in inp.items(): output.write(f"[{header}]\n") diff --git a/cibuildwheel/functools_cached_property_38.py b/cibuildwheel/functools_cached_property_38.py index e1c45ac2..cbe4537a 100644 --- a/cibuildwheel/functools_cached_property_38.py +++ b/cibuildwheel/functools_cached_property_38.py @@ -1,5 +1,7 @@ +from __future__ import annotations + from threading import RLock -from typing import Any, Callable, Generic, Optional, Type, TypeVar, overload +from typing import Any, Callable, Generic, TypeVar, overload __all__ = ["cached_property"] @@ -11,11 +13,11 @@ _T = TypeVar("_T") class cached_property(Generic[_T]): def __init__(self, func: Callable[[Any], _T]): self.func = func - self.attrname: Optional[str] = None + self.attrname: str | None = None self.__doc__ = func.__doc__ self.lock = RLock() - def __set_name__(self, owner: Type[Any], name: str) -> None: + def __set_name__(self, owner: type[Any], name: str) -> None: if self.attrname is None: self.attrname = name elif name != self.attrname: @@ -25,14 +27,14 @@ class cached_property(Generic[_T]): ) @overload - def __get__(self, instance: None, owner: Optional[Type[Any]] = ...) -> "cached_property[_T]": + def __get__(self, instance: None, owner: type[Any] | None = ...) -> cached_property[_T]: ... @overload - def __get__(self, instance: object, owner: Optional[Type[Any]] = ...) -> _T: + def __get__(self, instance: object, owner: type[Any] | None = ...) -> _T: ... - def __get__(self, instance: Optional[object], owner: Optional[Type[Any]] = None) -> Any: + def __get__(self, instance: object | None, owner: type[Any] | None = None) -> Any: if instance is None: return self if self.attrname is None: diff --git a/cibuildwheel/linux.py b/cibuildwheel/linux.py index 57a7deee..2a0ec43f 100644 --- a/cibuildwheel/linux.py +++ b/cibuildwheel/linux.py @@ -1,9 +1,11 @@ +from __future__ import annotations + import subprocess import sys import textwrap from dataclasses import dataclass from pathlib import Path, PurePath, PurePosixPath -from typing import Iterator, List, Set, Tuple +from typing import Iterator, Tuple from .architecture import Architecture from .logger import log @@ -35,15 +37,15 @@ class PythonConfiguration: @dataclass(frozen=True) class BuildStep: - platform_configs: List[PythonConfiguration] + platform_configs: list[PythonConfiguration] platform_tag: str container_image: str def get_python_configurations( build_selector: BuildSelector, - architectures: Set[Architecture], -) -> List[PythonConfiguration]: + architectures: set[Architecture], +) -> list[PythonConfiguration]: full_python_configs = read_python_configs("linux") @@ -79,7 +81,7 @@ def container_image_for_python_configuration(config: PythonConfiguration, option def get_build_steps( - options: Options, python_configurations: List[PythonConfiguration] + options: Options, python_configurations: list[PythonConfiguration] ) -> Iterator[BuildStep]: """ Groups PythonConfigurations into BuildSteps. Each BuildStep represents a @@ -110,7 +112,7 @@ def get_build_steps( def build_in_container( *, options: Options, - platform_configs: List[PythonConfiguration], + platform_configs: list[PythonConfiguration], container: OCIContainer, container_project_path: PurePath, container_package_dir: PurePath, @@ -140,13 +142,13 @@ def build_in_container( ) container.call(["sh", "-c", before_all_prepared], env=env) - built_wheels: List[PurePosixPath] = [] + built_wheels: list[PurePosixPath] = [] for config in platform_configs: log.build_start(config.identifier) build_options = options.build_options(config.identifier) - dependency_constraint_flags: List[PathOrStr] = [] + dependency_constraint_flags: list[PathOrStr] = [] if build_options.dependency_constraints: constraints_file = build_options.dependency_constraints.get_for_python_version( @@ -395,7 +397,7 @@ def build(options: Options, tmp_path: Path) -> None: # pylint: disable=unused-a sys.exit(1) -def _matches_prepared_command(error_cmd: List[str], command_template: str) -> bool: +def _matches_prepared_command(error_cmd: list[str], command_template: str) -> bool: if len(error_cmd) < 3 or error_cmd[0:2] != ["sh", "-c"]: return False command_prefix = command_template.split("{", maxsplit=1)[0].strip() diff --git a/cibuildwheel/logger.py b/cibuildwheel/logger.py index 0a4be14d..6f408b47 100644 --- a/cibuildwheel/logger.py +++ b/cibuildwheel/logger.py @@ -1,9 +1,11 @@ +from __future__ import annotations + import codecs import os import re import sys import time -from typing import IO, AnyStr, Optional, Union +from typing import IO, AnyStr from cibuildwheel.typing import Final from cibuildwheel.util import CIProvider, detect_ci_provider @@ -39,10 +41,10 @@ class Logger: fold_mode: str colors_enabled: bool unicode_enabled: bool - active_build_identifier: Optional[str] = None - build_start_time: Optional[float] = None - step_start_time: Optional[float] = None - active_fold_group_name: Optional[str] = None + active_build_identifier: str | None = None + build_start_time: float | None = None + step_start_time: float | None = None + active_fold_group_name: str | None = None def __init__(self) -> None: if sys.platform == "win32" and hasattr(sys.stdout, "reconfigure"): @@ -120,7 +122,7 @@ class Logger: self.step_start_time = None - def step_end_with_error(self, error: Union[BaseException, str]) -> None: + def step_end_with_error(self, error: BaseException | str) -> None: self.step_end(success=False) self.error(error) @@ -131,7 +133,7 @@ class Logger: c = self.colors print(f"{c.yellow}Warning{c.end}: {message}\n", file=sys.stderr) - def error(self, error: Union[BaseException, str]) -> None: + def error(self, error: BaseException | str) -> None: if self.fold_mode == "github": print(f"::error::{error}\n", file=sys.stderr) else: @@ -174,11 +176,11 @@ class Logger: return identifier.lower()[:20] @property - def colors(self) -> "Colors": + def colors(self) -> Colors: return Colors(enabled=self.colors_enabled) @property - def symbols(self) -> "Symbols": + def symbols(self) -> Symbols: return Symbols(unicode=self.unicode_enabled) diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index beb4d32e..6d56be20 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import functools import os import platform @@ -7,7 +9,7 @@ import subprocess import sys from dataclasses import dataclass from pathlib import Path -from typing import Dict, List, Sequence, Set, Tuple, cast +from typing import Sequence, Tuple, cast from filelock import FileLock @@ -37,7 +39,7 @@ from .util import ( ) -def get_macos_version() -> Tuple[int, int]: +def get_macos_version() -> tuple[int, int]: """ Returns the macOS major/minor version, as a tuple, e.g. (10, 15) or (11, 0) @@ -51,7 +53,7 @@ def get_macos_version() -> Tuple[int, int]: return cast(Tuple[int, int], version) -def get_macos_sdks() -> List[str]: +def get_macos_sdks() -> list[str]: output = call("xcodebuild", "-showsdks", capture_stdout=True) return [m.group(1) for m in re.finditer(r"-sdk (macosx\S+)", output)] @@ -64,8 +66,8 @@ class PythonConfiguration: def get_python_configurations( - build_selector: BuildSelector, architectures: Set[Architecture] -) -> List[PythonConfiguration]: + build_selector: BuildSelector, architectures: set[Architecture] +) -> list[PythonConfiguration]: full_python_configs = read_python_configs("macos") @@ -134,7 +136,7 @@ def setup_python( dependency_constraint_flags: Sequence[PathOrStr], environment: ParsedEnvironment, build_frontend: BuildFrontend, -) -> Dict[str, str]: +) -> dict[str, str]: tmp.mkdir() implementation_id = python_configuration.identifier.split("-")[0] log.step(f"Installing Python {implementation_id}...") @@ -295,7 +297,7 @@ def build(options: Options, tmp_path: Path) -> None: ) shell(before_all_prepared, env=env) - built_wheels: List[Path] = [] + built_wheels: list[Path] = [] for config in python_configurations: build_options = options.build_options(config.identifier) @@ -418,7 +420,7 @@ def build(options: Options, tmp_path: Path) -> None: if build_options.test_command and build_options.test_selector(config.identifier): machine_arch = platform.machine() - testing_archs: List[Literal["x86_64", "arm64"]] + testing_archs: list[Literal["x86_64", "arm64"]] if config_is_arm64: testing_archs = ["arm64"] diff --git a/cibuildwheel/oci_container.py b/cibuildwheel/oci_container.py index c02f7678..91714c7e 100644 --- a/cibuildwheel/oci_container.py +++ b/cibuildwheel/oci_container.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import io import json import os @@ -9,7 +11,7 @@ import sys import uuid from pathlib import Path, PurePath, PurePosixPath from types import TracebackType -from typing import IO, Dict, List, Optional, Sequence, Type, cast +from typing import IO, Dict, Sequence, cast from cibuildwheel.util import CIProvider, detect_ci_provider @@ -52,7 +54,7 @@ class OCIContainer: *, image: str, simulate_32_bit: bool = False, - cwd: Optional[PathOrStr] = None, + cwd: PathOrStr | None = None, engine: ContainerEngine = "docker", ): if not image: @@ -61,10 +63,10 @@ class OCIContainer: self.image = image self.simulate_32_bit = simulate_32_bit self.cwd = cwd - self.name: Optional[str] = None + self.name: str | None = None self.engine = engine - def __enter__(self) -> "OCIContainer": + def __enter__(self) -> OCIContainer: self.name = f"cibuildwheel-{uuid.uuid4()}" @@ -122,9 +124,9 @@ class OCIContainer: def __exit__( self, - exc_type: Optional[Type[BaseException]], - exc_val: Optional[BaseException], - exc_tb: Optional[TracebackType], + exc_type: type[BaseException] | None, + exc_val: BaseException | None, + exc_tb: TracebackType | None, ) -> None: self.bash_stdin.write(b"exit 0\n") @@ -217,7 +219,7 @@ class OCIContainer: else: 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) path_strings = json.loads( @@ -236,9 +238,9 @@ class OCIContainer: def call( self, args: Sequence[PathOrStr], - env: Optional[Dict[str, str]] = None, + env: dict[str, str] | None = None, capture_output: bool = False, - cwd: Optional[PathOrStr] = None, + cwd: PathOrStr | None = None, ) -> str: if cwd is None: @@ -314,7 +316,7 @@ class OCIContainer: return output - def get_environment(self) -> Dict[str, str]: + def get_environment(self) -> dict[str, str]: env = json.loads( self.call( [ @@ -327,7 +329,7 @@ class OCIContainer: ) return cast(Dict[str, str], env) - def environment_executor(self, command: List[str], environment: Dict[str, str]) -> str: + def environment_executor(self, command: list[str], environment: dict[str, str]) -> str: # used as an EnvironmentExecutor to evaluate commands and capture output return self.call(command, env=environment, capture_output=True) diff --git a/cibuildwheel/options.py b/cibuildwheel/options.py index 59ff1226..30803604 100644 --- a/cibuildwheel/options.py +++ b/cibuildwheel/options.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import functools import os import sys @@ -6,18 +8,7 @@ from configparser import ConfigParser from contextlib import contextmanager from dataclasses import asdict, dataclass from pathlib import Path -from typing import ( - Any, - Dict, - Generator, - List, - Mapping, - Optional, - Set, - Tuple, - Union, - cast, -) +from typing import Any, Dict, Generator, List, Mapping, Union, cast if sys.version_info >= (3, 11): import tomllib @@ -50,7 +41,7 @@ from .util import ( @dataclass class CommandLineArguments: platform: Literal["auto", "linux", "macos", "windows"] - archs: Optional[str] + archs: str | None output_dir: Path config_file: str package_dir: Path @@ -65,7 +56,7 @@ class GlobalOptions: output_dir: Path build_selector: BuildSelector test_selector: TestSelector - architectures: Set[Architecture] + architectures: set[Architecture] container_engine: ContainerEngine @@ -74,14 +65,14 @@ class BuildOptions: globals: GlobalOptions environment: ParsedEnvironment before_all: str - before_build: Optional[str] + before_build: str | None repair_command: str - manylinux_images: Optional[Dict[str, str]] - musllinux_images: Optional[Dict[str, str]] - dependency_constraints: Optional[DependencyConstraints] - test_command: Optional[str] - before_test: Optional[str] - test_requires: List[str] + manylinux_images: dict[str, str] | None + musllinux_images: dict[str, str] | None + dependency_constraints: DependencyConstraints | None + test_command: str | None + before_test: str | None + test_requires: list[str] test_extras: str build_verbosity: int build_frontend: BuildFrontend @@ -103,7 +94,7 @@ class BuildOptions: return self.globals.test_selector @property - def architectures(self) -> Set[Architecture]: + def architectures(self) -> set[Architecture]: return self.globals.architectures @@ -113,7 +104,7 @@ Setting = Union[Dict[str, str], List[str], str, int] @dataclass(frozen=True) class Override: select_pattern: str - options: Dict[str, Setting] + options: dict[str, Setting] MANYLINUX_OPTIONS = {f"manylinux-{build_platform}-image" for build_platform in MANYLINUX_ARCHS} @@ -134,7 +125,7 @@ class ConfigOptionError(KeyError): pass -def _dig_first(*pairs: Tuple[Mapping[str, Setting], str], ignore_empty: bool = False) -> Setting: +def _dig_first(*pairs: tuple[Mapping[str, Setting], str], ignore_empty: bool = False) -> Setting: """ Return the first dict item that matches from pairs of dicts and keys. Will throw a KeyError if missing. @@ -176,10 +167,10 @@ class OptionsReader: def __init__( self, - config_file_path: Optional[Path] = None, + config_file_path: Path | None = None, *, platform: PlatformName, - disallow: Optional[Dict[str, Set[str]]] = None, + disallow: dict[str, set[str]] | None = None, ) -> None: self.platform = platform self.disallow = disallow or {} @@ -189,8 +180,8 @@ class OptionsReader: self.default_options, self.default_platform_options = self._load_file(defaults_path) # Load the project config file - config_options: Dict[str, Any] = {} - config_platform_options: Dict[str, Any] = {} + config_options: dict[str, Any] = {} + config_platform_options: dict[str, Any] = {} if config_file_path is not None: config_options, config_platform_options = self._load_file(config_file_path) @@ -209,8 +200,8 @@ class OptionsReader: self.config_options = config_options self.config_platform_options = config_platform_options - self.overrides: List[Override] = [] - self.current_identifier: Optional[str] = None + self.overrides: list[Override] = [] + self.current_identifier: str | None = None config_overrides = self.config_options.get("overrides") @@ -251,7 +242,7 @@ class OptionsReader: return name in allowed_option_names - def _load_file(self, filename: Path) -> Tuple[Dict[str, Any], Dict[str, Any]]: + def _load_file(self, filename: Path) -> tuple[dict[str, Any], dict[str, Any]]: """ Load a toml file, returns global and platform as separate dicts. """ @@ -264,7 +255,7 @@ class OptionsReader: return global_options, platform_options @property - def active_config_overrides(self) -> List[Override]: + def active_config_overrides(self) -> list[Override]: if self.current_identifier is None: return [] return [ @@ -272,7 +263,7 @@ class OptionsReader: ] @contextmanager - def identifier(self, identifier: Optional[str]) -> Generator[None, None, None]: + def identifier(self, identifier: str | None) -> Generator[None, None, None]: self.current_identifier = identifier try: yield @@ -284,8 +275,8 @@ class OptionsReader: name: str, *, env_plat: bool = True, - sep: Optional[str] = None, - table: Optional[TableFmt] = None, + sep: str | None = None, + table: TableFmt | None = None, ignore_empty: bool = False, ) -> str: """ @@ -349,7 +340,7 @@ class Options: ) @property - def config_file_path(self) -> Optional[Path]: + def config_file_path(self) -> Path | None: args = self.command_line_arguments if args.config_file: @@ -363,7 +354,7 @@ class Options: return None @cached_property - def package_requires_python_str(self) -> Optional[str]: + def package_requires_python_str(self) -> str | None: args = self.command_line_arguments return get_requires_python_str(Path(args.package_dir)) @@ -383,7 +374,7 @@ class Options: # This is not supported in tool.cibuildwheel, as it comes from a standard location. # Passing this in as an environment variable will override pyproject.toml, setup.cfg, or setup.py - requires_python_str: Optional[str] = ( + requires_python_str: str | None = ( os.environ.get("CIBW_PROJECT_REQUIRES_PYTHON") or self.package_requires_python_str ) requires_python = None if requires_python_str is None else SpecifierSet(requires_python_str) @@ -417,7 +408,7 @@ class Options: container_engine=container_engine, ) - def build_options(self, identifier: Optional[str]) -> BuildOptions: + def build_options(self, identifier: str | None) -> BuildOptions: """ Compute BuildOptions for a single run configuration. """ @@ -469,9 +460,9 @@ class Options: pass if dependency_versions == "pinned": - dependency_constraints: Optional[ + dependency_constraints: None | ( DependencyConstraints - ] = DependencyConstraints.with_defaults() + ) = DependencyConstraints.with_defaults() elif dependency_versions == "latest": dependency_constraints = None else: @@ -486,8 +477,8 @@ class Options: except ValueError: build_verbosity = 0 - manylinux_images: Dict[str, str] = {} - musllinux_images: Dict[str, str] = {} + manylinux_images: dict[str, str] = {} + musllinux_images: dict[str, str] = {} if self.platform == "linux": all_pinned_container_images = _get_pinned_container_images() @@ -539,7 +530,7 @@ class Options: build_frontend=build_frontend, ) - def check_for_invalid_configuration(self, identifiers: List[str]) -> None: + def check_for_invalid_configuration(self, identifiers: list[str]) -> None: if self.platform in ["macos", "windows"]: before_all_values = {self.build_options(i).before_all for i in identifiers} @@ -562,7 +553,7 @@ class Options: deprecated_selectors("CIBW_SKIP", build_selector.skip_config) deprecated_selectors("CIBW_TEST_SKIP", test_selector.skip_config) - def summary(self, identifiers: List[str]) -> str: + def summary(self, identifiers: list[str]) -> str: lines = [ f"{option_name}: {option_value!r}" for option_name, option_value in sorted(asdict(self.globals).items()) diff --git a/cibuildwheel/projectfiles.py b/cibuildwheel/projectfiles.py index 90d388f6..b5c3cbdf 100644 --- a/cibuildwheel/projectfiles.py +++ b/cibuildwheel/projectfiles.py @@ -1,8 +1,10 @@ +from __future__ import annotations + import ast import sys from configparser import ConfigParser from pathlib import Path -from typing import Any, Optional +from typing import Any if sys.version_info >= (3, 11): import tomllib @@ -24,7 +26,7 @@ else: class Analyzer(ast.NodeVisitor): def __init__(self) -> None: - self.requires_python: Optional[str] = None + self.requires_python: str | None = None def visit(self, node: ast.AST) -> None: for inner_node in ast.walk(node): @@ -43,7 +45,7 @@ class Analyzer(ast.NodeVisitor): self.requires_python = get_constant(node.value) -def setup_py_python_requires(content: str) -> Optional[str]: +def setup_py_python_requires(content: str) -> str | None: try: tree = ast.parse(content) analyzer = Analyzer() @@ -53,7 +55,7 @@ def setup_py_python_requires(content: str) -> Optional[str]: return None -def get_requires_python_str(package_dir: Path) -> Optional[str]: +def get_requires_python_str(package_dir: Path) -> str | None: """Return the python requires string from the most canonical source available, or None""" # Read in from pyproject.toml:project.requires-python diff --git a/cibuildwheel/typing.py b/cibuildwheel/typing.py index 1e6e5787..a546d7bf 100644 --- a/cibuildwheel/typing.py +++ b/cibuildwheel/typing.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os import subprocess import sys @@ -36,7 +38,7 @@ else: PlatformName = Literal["linux", "macos", "windows"] -PLATFORMS: Final[Set[PlatformName]] = {"linux", "macos", "windows"} +PLATFORMS: Final[set[PlatformName]] = {"linux", "macos", "windows"} def assert_never(value: NoReturn) -> NoReturn: diff --git a/cibuildwheel/util.py b/cibuildwheel/util.py index d2287a05..6a6a6e2a 100644 --- a/cibuildwheel/util.py +++ b/cibuildwheel/util.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import contextlib import fnmatch import itertools @@ -18,15 +20,11 @@ from time import sleep from typing import ( Any, ClassVar, - Dict, Generator, Iterable, - List, - Optional, Sequence, TextIO, TypeVar, - Union, cast, overload, ) @@ -98,8 +96,8 @@ IS_WIN: Final = sys.platform.startswith("win") @overload def call( *args: PathOrStr, - env: Optional[Dict[str, str]] = None, - cwd: Optional[PathOrStr] = None, + env: dict[str, str] | None = None, + cwd: PathOrStr | None = None, capture_stdout: Literal[False] = ..., ) -> None: ... @@ -108,8 +106,8 @@ def call( @overload def call( *args: PathOrStr, - env: Optional[Dict[str, str]] = None, - cwd: Optional[PathOrStr] = None, + env: dict[str, str] | None = None, + cwd: PathOrStr | None = None, capture_stdout: Literal[True], ) -> str: ... @@ -117,10 +115,10 @@ def call( def call( *args: PathOrStr, - env: Optional[Dict[str, str]] = None, - cwd: Optional[PathOrStr] = None, + env: dict[str, str] | None = None, + cwd: PathOrStr | None = None, capture_stdout: bool = False, -) -> Optional[str]: +) -> str | None: """ Run subprocess.run, but print the commands first. Takes the commands as *args. Uses shell=True on Windows due to a bug. Also converts to @@ -130,7 +128,7 @@ def call( args_ = [str(arg) for arg in args] # print the command executing for the logs print("+ " + " ".join(shlex.quote(a) for a in args_)) - kwargs: Dict[str, Any] = {} + kwargs: dict[str, Any] = {} if capture_stdout: kwargs["universal_newlines"] = True kwargs["stdout"] = subprocess.PIPE @@ -140,9 +138,7 @@ def call( return cast(str, result.stdout) -def shell( - *commands: str, env: Optional[Dict[str, str]] = None, cwd: Optional[PathOrStr] = None -) -> None: +def shell(*commands: str, env: dict[str, str] | None = None, cwd: PathOrStr | None = None) -> None: command = " ".join(commands) print(f"+ {command}") subprocess.run(command, env=env, cwd=cwd, shell=True, check=True) @@ -200,7 +196,7 @@ def prepare_command(command: str, **kwargs: PathOrStr) -> str: return format_safe(command, python="python", pip="pip", **kwargs) -def get_build_verbosity_extra_flags(level: int) -> List[str]: +def get_build_verbosity_extra_flags(level: int) -> list[str]: if level > 0: return ["-" + level * "v"] elif level < 0: @@ -209,11 +205,11 @@ def get_build_verbosity_extra_flags(level: int) -> List[str]: return [] -def read_python_configs(config: PlatformName) -> List[Dict[str, str]]: +def read_python_configs(config: PlatformName) -> list[dict[str, str]]: input_file = resources_dir / "build-platforms.toml" with input_file.open("rb") as f: loaded_file = tomllib.load(f) - results: List[Dict[str, str]] = list(loaded_file[config]["python_configurations"]) + results: list[dict[str, str]] = list(loaded_file[config]["python_configurations"]) return results @@ -243,7 +239,7 @@ class BuildSelector: build_config: str skip_config: str - requires_python: Optional[SpecifierSet] = None + requires_python: SpecifierSet | None = None # a pattern that skips prerelease versions, when include_prereleases is False. PRERELEASE_SKIP: ClassVar[str] = "cp311-*" @@ -328,7 +324,7 @@ class DependencyConstraints: self.base_file_path = base_file_path.resolve() @staticmethod - def with_defaults() -> "DependencyConstraints": + def with_defaults() -> DependencyConstraints: return DependencyConstraints(base_file_path=resources_dir / "constraints.txt") def get_for_python_version(self, version: str) -> Path: @@ -400,7 +396,7 @@ class CIProvider(Enum): other = "other" -def detect_ci_provider() -> Optional[CIProvider]: +def detect_ci_provider() -> CIProvider | None: if "TRAVIS" in os.environ: return CIProvider.travis_ci elif "APPVEYOR" in os.environ: @@ -473,7 +469,7 @@ def print_new_wheels(msg: str, output_dir: Path) -> Generator[None, None, None]: ) -def get_pip_version(env: Dict[str, str]) -> str: +def get_pip_version(env: dict[str, str]) -> str: versions_output_text = call( "python", "-m", "pip", "freeze", "--all", capture_stdout=True, env=env ) @@ -501,7 +497,7 @@ def _ensure_virtualenv() -> Path: def _parse_constraints_for_virtualenv( dependency_constraint_flags: Sequence[PathOrStr], -) -> Dict[str, str]: +) -> dict[str, str]: """ Parses the constraints file referenced by `dependency_constraint_flags` and returns a dict where the key is the package name, and the value is the constraint version. @@ -547,7 +543,7 @@ def _parse_constraints_for_virtualenv( def virtualenv( python: Path, venv_path: Path, dependency_constraint_flags: Sequence[PathOrStr] -) -> Dict[str, str]: +) -> dict[str, str]: assert python.exists() virtualenv_app = _ensure_virtualenv() constraints = _parse_constraints_for_virtualenv(dependency_constraint_flags) @@ -589,7 +585,7 @@ def virtualenv( T = TypeVar("T", bound=PurePath) -def find_compatible_wheel(wheels: Sequence[T], identifier: str) -> Optional[T]: +def find_compatible_wheel(wheels: Sequence[T], identifier: str) -> T | None: """ Finds a wheel with an abi3 or a none ABI tag in `wheels` compatible with the Python interpreter specified by `identifier` that is previously built. @@ -641,7 +637,7 @@ else: # Can be replaced by contextlib.chdir in Python 3.11 @contextlib.contextmanager -def chdir(new_path: Union[Path, str]) -> Generator[None, None, None]: +def chdir(new_path: Path | str) -> Generator[None, None, None]: """Non thread-safe context manager to change the current working directory.""" cwd = os.getcwd() diff --git a/cibuildwheel/windows.py b/cibuildwheel/windows.py index 82309a23..b6e223ec 100644 --- a/cibuildwheel/windows.py +++ b/cibuildwheel/windows.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os import shutil import subprocess @@ -5,7 +7,7 @@ import sys from dataclasses import dataclass from functools import lru_cache from pathlib import Path -from typing import Dict, List, Optional, Sequence, Set +from typing import Sequence from zipfile import ZipFile from filelock import FileLock @@ -34,7 +36,7 @@ from .util import ( ) -def get_nuget_args(version: str, arch: str, output_directory: Path) -> List[str]: +def get_nuget_args(version: str, arch: str, output_directory: Path) -> list[str]: platform_suffix = {"32": "x86", "64": "", "ARM64": "arm64"} python_name = "python" + platform_suffix[arch] return [ @@ -53,13 +55,13 @@ class PythonConfiguration: version: str arch: str identifier: str - url: Optional[str] = None + url: str | None = None def get_python_configurations( build_selector: BuildSelector, - architectures: Set[Architecture], -) -> List[PythonConfiguration]: + architectures: set[Architecture], +) -> list[PythonConfiguration]: full_python_configs = read_python_configs("windows") @@ -124,7 +126,7 @@ def setup_python( dependency_constraint_flags: Sequence[PathOrStr], environment: ParsedEnvironment, build_frontend: BuildFrontend, -) -> Dict[str, str]: +) -> dict[str, str]: tmp.mkdir() implementation_id = python_configuration.identifier.split("-")[0] log.step(f"Installing Python {implementation_id}...") @@ -253,7 +255,7 @@ def build(options: Options, tmp_path: Path) -> None: ) shell(before_all_prepared, env=env) - built_wheels: List[Path] = [] + built_wheels: list[Path] = [] for config in python_configurations: build_options = options.build_options(config.identifier) diff --git a/docs/main.py b/docs/main.py index b1798237..acb0d49c 100644 --- a/docs/main.py +++ b/docs/main.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import subprocess from typing import Any diff --git a/noxfile.py b/noxfile.py index f045e616..659e7ff5 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os import shutil import sys diff --git a/setup.py b/setup.py index 6c08425d..0cb95028 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from setuptools import setup extras = { diff --git a/test/conftest.py b/test/conftest.py index e7c42112..872eeb17 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -1,4 +1,4 @@ -from typing import Dict +from __future__ import annotations import pytest @@ -13,5 +13,5 @@ def pytest_addoption(parser) -> None: @pytest.fixture( params=[{"CIBW_BUILD_FRONTEND": "pip"}, {"CIBW_BUILD_FRONTEND": "build"}], ids=["pip", "build"] ) -def build_frontend_env(request) -> Dict[str, str]: +def build_frontend_env(request) -> dict[str, str]: return request.param # type: ignore[no-any-return] diff --git a/test/test_0_basic.py b/test/test_0_basic.py index 2d2e8d97..5fb7a241 100644 --- a/test/test_0_basic.py +++ b/test/test_0_basic.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import textwrap import pytest diff --git a/test/test_abi_variants.py b/test/test_abi_variants.py index 932a2ec0..11473655 100644 --- a/test/test_abi_variants.py +++ b/test/test_abi_variants.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import textwrap from . import test_projects, utils diff --git a/test/test_before_all.py b/test/test_before_all.py index 9c8722d7..bad2d4c0 100644 --- a/test/test_before_all.py +++ b/test/test_before_all.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import subprocess import textwrap diff --git a/test/test_before_build.py b/test/test_before_build.py index 00906acc..1ee7757e 100644 --- a/test/test_before_build.py +++ b/test/test_before_build.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import subprocess import textwrap diff --git a/test/test_before_test.py b/test/test_before_test.py index 535131aa..5c3e09d2 100644 --- a/test/test_before_test.py +++ b/test/test_before_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from . import test_projects, utils before_test_project = test_projects.new_c_project() diff --git a/test/test_build_skip.py b/test/test_build_skip.py index 0d285d82..e29d14f1 100644 --- a/test/test_build_skip.py +++ b/test/test_build_skip.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import textwrap from . import test_projects, utils diff --git a/test/test_container_images.py b/test/test_container_images.py index 8318a64e..75b102e3 100644 --- a/test/test_container_images.py +++ b/test/test_container_images.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import platform import textwrap diff --git a/test/test_cpp_standards.py b/test/test_cpp_standards.py index a5385007..f09e7a53 100644 --- a/test/test_cpp_standards.py +++ b/test/test_cpp_standards.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os import jinja2 diff --git a/test/test_dependency_versions.py b/test/test_dependency_versions.py index 90854a86..e1f20632 100644 --- a/test/test_dependency_versions.py +++ b/test/test_dependency_versions.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import re import textwrap diff --git a/test/test_emulation.py b/test/test_emulation.py index 95b574dd..6b29c019 100644 --- a/test/test_emulation.py +++ b/test/test_emulation.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import subprocess import pytest diff --git a/test/test_environment.py b/test/test_environment.py index 6ad8ff9f..4382df44 100644 --- a/test/test_environment.py +++ b/test/test_environment.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os import subprocess import textwrap diff --git a/test/test_from_sdist.py b/test/test_from_sdist.py index d1d4ff11..f0b7e93e 100644 --- a/test/test_from_sdist.py +++ b/test/test_from_sdist.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os import subprocess import sys diff --git a/test/test_macos_archs.py b/test/test_macos_archs.py index a85a6b24..d3a56fb7 100644 --- a/test/test_macos_archs.py +++ b/test/test_macos_archs.py @@ -1,6 +1,7 @@ +from __future__ import annotations + import platform import subprocess -from typing import Tuple import pytest @@ -14,7 +15,7 @@ ALL_MACOS_WHEELS = { } -def get_xcode_version() -> Tuple[int, int]: +def get_xcode_version() -> tuple[int, int]: output = subprocess.run( ["xcodebuild", "-version"], text=True, diff --git a/test/test_manylinuxXXXX_only.py b/test/test_manylinuxXXXX_only.py index 935aa592..6013e856 100644 --- a/test/test_manylinuxXXXX_only.py +++ b/test/test_manylinuxXXXX_only.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import platform import textwrap diff --git a/test/test_pep518.py b/test/test_pep518.py index 12883428..0f1bc0c5 100644 --- a/test/test_pep518.py +++ b/test/test_pep518.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import textwrap from . import test_projects, utils diff --git a/test/test_podman.py b/test/test_podman.py index dd07572b..ea3bd8a6 100644 --- a/test/test_podman.py +++ b/test/test_podman.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest from . import test_projects, utils diff --git a/test/test_projects/__init__.py b/test/test_projects/__init__.py index d6bed818..2d8da665 100644 --- a/test/test_projects/__init__.py +++ b/test/test_projects/__init__.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from .base import TestProject from .c import new_c_project diff --git a/test/test_projects/__main__.py b/test/test_projects/__main__.py index a1e77c43..0d3cf252 100644 --- a/test/test_projects/__main__.py +++ b/test/test_projects/__main__.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import importlib import subprocess import sys diff --git a/test/test_projects/base.py b/test/test_projects/base.py index 66d0006e..c4ea5403 100644 --- a/test/test_projects/base.py +++ b/test/test_projects/base.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from pathlib import Path from typing import Any, Dict, Union diff --git a/test/test_projects/c.py b/test/test_projects/c.py index d4c37c69..62252a62 100644 --- a/test/test_projects/c.py +++ b/test/test_projects/c.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import jinja2 from .base import TestProject diff --git a/test/test_pure_wheel.py b/test/test_pure_wheel.py index 2ba33711..f7a4807b 100644 --- a/test/test_pure_wheel.py +++ b/test/test_pure_wheel.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import subprocess from test import test_projects diff --git a/test/test_same_wheel.py b/test/test_same_wheel.py index d89f28cb..f25cba5d 100644 --- a/test/test_same_wheel.py +++ b/test/test_same_wheel.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import subprocess from test import test_projects diff --git a/test/test_ssl.py b/test/test_ssl.py index 5283a59d..9c35650e 100644 --- a/test/test_ssl.py +++ b/test/test_ssl.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import textwrap from . import test_projects, utils diff --git a/test/test_subdir_package.py b/test/test_subdir_package.py index 9241ae30..c1d73df1 100644 --- a/test/test_subdir_package.py +++ b/test/test_subdir_package.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from pathlib import Path import jinja2 diff --git a/test/test_testing.py b/test/test_testing.py index ef41f35a..c7264383 100644 --- a/test/test_testing.py +++ b/test/test_testing.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os import subprocess import textwrap diff --git a/test/test_troubleshooting.py b/test/test_troubleshooting.py index 7039c268..e647bca6 100644 --- a/test/test_troubleshooting.py +++ b/test/test_troubleshooting.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import subprocess import pytest diff --git a/test/test_wheel_tag.py b/test/test_wheel_tag.py index a026b2d7..786eaa7a 100644 --- a/test/test_wheel_tag.py +++ b/test/test_wheel_tag.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest from . import test_projects, utils diff --git a/test/utils.py b/test/utils.py index ebe682e3..947c8968 100644 --- a/test/utils.py +++ b/test/utils.py @@ -4,6 +4,8 @@ Utility functions used by the cibuildwheel tests. This file is added to the PYTHONPATH in the test runner at bin/run_test.py. """ +from __future__ import annotations + import os import platform as pm import subprocess diff --git a/unit_test/build_ids_test.py b/unit_test/build_ids_test.py index 60ac3874..0f62ba40 100644 --- a/unit_test/build_ids_test.py +++ b/unit_test/build_ids_test.py @@ -1,5 +1,6 @@ +from __future__ import annotations + import sys -from typing import Dict, List if sys.version_info >= (3, 11): import tomllib @@ -27,7 +28,7 @@ def test_compare_configs(): def test_dump_with_Version(): # MyPy doesn't understand deeply nested dicts correctly - example: Dict[str, Dict[str, List[Dict[str, Printable]]]] = { + example: dict[str, dict[str, list[dict[str, Printable]]]] = { "windows": { "python_configurations": [ {"identifier": "cp27-win32", "version": Version("2.7.18"), "arch": "32"}, diff --git a/unit_test/build_selector_test.py b/unit_test/build_selector_test.py index b71cb05f..14ff8da6 100644 --- a/unit_test/build_selector_test.py +++ b/unit_test/build_selector_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from packaging.specifiers import SpecifierSet from cibuildwheel.util import BuildSelector diff --git a/unit_test/conftest.py b/unit_test/conftest.py index 3d98c30b..7e1df1b2 100644 --- a/unit_test/conftest.py +++ b/unit_test/conftest.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import sys from pathlib import Path diff --git a/unit_test/dependency_constraints_test.py b/unit_test/dependency_constraints_test.py index 95215195..ce907d5e 100644 --- a/unit_test/dependency_constraints_test.py +++ b/unit_test/dependency_constraints_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from pathlib import Path from cibuildwheel.util import DependencyConstraints diff --git a/unit_test/download_test.py b/unit_test/download_test.py index 0aac1430..efc5c4e5 100644 --- a/unit_test/download_test.py +++ b/unit_test/download_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import ssl import certifi diff --git a/unit_test/environment_test.py b/unit_test/environment_test.py index c1d0a4a1..38678771 100644 --- a/unit_test/environment_test.py +++ b/unit_test/environment_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os from cibuildwheel.environment import parse_environment diff --git a/unit_test/linux_build_steps_test.py b/unit_test/linux_build_steps_test.py index 36aaebb7..809cdf65 100644 --- a/unit_test/linux_build_steps_test.py +++ b/unit_test/linux_build_steps_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import textwrap from pathlib import Path from pprint import pprint diff --git a/unit_test/main_tests/conftest.py b/unit_test/main_tests/conftest.py index 973012cf..25732187 100644 --- a/unit_test/main_tests/conftest.py +++ b/unit_test/main_tests/conftest.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import contextlib import platform as platform_module import subprocess diff --git a/unit_test/main_tests/main_options_test.py b/unit_test/main_tests/main_options_test.py index 59368de5..813fd5c5 100644 --- a/unit_test/main_tests/main_options_test.py +++ b/unit_test/main_tests/main_options_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import sys from fnmatch import fnmatch from pathlib import Path diff --git a/unit_test/main_tests/main_platform_test.py b/unit_test/main_tests/main_platform_test.py index 8974a27e..61dd8e85 100644 --- a/unit_test/main_tests/main_platform_test.py +++ b/unit_test/main_tests/main_platform_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import sys import pytest diff --git a/unit_test/main_tests/main_requires_python_test.py b/unit_test/main_tests/main_requires_python_test.py index 0edb0937..e513f743 100644 --- a/unit_test/main_tests/main_requires_python_test.py +++ b/unit_test/main_tests/main_requires_python_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import sys import textwrap diff --git a/unit_test/oci_container_test.py b/unit_test/oci_container_test.py index 05ef24fd..30739db7 100644 --- a/unit_test/oci_container_test.py +++ b/unit_test/oci_container_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os import platform import random diff --git a/unit_test/option_prepare_test.py b/unit_test/option_prepare_test.py index 3eef68a7..bc01317b 100644 --- a/unit_test/option_prepare_test.py +++ b/unit_test/option_prepare_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import platform as platform_module import subprocess import sys diff --git a/unit_test/options_test.py b/unit_test/options_test.py index 3ce8b214..a609bb49 100644 --- a/unit_test/options_test.py +++ b/unit_test/options_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import platform as platform_module import pytest diff --git a/unit_test/options_toml_test.py b/unit_test/options_toml_test.py index 1dcfdc21..a3fab2cc 100644 --- a/unit_test/options_toml_test.py +++ b/unit_test/options_toml_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from pathlib import Path import pytest diff --git a/unit_test/projectfiles_test.py b/unit_test/projectfiles_test.py index 6c55d46a..e7e21ba5 100644 --- a/unit_test/projectfiles_test.py +++ b/unit_test/projectfiles_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from textwrap import dedent from cibuildwheel.projectfiles import get_requires_python_str, setup_py_python_requires diff --git a/unit_test/utils.py b/unit_test/utils.py index 2b312eca..0cd2fefb 100644 --- a/unit_test/utils.py +++ b/unit_test/utils.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from pathlib import Path from cibuildwheel.options import CommandLineArguments diff --git a/unit_test/utils_test.py b/unit_test/utils_test.py index 7f949a73..adf21435 100644 --- a/unit_test/utils_test.py +++ b/unit_test/utils_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from pathlib import PurePath import pytest diff --git a/unit_test/wheel_print_test.py b/unit_test/wheel_print_test.py index 02060060..fe68f718 100644 --- a/unit_test/wheel_print_test.py +++ b/unit_test/wheel_print_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest from cibuildwheel.util import print_new_wheels From 8575b35cc27c0c0f685d6292a628ede312d3fa00 Mon Sep 17 00:00:00 2001 From: Hadi Alqattan Date: Tue, 19 Jul 2022 13:05:33 +0300 Subject: [PATCH 78/86] Upgrading Pycln from v2.0.3 to v2.0.4 Pycln v2.0.3 has some issues with Py3.9+. --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fdd22536..8437bbb1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -27,7 +27,7 @@ repos: # Autoremoves unused imports - repo: https://github.com/hadialqattan/pycln - rev: v2.0.3 + rev: v2.0.4 hooks: - id: pycln args: [--all] From fc15836c636a92caf57bbe6fe87de1f49911576e Mon Sep 17 00:00:00 2001 From: "cibuildwheel-bot[bot]" <83877280+cibuildwheel-bot[bot]@users.noreply.github.com> Date: Mon, 25 Jul 2022 06:15:53 +0000 Subject: [PATCH 79/86] Update dependencies --- .../resources/constraints-python310.txt | 2 +- .../resources/constraints-python311.txt | 2 +- .../resources/constraints-python37.txt | 2 +- .../resources/constraints-python38.txt | 2 +- .../resources/constraints-python39.txt | 2 +- cibuildwheel/resources/constraints.txt | 2 +- .../resources/pinned_docker_images.cfg | 60 ++--- docs/working-examples.md | 212 +++++++++--------- 8 files changed, 142 insertions(+), 142 deletions(-) diff --git a/cibuildwheel/resources/constraints-python310.txt b/cibuildwheel/resources/constraints-python310.txt index 1b4a6b31..f3d3b7f9 100644 --- a/cibuildwheel/resources/constraints-python310.txt +++ b/cibuildwheel/resources/constraints-python310.txt @@ -24,7 +24,7 @@ wheel==0.37.1 # delocate # The following packages are considered to be unsafe in a requirements file: -pip==22.1.2 +pip==22.2 # via -r cibuildwheel/resources/constraints.in setuptools==63.2.0 # via -r cibuildwheel/resources/constraints.in diff --git a/cibuildwheel/resources/constraints-python311.txt b/cibuildwheel/resources/constraints-python311.txt index 93901adb..849abf49 100644 --- a/cibuildwheel/resources/constraints-python311.txt +++ b/cibuildwheel/resources/constraints-python311.txt @@ -24,7 +24,7 @@ wheel==0.37.1 # delocate # The following packages are considered to be unsafe in a requirements file: -pip==22.1.2 +pip==22.2 # via -r cibuildwheel/resources/constraints.in setuptools==63.2.0 # via -r cibuildwheel/resources/constraints.in diff --git a/cibuildwheel/resources/constraints-python37.txt b/cibuildwheel/resources/constraints-python37.txt index f5a8ac31..78ea26b2 100644 --- a/cibuildwheel/resources/constraints-python37.txt +++ b/cibuildwheel/resources/constraints-python37.txt @@ -30,7 +30,7 @@ zipp==3.8.1 # via importlib-metadata # The following packages are considered to be unsafe in a requirements file: -pip==22.1.2 +pip==22.2 # via -r cibuildwheel/resources/constraints.in setuptools==63.2.0 # via -r cibuildwheel/resources/constraints.in diff --git a/cibuildwheel/resources/constraints-python38.txt b/cibuildwheel/resources/constraints-python38.txt index c13a47fa..aa06de6e 100644 --- a/cibuildwheel/resources/constraints-python38.txt +++ b/cibuildwheel/resources/constraints-python38.txt @@ -24,7 +24,7 @@ wheel==0.37.1 # delocate # The following packages are considered to be unsafe in a requirements file: -pip==22.1.2 +pip==22.2 # via -r cibuildwheel/resources/constraints.in setuptools==63.2.0 # via -r cibuildwheel/resources/constraints.in diff --git a/cibuildwheel/resources/constraints-python39.txt b/cibuildwheel/resources/constraints-python39.txt index f5f35ff1..0aed606e 100644 --- a/cibuildwheel/resources/constraints-python39.txt +++ b/cibuildwheel/resources/constraints-python39.txt @@ -24,7 +24,7 @@ wheel==0.37.1 # delocate # The following packages are considered to be unsafe in a requirements file: -pip==22.1.2 +pip==22.2 # via -r cibuildwheel/resources/constraints.in setuptools==63.2.0 # via -r cibuildwheel/resources/constraints.in diff --git a/cibuildwheel/resources/constraints.txt b/cibuildwheel/resources/constraints.txt index f5f35ff1..0aed606e 100644 --- a/cibuildwheel/resources/constraints.txt +++ b/cibuildwheel/resources/constraints.txt @@ -24,7 +24,7 @@ wheel==0.37.1 # delocate # The following packages are considered to be unsafe in a requirements file: -pip==22.1.2 +pip==22.2 # via -r cibuildwheel/resources/constraints.in setuptools==63.2.0 # via -r cibuildwheel/resources/constraints.in diff --git a/cibuildwheel/resources/pinned_docker_images.cfg b/cibuildwheel/resources/pinned_docker_images.cfg index 4c829bd6..1fe4bf41 100644 --- a/cibuildwheel/resources/pinned_docker_images.cfg +++ b/cibuildwheel/resources/pinned_docker_images.cfg @@ -1,48 +1,48 @@ [x86_64] manylinux1 = quay.io/pypa/manylinux1_x86_64:2022-07-17-f8ddacc -manylinux2010 = quay.io/pypa/manylinux2010_x86_64:2022-07-17-51324db -manylinux2014 = quay.io/pypa/manylinux2014_x86_64:2022-07-17-51324db -manylinux_2_24 = quay.io/pypa/manylinux_2_24_x86_64:2022-07-17-51324db -manylinux_2_28 = quay.io/pypa/manylinux_2_28_x86_64:2022-07-17-51324db -musllinux_1_1 = quay.io/pypa/musllinux_1_1_x86_64:2022-07-17-51324db +manylinux2010 = quay.io/pypa/manylinux2010_x86_64:2022-07-21-947f13c +manylinux2014 = quay.io/pypa/manylinux2014_x86_64:2022-07-21-947f13c +manylinux_2_24 = quay.io/pypa/manylinux_2_24_x86_64:2022-07-21-947f13c +manylinux_2_28 = quay.io/pypa/manylinux_2_28_x86_64:2022-07-21-947f13c +musllinux_1_1 = quay.io/pypa/musllinux_1_1_x86_64:2022-07-21-947f13c [i686] manylinux1 = quay.io/pypa/manylinux1_i686:2022-07-17-f8ddacc -manylinux2010 = quay.io/pypa/manylinux2010_i686:2022-07-17-51324db -manylinux2014 = quay.io/pypa/manylinux2014_i686:2022-07-17-51324db -manylinux_2_24 = quay.io/pypa/manylinux_2_24_i686:2022-07-17-51324db -musllinux_1_1 = quay.io/pypa/musllinux_1_1_i686:2022-07-17-51324db +manylinux2010 = quay.io/pypa/manylinux2010_i686:2022-07-21-947f13c +manylinux2014 = quay.io/pypa/manylinux2014_i686:2022-07-21-947f13c +manylinux_2_24 = quay.io/pypa/manylinux_2_24_i686:2022-07-21-947f13c +musllinux_1_1 = quay.io/pypa/musllinux_1_1_i686:2022-07-21-947f13c [pypy_x86_64] -manylinux2010 = quay.io/pypa/manylinux2010_x86_64:2022-07-17-51324db -manylinux2014 = quay.io/pypa/manylinux2014_x86_64:2022-07-17-51324db -manylinux_2_24 = quay.io/pypa/manylinux_2_24_x86_64:2022-07-17-51324db -manylinux_2_28 = quay.io/pypa/manylinux_2_28_x86_64:2022-07-17-51324db +manylinux2010 = quay.io/pypa/manylinux2010_x86_64:2022-07-21-947f13c +manylinux2014 = quay.io/pypa/manylinux2014_x86_64:2022-07-21-947f13c +manylinux_2_24 = quay.io/pypa/manylinux_2_24_x86_64:2022-07-21-947f13c +manylinux_2_28 = quay.io/pypa/manylinux_2_28_x86_64:2022-07-21-947f13c [pypy_i686] -manylinux2010 = quay.io/pypa/manylinux2010_i686:2022-07-17-51324db -manylinux2014 = quay.io/pypa/manylinux2014_i686:2022-07-17-51324db -manylinux_2_24 = quay.io/pypa/manylinux_2_24_i686:2022-07-17-51324db +manylinux2010 = quay.io/pypa/manylinux2010_i686:2022-07-21-947f13c +manylinux2014 = quay.io/pypa/manylinux2014_i686:2022-07-21-947f13c +manylinux_2_24 = quay.io/pypa/manylinux_2_24_i686:2022-07-21-947f13c [aarch64] -manylinux2014 = quay.io/pypa/manylinux2014_aarch64:2022-07-17-51324db -manylinux_2_24 = quay.io/pypa/manylinux_2_24_aarch64:2022-07-17-51324db -manylinux_2_28 = quay.io/pypa/manylinux_2_28_aarch64:2022-07-17-51324db -musllinux_1_1 = quay.io/pypa/musllinux_1_1_aarch64:2022-07-17-51324db +manylinux2014 = quay.io/pypa/manylinux2014_aarch64:2022-07-21-947f13c +manylinux_2_24 = quay.io/pypa/manylinux_2_24_aarch64:2022-07-21-947f13c +manylinux_2_28 = quay.io/pypa/manylinux_2_28_aarch64:2022-07-21-947f13c +musllinux_1_1 = quay.io/pypa/musllinux_1_1_aarch64:2022-07-21-947f13c [ppc64le] -manylinux2014 = quay.io/pypa/manylinux2014_ppc64le:2022-07-17-51324db -manylinux_2_24 = quay.io/pypa/manylinux_2_24_ppc64le:2022-07-17-51324db -manylinux_2_28 = quay.io/pypa/manylinux_2_28_ppc64le:2022-07-17-51324db -musllinux_1_1 = quay.io/pypa/musllinux_1_1_ppc64le:2022-07-17-51324db +manylinux2014 = quay.io/pypa/manylinux2014_ppc64le:2022-07-21-947f13c +manylinux_2_24 = quay.io/pypa/manylinux_2_24_ppc64le:2022-07-21-947f13c +manylinux_2_28 = quay.io/pypa/manylinux_2_28_ppc64le:2022-07-21-947f13c +musllinux_1_1 = quay.io/pypa/musllinux_1_1_ppc64le:2022-07-21-947f13c [s390x] -manylinux2014 = quay.io/pypa/manylinux2014_s390x:2022-07-17-51324db -manylinux_2_24 = quay.io/pypa/manylinux_2_24_s390x:2022-07-17-51324db -musllinux_1_1 = quay.io/pypa/musllinux_1_1_s390x:2022-07-17-51324db +manylinux2014 = quay.io/pypa/manylinux2014_s390x:2022-07-21-947f13c +manylinux_2_24 = quay.io/pypa/manylinux_2_24_s390x:2022-07-21-947f13c +musllinux_1_1 = quay.io/pypa/musllinux_1_1_s390x:2022-07-21-947f13c [pypy_aarch64] -manylinux2014 = quay.io/pypa/manylinux2014_aarch64:2022-07-17-51324db -manylinux_2_24 = quay.io/pypa/manylinux_2_24_aarch64:2022-07-17-51324db -manylinux_2_28 = quay.io/pypa/manylinux_2_28_aarch64:2022-07-17-51324db +manylinux2014 = quay.io/pypa/manylinux2014_aarch64:2022-07-21-947f13c +manylinux_2_24 = quay.io/pypa/manylinux_2_24_aarch64:2022-07-21-947f13c +manylinux_2_28 = quay.io/pypa/manylinux_2_28_aarch64:2022-07-21-947f13c diff --git a/docs/working-examples.md b/docs/working-examples.md index 328d1dbb..63b34bb8 100644 --- a/docs/working-examples.md +++ b/docs/working-examples.md @@ -24,10 +24,10 @@ title: Working examples | [vaex][] | ![github icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | Out-of-Core hybrid Apache Arrow/NumPy DataFrame for Python, ML, visualization and exploration of big tabular data at a billion rows per second 🚀 | | [Google Benchmark][] | ![github icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | A microbenchmark support library | | [Apache Beam][] | ![github icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | Apache Beam is a unified programming model for Batch and Streaming data processing. | -| [asyncpg][] | ![github icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | A fast PostgreSQL Database Client Library for Python/asyncio. | | [duckdb][] | ![github icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | DuckDB is an in-process SQL OLAP Database Management System | -| [scikit-image][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Image processing library. Uses cibuildwheel to build and test a project that uses Cython with platform-native code. | +| [asyncpg][] | ![github icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | A fast PostgreSQL Database Client Library for Python/asyncio. | | [PyGame][] | ![github icon][] | ![apple icon][] ![linux icon][] | pygame (the library) is a Free and Open Source python programming language library for making multimedia applications like games built on top of the excellent SDL library. C, Python, Native, OpenGL. | +| [scikit-image][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Image processing library. Uses cibuildwheel to build and test a project that uses Cython with platform-native code. | | [cmake][] | ![github icon][] ![travisci icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | Multitagged binary builds for all supported platforms, using cibw 2 config configuration. | | [twisted-iocpsupport][] | ![github icon][] | ![windows icon][] | A submodule of Twisted that hooks into native C APIs using Cython. | | [websockets][] | ![travisci icon][] | ![apple icon][] ![linux icon][] | Library for building WebSocket servers and clients. Mostly written in Python, with a small C 'speedups' extension module. | @@ -57,8 +57,8 @@ title: Working examples | [Line Profiler][] | ![github icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | Line-by-line profiling for Python | | [PyTables][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | A Python package to manage extremely large amounts of data | | [OpenTimelineIO][] | ![github icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | Open Source API and interchange format for editorial timeline information. | -| [ruptures][] | ![github icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | Extensive Cython + NumPy [pyproject.toml](https://github.com/deepcharles/ruptures/blob/master/pyproject.toml) example. | | [aioquic][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | QUIC and HTTP/3 implementation in Python | +| [ruptures][] | ![github icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | Extensive Cython + NumPy [pyproject.toml](https://github.com/deepcharles/ruptures/blob/master/pyproject.toml) example. | | [DeepForest][] | ![github icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | An Efficient, Scalable and Optimized Python Framework for Deep Forest (2021.2.1) | | [google neuroglancer][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | WebGL-based viewer for volumetric data | | [Psycopg 3][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | A modern implementation of a PostgreSQL adapter for Python | @@ -105,8 +105,8 @@ title: Working examples | [ninja][] | ![github icon][] ![travisci icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | Multitagged binary builds for all supported platforms, using cibw 2 config configuration. | | [GSD][] | ![github icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | Cython and NumPy project with 64-bit wheels. | | [pyinstrument_cext][] | ![travisci icon][] ![appveyor icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | A simple C extension, without external dependencies | -| [xmlstarlet][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Python 3.6+ CFFI bindings with true MSVC build. | | [CorrectionLib][] | ![github icon][] | ![apple icon][] ![linux icon][] | Structured JSON powered correction library for HEP, designed for the CMS experiment at CERN. | +| [xmlstarlet][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Python 3.6+ CFFI bindings with true MSVC build. | | [SiPM][] | ![github icon][] | ![apple icon][] ![linux icon][] | High performance library for SiPM detectors simulation using C++17, OpenMP and AVX2 intrinsics. | [scikit-learn]: https://github.com/scikit-learn/scikit-learn @@ -125,10 +125,10 @@ title: Working examples [vaex]: https://github.com/vaexio/vaex [Google Benchmark]: https://github.com/google/benchmark [Apache Beam]: https://github.com/apache/beam -[asyncpg]: https://github.com/MagicStack/asyncpg [duckdb]: https://github.com/duckdb/duckdb -[scikit-image]: https://github.com/scikit-image/scikit-image +[asyncpg]: https://github.com/MagicStack/asyncpg [PyGame]: https://github.com/pygame/pygame +[scikit-image]: https://github.com/scikit-image/scikit-image [cmake]: https://github.com/scikit-build/cmake-python-distributions [twisted-iocpsupport]: https://github.com/twisted/twisted-iocpsupport [websockets]: https://github.com/aaugustin/websockets @@ -158,8 +158,8 @@ title: Working examples [Line Profiler]: https://github.com/pyutils/line_profiler [PyTables]: https://github.com/PyTables/PyTables [OpenTimelineIO]: https://github.com/PixarAnimationStudios/OpenTimelineIO -[ruptures]: https://github.com/deepcharles/ruptures [aioquic]: https://github.com/aiortc/aioquic +[ruptures]: https://github.com/deepcharles/ruptures [DeepForest]: https://github.com/LAMDA-NJU/Deep-Forest [google neuroglancer]: https://github.com/google/neuroglancer [Psycopg 3]: https://github.com/psycopg/psycopg @@ -206,8 +206,8 @@ title: Working examples [ninja]: https://github.com/scikit-build/ninja-python-distributions [GSD]: https://github.com/glotzerlab/gsd [pyinstrument_cext]: https://github.com/joerick/pyinstrument_cext -[xmlstarlet]: https://github.com/dimitern/xmlstarlet [CorrectionLib]: https://github.com/cms-nanoAOD/correctionlib +[xmlstarlet]: https://github.com/dimitern/xmlstarlet [SiPM]: https://github.com/EdoPro98/SimSiPM [appveyor icon]: data/readme_icons/appveyor.svg @@ -220,106 +220,106 @@ title: Working examples [apple icon]: data/readme_icons/apple.svg [linux icon]: data/readme_icons/linux.svg - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + From aa4ca4268384a02c0b5581effaab86b8a29d1ff9 Mon Sep 17 00:00:00 2001 From: jack1142 <6032823+jack1142@users.noreply.github.com> Date: Mon, 25 Jul 2022 16:15:00 +0200 Subject: [PATCH 80/86] Fix Rosetta2 usage for shell commands --- cibuildwheel/macos.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index beb4d32e..d6b5b982 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -505,7 +505,7 @@ def build(options: Options, tmp_path: Path) -> None: # define a custom 'call' function that adds the arch prefix each time call_with_arch = functools.partial(call, *arch_prefix) - shell_with_arch = functools.partial(shell, *arch_prefix) + shell_with_arch = functools.partial(call, *arch_prefix, "/bin/sh", "-c") # Use --no-download to ensure determinism by using seed libraries # built into virtualenv From 1a7abe562b51163c0b8d1d6901ab25da52550483 Mon Sep 17 00:00:00 2001 From: jack1142 <6032823+jack1142@users.noreply.github.com> Date: Mon, 25 Jul 2022 17:01:22 +0200 Subject: [PATCH 81/86] Remove dependency on Unix tools in Windows --- test/test_environment.py | 2 +- unit_test/environment_test.py | 29 +++++++++++++++++++++++------ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/test/test_environment.py b/test/test_environment.py index 6ad8ff9f..d2b75f0a 100644 --- a/test/test_environment.py +++ b/test/test_environment.py @@ -43,7 +43,7 @@ def test(tmp_path): project_dir, add_env={ "CIBW_ENVIRONMENT": """CIBW_TEST_VAR="a b c" CIBW_TEST_VAR_2=1 CIBW_TEST_VAR_3="$(echo 'test string 3')" PATH=$PATH:/opt/cibw_test_path""", - "CIBW_ENVIRONMENT_WINDOWS": '''CIBW_TEST_VAR="a b c" CIBW_TEST_VAR_2=1 CIBW_TEST_VAR_3="$(echo 'test string 3')" PATH="$PATH;/opt/cibw_test_path"''', + "CIBW_ENVIRONMENT_WINDOWS": '''CIBW_TEST_VAR="a b c" CIBW_TEST_VAR_2=1 CIBW_TEST_VAR_3="$(cmd /C echo test string 3)" PATH="$PATH;/opt/cibw_test_path"''', }, ) diff --git a/unit_test/environment_test.py b/unit_test/environment_test.py index c1d0a4a1..8c67b259 100644 --- a/unit_test/environment_test.py +++ b/unit_test/environment_test.py @@ -1,4 +1,5 @@ import os +import sys from cibuildwheel.environment import parse_environment @@ -28,7 +29,11 @@ def test_inheritance(): def test_shell_eval(): - environment_recipe = parse_environment('VAR="$(echo "a test" string)"') + if sys.platform == "win32": + env_string = 'VAR="$(cmd /C "echo a test string")"' + else: + env_string = 'VAR="$(echo "a test" string)"' + environment_recipe = parse_environment(env_string) env_copy = os.environ.copy() env_copy.pop("VAR", None) @@ -39,7 +44,11 @@ def test_shell_eval(): def test_shell_eval_and_env(): - environment_recipe = parse_environment('VAR="$(echo "$PREV_VAR" string)"') + if sys.platform == "win32": + env_string = 'VAR="$(cmd /C "echo $PREV_VAR string")"' + else: + env_string = 'VAR="$(echo "$PREV_VAR" string)"' + environment_recipe = parse_environment(env_string) environment_dict = environment_recipe.as_dictionary(prev_environment={"PREV_VAR": "1 2 3"}) @@ -73,7 +82,11 @@ def test_no_vars_pass_through(): def test_operators_inside_eval(): - environment_recipe = parse_environment('SOMETHING="$(echo a; echo b; echo c)"') + if sys.platform == "win32": + env_string = 'SOMETHING="$(cmd /C echo a; cmd /C echo b; cmd /C echo c)"' + else: + env_string = 'SOMETHING="$(echo a; echo b; echo c)"' + environment_recipe = parse_environment(env_string) # pass the existing process env so PATH is available environment_dict = environment_recipe.as_dictionary(os.environ.copy()) @@ -91,9 +104,13 @@ def test_substitution_with_backslash(): def test_awkwardly_quoted_variable(): - environment_recipe = parse_environment( - 'VAR2=something"like this""$VAR1"$VAR1$(echo "there is more")"$(echo "and more!")"' - ) + if sys.platform == "win32": + env_string = 'VAR2=something"like this""$VAR1"$VAR1$(cmd /C echo there is more)"$(cmd /C echo and more!)"' + else: + env_string = ( + 'VAR2=something"like this""$VAR1"$VAR1$(echo "there is more")"$(echo "and more!")"' + ) + environment_recipe = parse_environment(env_string) # pass the existing process env so PATH is available environment_dict = environment_recipe.as_dictionary({"VAR1": "but wait"}) From 23cdab79e6d44ced3adafe2fed5642c672ff63a2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 25 Jul 2022 19:17:51 +0000 Subject: [PATCH 82/86] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/asottile/pyupgrade: v2.37.1 → v2.37.2](https://github.com/asottile/pyupgrade/compare/v2.37.1...v2.37.2) - [github.com/asottile/setup-cfg-fmt: v1.20.1 → v1.20.2](https://github.com/asottile/setup-cfg-fmt/compare/v1.20.1...v1.20.2) - [github.com/pre-commit/mirrors-mypy: v0.961 → v0.971](https://github.com/pre-commit/mirrors-mypy/compare/v0.961...v0.971) --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8437bbb1..a1fa28a3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,7 +14,7 @@ repos: - id: trailing-whitespace - repo: https://github.com/asottile/pyupgrade - rev: v2.37.1 + rev: v2.37.2 hooks: - id: pyupgrade name: PyUpgrade 3.6+ @@ -44,12 +44,12 @@ repos: - id: black - repo: https://github.com/asottile/setup-cfg-fmt - rev: v1.20.1 + rev: v1.20.2 hooks: - id: setup-cfg-fmt - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.961 + rev: v0.971 hooks: - id: mypy name: mypy 3.6 on cibuildwheel/ From cccc2acae9c746839df9c0006a34f9df4f79af99 Mon Sep 17 00:00:00 2001 From: jack1142 <6032823+jack1142@users.noreply.github.com> Date: Fri, 29 Jul 2022 18:04:27 +0200 Subject: [PATCH 83/86] Use an equivalent of Unix echo written in Python --- test/test_environment.py | 3 ++- unit_test/environment_test.py | 33 ++++++++++----------------------- 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/test/test_environment.py b/test/test_environment.py index d2b75f0a..079081ce 100644 --- a/test/test_environment.py +++ b/test/test_environment.py @@ -33,6 +33,7 @@ project_with_environment_asserts = test_projects.new_c_project( def test(tmp_path): + python_echo = 'python -c "import sys; print(*sys.argv[1:])"' project_dir = tmp_path / "project" project_with_environment_asserts.generate(project_dir) @@ -43,7 +44,7 @@ def test(tmp_path): project_dir, add_env={ "CIBW_ENVIRONMENT": """CIBW_TEST_VAR="a b c" CIBW_TEST_VAR_2=1 CIBW_TEST_VAR_3="$(echo 'test string 3')" PATH=$PATH:/opt/cibw_test_path""", - "CIBW_ENVIRONMENT_WINDOWS": '''CIBW_TEST_VAR="a b c" CIBW_TEST_VAR_2=1 CIBW_TEST_VAR_3="$(cmd /C echo test string 3)" PATH="$PATH;/opt/cibw_test_path"''', + "CIBW_ENVIRONMENT_WINDOWS": f'''CIBW_TEST_VAR="a b c" CIBW_TEST_VAR_2=1 CIBW_TEST_VAR_3="$({python_echo} 'test string 3')" PATH="$PATH;/opt/cibw_test_path"''', }, ) diff --git a/unit_test/environment_test.py b/unit_test/environment_test.py index 8c67b259..696dff63 100644 --- a/unit_test/environment_test.py +++ b/unit_test/environment_test.py @@ -1,8 +1,9 @@ import os -import sys from cibuildwheel.environment import parse_environment +PYTHON_ECHO = 'python -c "import sys; print(*sys.argv[1:])"' + def test_basic_parsing(): environment_recipe = parse_environment("VAR=1 VBR=2") @@ -29,11 +30,7 @@ def test_inheritance(): def test_shell_eval(): - if sys.platform == "win32": - env_string = 'VAR="$(cmd /C "echo a test string")"' - else: - env_string = 'VAR="$(echo "a test" string)"' - environment_recipe = parse_environment(env_string) + environment_recipe = parse_environment(f'VAR="$({PYTHON_ECHO} "a test" string)"') env_copy = os.environ.copy() env_copy.pop("VAR", None) @@ -44,11 +41,7 @@ def test_shell_eval(): def test_shell_eval_and_env(): - if sys.platform == "win32": - env_string = 'VAR="$(cmd /C "echo $PREV_VAR string")"' - else: - env_string = 'VAR="$(echo "$PREV_VAR" string)"' - environment_recipe = parse_environment(env_string) + environment_recipe = parse_environment(f'VAR="$({PYTHON_ECHO} "$PREV_VAR" string)"') environment_dict = environment_recipe.as_dictionary(prev_environment={"PREV_VAR": "1 2 3"}) @@ -82,11 +75,9 @@ def test_no_vars_pass_through(): def test_operators_inside_eval(): - if sys.platform == "win32": - env_string = 'SOMETHING="$(cmd /C echo a; cmd /C echo b; cmd /C echo c)"' - else: - env_string = 'SOMETHING="$(echo a; echo b; echo c)"' - environment_recipe = parse_environment(env_string) + environment_recipe = parse_environment( + f'SOMETHING="$({PYTHON_ECHO} a; {PYTHON_ECHO} b; {PYTHON_ECHO} c)"' + ) # pass the existing process env so PATH is available environment_dict = environment_recipe.as_dictionary(os.environ.copy()) @@ -104,13 +95,9 @@ def test_substitution_with_backslash(): def test_awkwardly_quoted_variable(): - if sys.platform == "win32": - env_string = 'VAR2=something"like this""$VAR1"$VAR1$(cmd /C echo there is more)"$(cmd /C echo and more!)"' - else: - env_string = ( - 'VAR2=something"like this""$VAR1"$VAR1$(echo "there is more")"$(echo "and more!")"' - ) - environment_recipe = parse_environment(env_string) + environment_recipe = parse_environment( + f'VAR2=something"like this""$VAR1"$VAR1$({PYTHON_ECHO} "there is more")"$({PYTHON_ECHO} "and more!")"' + ) # pass the existing process env so PATH is available environment_dict = environment_recipe.as_dictionary({"VAR1": "but wait"}) From e0f25c5fb56683b57c11bd55e3cae302b3c1dafd Mon Sep 17 00:00:00 2001 From: jack1142 <6032823+jack1142@users.noreply.github.com> Date: Fri, 29 Jul 2022 18:52:26 +0200 Subject: [PATCH 84/86] Use sys.executable --- test/test_environment.py | 3 ++- unit_test/environment_test.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/test/test_environment.py b/test/test_environment.py index 079081ce..97326549 100644 --- a/test/test_environment.py +++ b/test/test_environment.py @@ -1,5 +1,6 @@ import os import subprocess +import sys import textwrap import pytest @@ -33,7 +34,7 @@ project_with_environment_asserts = test_projects.new_c_project( def test(tmp_path): - python_echo = 'python -c "import sys; print(*sys.argv[1:])"' + python_echo = f'"{sys.executable}" -c "import sys; print(*sys.argv[1:])"' project_dir = tmp_path / "project" project_with_environment_asserts.generate(project_dir) diff --git a/unit_test/environment_test.py b/unit_test/environment_test.py index 696dff63..3161a294 100644 --- a/unit_test/environment_test.py +++ b/unit_test/environment_test.py @@ -1,8 +1,9 @@ import os +import sys from cibuildwheel.environment import parse_environment -PYTHON_ECHO = 'python -c "import sys; print(*sys.argv[1:])"' +PYTHON_ECHO = f'"{sys.executable}" -c "import sys; print(*sys.argv[1:])"' def test_basic_parsing(): From 3cbe1756327ee38d0f6b8f558ea9daf773ea9257 Mon Sep 17 00:00:00 2001 From: jack1142 <6032823+jack1142@users.noreply.github.com> Date: Fri, 29 Jul 2022 18:57:47 +0200 Subject: [PATCH 85/86] Fix Windows paths getting escaped --- test/test_environment.py | 2 +- unit_test/environment_test.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_environment.py b/test/test_environment.py index 97326549..b784edab 100644 --- a/test/test_environment.py +++ b/test/test_environment.py @@ -34,7 +34,7 @@ project_with_environment_asserts = test_projects.new_c_project( def test(tmp_path): - python_echo = f'"{sys.executable}" -c "import sys; print(*sys.argv[1:])"' + python_echo = f"'{sys.executable}' -c \"import sys; print(*sys.argv[1:])\"" project_dir = tmp_path / "project" project_with_environment_asserts.generate(project_dir) diff --git a/unit_test/environment_test.py b/unit_test/environment_test.py index 3161a294..405fc8ac 100644 --- a/unit_test/environment_test.py +++ b/unit_test/environment_test.py @@ -3,7 +3,7 @@ import sys from cibuildwheel.environment import parse_environment -PYTHON_ECHO = f'"{sys.executable}" -c "import sys; print(*sys.argv[1:])"' +PYTHON_ECHO = f"'{sys.executable}' -c \"import sys; print(*sys.argv[1:])\"" def test_basic_parsing(): From 7c95f77524d56682ded70770f4cb9892419ec572 Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Fri, 29 Jul 2022 18:48:43 +0100 Subject: [PATCH 86/86] Ensure the tests that use subcommands have access to the system env --- unit_test/environment_test.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/unit_test/environment_test.py b/unit_test/environment_test.py index 405fc8ac..c5e6e57c 100644 --- a/unit_test/environment_test.py +++ b/unit_test/environment_test.py @@ -3,6 +3,7 @@ import sys from cibuildwheel.environment import parse_environment +# this command is equivalent to Unix 'echo', but works on Windows too PYTHON_ECHO = f"'{sys.executable}' -c \"import sys; print(*sys.argv[1:])\"" @@ -44,9 +45,10 @@ def test_shell_eval(): def test_shell_eval_and_env(): environment_recipe = parse_environment(f'VAR="$({PYTHON_ECHO} "$PREV_VAR" string)"') - environment_dict = environment_recipe.as_dictionary(prev_environment={"PREV_VAR": "1 2 3"}) + prev_environment = {**os.environ, "PREV_VAR": "1 2 3"} + environment_dict = environment_recipe.as_dictionary(prev_environment=prev_environment) - assert environment_dict == {"PREV_VAR": "1 2 3", "VAR": "1 2 3 string"} + assert environment_dict == {**prev_environment, "VAR": "1 2 3 string"} def test_empty_var(): @@ -80,8 +82,8 @@ def test_operators_inside_eval(): f'SOMETHING="$({PYTHON_ECHO} a; {PYTHON_ECHO} b; {PYTHON_ECHO} c)"' ) - # pass the existing process env so PATH is available - environment_dict = environment_recipe.as_dictionary(os.environ.copy()) + # pass the existing process env so subcommands can be run in the evaluation + environment_dict = environment_recipe.as_dictionary(prev_environment=os.environ.copy()) assert environment_dict.get("SOMETHING") == "a\nb\nc" @@ -89,7 +91,6 @@ def test_operators_inside_eval(): def test_substitution_with_backslash(): environment_recipe = parse_environment('PATH2="somewhere_else;$PATH1"') - # pass the existing process env so PATH is available environment_dict = environment_recipe.as_dictionary(prev_environment={"PATH1": "c:\\folder\\"}) assert environment_dict.get("PATH2") == "somewhere_else;c:\\folder\\" @@ -100,8 +101,8 @@ def test_awkwardly_quoted_variable(): f'VAR2=something"like this""$VAR1"$VAR1$({PYTHON_ECHO} "there is more")"$({PYTHON_ECHO} "and more!")"' ) - # pass the existing process env so PATH is available - environment_dict = environment_recipe.as_dictionary({"VAR1": "but wait"}) + prev_environment = {**os.environ, "VAR1": "but wait"} + environment_dict = environment_recipe.as_dictionary(prev_environment=prev_environment) assert ( environment_dict.get("VAR2") == "somethinglike thisbut waitbut waitthere is moreand more!"