Make container-engine a global option, since that's how its being used
This commit is contained in:
+13
-8
@@ -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(
|
||||
|
||||
+11
-10
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user