fix: image deprecation warning (#2314)
This commit is contained in:
committed by
Joe Rickerby
parent
a880bf5105
commit
c25fe60385
+17
-19
@@ -567,7 +567,7 @@ class Options:
|
|||||||
self.command_line_arguments = command_line_arguments
|
self.command_line_arguments = command_line_arguments
|
||||||
self.env = env
|
self.env = env
|
||||||
self._defaults = defaults
|
self._defaults = defaults
|
||||||
self._image_warnings = set[str]()
|
self._image_warnings: set[str] = set()
|
||||||
|
|
||||||
self.reader = OptionsReader(
|
self.reader = OptionsReader(
|
||||||
None if defaults else self.config_file_path,
|
None if defaults else self.config_file_path,
|
||||||
@@ -689,6 +689,20 @@ class Options:
|
|||||||
allow_empty=allow_empty,
|
allow_empty=allow_empty,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def _check_pinned_image(self, value: str, pinned_images: Mapping[str, str]) -> None:
|
||||||
|
if (
|
||||||
|
value in {"manylinux1", "manylinux2010", "manylinux_2_24", "musllinux_1_1"}
|
||||||
|
and value not in self._image_warnings
|
||||||
|
):
|
||||||
|
self._image_warnings.add(value)
|
||||||
|
msg = (
|
||||||
|
f"Deprecated image {value!r}. This value will not work"
|
||||||
|
" in a future version of cibuildwheel. Either upgrade to a supported"
|
||||||
|
" image or continue using the deprecated image by pinning directly"
|
||||||
|
f" to {pinned_images[value]!r}."
|
||||||
|
)
|
||||||
|
log.warning(msg)
|
||||||
|
|
||||||
def build_options(self, identifier: str | None) -> BuildOptions:
|
def build_options(self, identifier: str | None) -> BuildOptions:
|
||||||
"""
|
"""
|
||||||
Compute BuildOptions for a single run configuration.
|
Compute BuildOptions for a single run configuration.
|
||||||
@@ -786,24 +800,7 @@ class Options:
|
|||||||
# default to manylinux2014
|
# default to manylinux2014
|
||||||
image = pinned_images["manylinux2014"]
|
image = pinned_images["manylinux2014"]
|
||||||
elif config_value in pinned_images:
|
elif config_value in pinned_images:
|
||||||
if (
|
self._check_pinned_image(config_value, pinned_images)
|
||||||
config_value
|
|
||||||
in {
|
|
||||||
"manylinux1",
|
|
||||||
"manylinux2010",
|
|
||||||
"manylinux_2_24",
|
|
||||||
"musllinux_1_1",
|
|
||||||
}
|
|
||||||
and config_value not in self._image_warnings
|
|
||||||
):
|
|
||||||
self._image_warnings.add(config_value)
|
|
||||||
msg = (
|
|
||||||
f"Deprecated image {config_value!r}. This value will not work"
|
|
||||||
" in a future version of cibuildwheel. Either upgrade to a supported"
|
|
||||||
" image or continue using the deprecated image by pinning directly"
|
|
||||||
f" to {pinned_images[config_value]!r}."
|
|
||||||
)
|
|
||||||
log.warning(msg)
|
|
||||||
image = pinned_images[config_value]
|
image = pinned_images[config_value]
|
||||||
else:
|
else:
|
||||||
image = config_value
|
image = config_value
|
||||||
@@ -818,6 +815,7 @@ class Options:
|
|||||||
if not config_value:
|
if not config_value:
|
||||||
image = pinned_images["musllinux_1_2"]
|
image = pinned_images["musllinux_1_2"]
|
||||||
elif config_value in pinned_images:
|
elif config_value in pinned_images:
|
||||||
|
self._check_pinned_image(config_value, pinned_images)
|
||||||
image = pinned_images[config_value]
|
image = pinned_images[config_value]
|
||||||
else:
|
else:
|
||||||
image = config_value
|
image = config_value
|
||||||
|
|||||||
@@ -459,3 +459,36 @@ def test_free_threaded_support(
|
|||||||
assert EnableGroups.CPythonFreeThreading in options.globals.build_selector.enable
|
assert EnableGroups.CPythonFreeThreading in options.globals.build_selector.enable
|
||||||
else:
|
else:
|
||||||
assert EnableGroups.CPythonFreeThreading not in options.globals.build_selector.enable
|
assert EnableGroups.CPythonFreeThreading not in options.globals.build_selector.enable
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
("image", "deprecated"),
|
||||||
|
[
|
||||||
|
("manylinux1", True),
|
||||||
|
("manylinux2010", True),
|
||||||
|
("manylinux2014", False),
|
||||||
|
("manylinux_2_24", True),
|
||||||
|
("manylinux_2_28", False),
|
||||||
|
("manylinux_2_34", False),
|
||||||
|
("musllinux_1_1", True),
|
||||||
|
("musllinux_1_2", False),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_deprecated_image(image: str, deprecated: bool, capsys: pytest.CaptureFixture[str]) -> None:
|
||||||
|
args = CommandLineArguments.defaults()
|
||||||
|
env = {
|
||||||
|
"CIBW_ARCHS": "x86_64",
|
||||||
|
"CIBW_MANYLINUX_X86_64_IMAGE": image if image.startswith("manylinux") else "",
|
||||||
|
"CIBW_MUSLLINUX_X86_64_IMAGE": image if image.startswith("musllinux") else "",
|
||||||
|
}
|
||||||
|
options = Options(platform="linux", command_line_arguments=args, env=env)
|
||||||
|
bo = options.build_options(None)
|
||||||
|
images = bo.manylinux_images if image.startswith("manylinux") else bo.musllinux_images
|
||||||
|
assert images is not None
|
||||||
|
resolved_image = images["x86_64"]
|
||||||
|
captured = capsys.readouterr()
|
||||||
|
if deprecated:
|
||||||
|
assert f"Deprecated image {image!r}" in captured.err
|
||||||
|
assert f"{resolved_image!r}" in captured.err
|
||||||
|
else:
|
||||||
|
assert captured.err == ""
|
||||||
|
|||||||
Reference in New Issue
Block a user