Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: warn on deprecated images being set #2312

Merged
merged 4 commits into from
Mar 11, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions cibuildwheel/logger.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import codecs
import dataclasses
import os
import re
import sys
Expand Down Expand Up @@ -64,16 +65,18 @@ def __init__(self, *, unicode: bool) -> None:
self.error = "✕" if unicode else "failed"


@dataclasses.dataclass
class Logger:
fold_mode: str
colors_enabled: bool
unicode_enabled: bool
fold_mode: str = "disabled"
colors_enabled: bool = False
unicode_enabled: bool = False
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
dedupiclate: set[str] = dataclasses.field(default_factory=set)

def __init__(self) -> None:
def __post_init__(self) -> None:
if sys.platform == "win32" and hasattr(sys.stdout, "reconfigure"):
# the encoding on Windows can be a 1-byte charmap, but all CIs
# support utf8, so we hardcode that
Expand All @@ -96,11 +99,9 @@ def __init__(self) -> None:
self.colors_enabled = True

elif ci_provider == CIProvider.appveyor:
self.fold_mode = "disabled"
self.colors_enabled = True

else:
self.fold_mode = "disabled"
self.colors_enabled = file_supports_color(sys.stdout)

def build_start(self, identifier: str) -> None:
Expand Down Expand Up @@ -164,7 +165,11 @@ def notice(self, message: str) -> None:
c = self.colors
print(f"cibuildwheel: {c.bold}note{c.end}: {message}\n", file=sys.stderr)

def warning(self, message: str) -> None:
def warning(self, message: str, *, deduplicate: bool = False) -> None:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could just always do this for warnings?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think I'd prefer to keep it explicit, it's a bit surprising at the call site otherwise. Might also make some unit tests buggy as this is shared global state.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^ actually the global state thing might be a reason to do it on Options rather than here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was originally going to make it global as a ClassVar in options. I guess if it was an instance variable it still wouldn't over trigger? It's pretty common for warning to be only shown once globally (the "default" setting for warnings in Python, for example).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess if it was an instance variable it still wouldn't over trigger?

I don't think so. There's only one instance of Options in a normal running process. The only reason I hesitate to do it globally is that I can imagine a unit test expecting to see a warning but depending on test execution order, it sometimes gets triggered somewhere else and the test becomes flaky/hard to debug.

That said it's a hypothetical issue at this point, we can leave it here if you wish.

if deduplicate and message in self.dedupiclate:
return
self.dedupiclate.add(message)

if self.fold_mode == "github":
print(f"::warning::cibuildwheel: {message}\n", file=sys.stderr)
else:
Expand Down
13 changes: 13 additions & 0 deletions cibuildwheel/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,19 @@ def _compute_build_options(self, identifier: str | None) -> BuildOptions:
# default to manylinux2014
image = pinned_images["manylinux2014"]
elif config_value in pinned_images:
if config_value in {
"manylinux1",
"manylinux2010",
"manylinux_2_24",
"musllinux_1_1",
}:
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, deduplicate=True)
image = pinned_images[config_value]
else:
image = config_value
Expand Down
Loading