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

Conversation

henryiii
Copy link
Contributor

See #2047.

@henryiii henryiii force-pushed the henryiii/fix/warn-on-dep branch from a4ed9aa to 9fa0075 Compare March 10, 2025 21:19
Copy link
Contributor

@joerick joerick left a comment

Choose a reason for hiding this comment

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

I think we'd want to check that the warning doesn't fire loads of times? I think that build_options() is called rather a lot... at least, once per identifier. Perhaps we'd need an instance variable tracking which deprecated images have already been seen.

@joerick joerick added the needs-backport Can/should be ported to LTS branch label Mar 10, 2025
@@ -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.

@@ -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

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.

@henryiii henryiii force-pushed the henryiii/fix/warn-on-dep branch from 1c3d5c4 to 8a190f4 Compare March 11, 2025 04:38
Copy link
Contributor

@joerick joerick left a comment

Choose a reason for hiding this comment

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

Looks good. Thanks for putting it together. I'll roll this into a 2.x patch release.

@henryiii henryiii merged commit 915d15c into pypa:main Mar 11, 2025
25 checks passed
@henryiii henryiii deleted the henryiii/fix/warn-on-dep branch March 11, 2025 20:44
joerick added a commit that referenced this pull request Mar 12, 2025
* fix: warn on deprecated images being set

Signed-off-by: Henry Schreiner <[email protected]>

* fix: handle repeated warning messages

Signed-off-by: Henry Schreiner <[email protected]>

* Apply suggestions from code review

Co-authored-by: Joe Rickerby <[email protected]>

* fix: try making the warnings once per Options

Signed-off-by: Henry Schreiner <[email protected]>

---------

Signed-off-by: Henry Schreiner <[email protected]>
Co-authored-by: Joe Rickerby <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-backport Can/should be ported to LTS branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants