-
- Notifications
You must be signed in to change notification settings - Fork 1.3k
Overhaul for better visibility of warnings #3849
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
Conversation
The objective is to centralize all the warnings in a single module.
| The following is a list of "due dates" that I loosely proposed in this PR.
Unspecified "due dates":
|
| Probably this idea of adding a due date to every single deprecation warning is a bit too excessive... and is likely to cause a lot of push back from the community. @jaraco do you have any thoughts about how should we handle deprecations? (Should we enforce an 'end-date' for them?). |
edmorley left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for working on improving deprecation warnings! :-)
Co-authored-by: Ed Morley <501702+edmorley@users.noreply.github.com>
| Thank you very much for the suggestions @edmorley. |
I'm slightly opposed to this concept because it sidesteps the conventions established by Python, mainly the convention that DeprecationWarnings get a special treatment (invisible by default except under tests). The reason we created SetuptoolsDeprecationWarning was to bypass this convention in select circumstances where it's important for end users to see the warning outside of test environments. In practice, since Setuptools is moving away from being an API and instead focusing on being a build backend, it's going to be increasingly important for build backends to be able to surface warnings and errors through the frontends. To the extent this change achieves that goal, that's great, but I do worry about the potential to create a whole new convention/standard that users may need to honor... or perhaps it's already that way and this change just consolidates the ad-hoc approach.
The CPython project has started using a methodology for due dates, based on the formalized deprecation policy. That policy makes it easier, because it treats all deprecations as more-or-less equal and gives them two governed major releases before removing. The process we're talking about introducing here is much more flexible and thus nuanced, so would require more consideration for each incidence. I worry that approach could increase the maintenance burden and impede the ability to enact deprecations when appropriate. I've been unwilling to try to manage this space so rigorously, but I'm glad to see Anderson tackling this issue. I'm supportive of creating a framework for managing deprecations especially if it limits the aforementioned concerns. I'm willing to try it out and see how it goes. As far as due dates, there are two facets to consider: giving users a more predictable expectation and mechanically enforcing that expectation. I'm an enthusiastic +1 on the former, but -0 on the latter. My main concern with mechanically enforcing due dates is that users would then have less control over protecting against breaking changes - the "breaking" release would be the one where the due date was added and not the one where the behavior is actually removed, because once the due-date passes, that release is now breaking (depending on your perspective). Or maybe there are now two breaking releases for each breaking change. So while I have some concerns, I appreciate all the effort that's gone into characterizing the deprecations and creating a framework for managing them, and I'm happy to try it out. |
| Thank you very much @jaraco, I merged this and created a new release. If we have a push back we can revert. The reason why I went with a due date instead of a "2 releases from now" policy is because setuptools does not work with a release calendar like CPython. I thought that using a due date would make things more predictable. The enforcement should only be "opt-in", so when the due date arrives, the users will still be able to use the software in the same way there where using before, as long as they don't set I did set |
| @abravalheri looks like the warnings are turned into errors unconditionally now. See https://dev.azure.com/ansible/ansible/_build/results?buildId=74849&view=logs&j=05630f17-7677-51af-4b88-11118adc6a44&t=b3edd11b-a13a-5494-96a8-2c9d98447f6f&l=234 |
| Additional details for the failure can be found on #3898, including a simple reproducer. |
…> `[uv ]pip install --no-build-isolation [-e ].` (#156027) Modernize the development installation: ```bash # python setup.py develop python -m pip install --no-build-isolation -e . # python setup.py install python -m pip install --no-build-isolation . ``` Now, the `python setup.py develop` is a wrapper around `python -m pip install -e .` since `setuptools>=80.0`: - pypa/setuptools#4955 `python setup.py install` is deprecated and will emit a warning during run. The warning will become an error on October 31, 2025. - https://github.com/pypa/setuptools/blob/9c4d383631d3951fcae0afd73b5d08ff5a262976/setuptools/command/install.py#L58-L67 > ```python > SetuptoolsDeprecationWarning.emit( > "setup.py install is deprecated.", > """ > Please avoid running ``setup.py`` directly. > Instead, use pypa/build, pypa/installer or other > standards-based tools. > """, > see_url="https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html", > due_date=(2025, 10, 31), > ) > ``` - pypa/setuptools#3849 Additional Resource: - [Why you shouldn't invoke setup.py directly](https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html) Pull Request resolved: #156027 Approved by: https://github.com/ezyang
The idea of this PR is to partially tackle #3780.
Summary of changes
setuptools.warnings.SetuptoolsWarning.emitmethod in the warning classes that adds a lot of visual decorations for improving the visibility.due_date,see_docs,see_urlto provide more information to the user, as requested in Better visibility to deprecations #3780 (fallback to the corresponding attributes in the warning class, e.g._DUE_DATE,_SEE_DOCS, etc...).SETUPTOOLS_ENFORCE_DEPRECATION=true.tox.inito remind us to act once the deprecation period is over.warnings.warnwith the newemit. I took this opportunity to re-visit some of the warning messages and try to assign a due date as requested in Better visibility to deprecations #3780. This might be the bulk of the change.Other implications and open questions
In this PR, I tried to assign "due dates" for the deprecation warnings as it was originally requested in #3780.
If we actually try to enforce these deprecations, this might be too disruptive...
Moreover there is always the problem with old unmaintained projects that may stop working if they need to be installed from
sdists/source...So we have a few options here:
Remarks
I did not try to apply this to
pkg_resourcesonly tosetuptools...The reasoning behind it that
pkg_resourceswarnings areDeprecationWarningsinvisible by default... So I don't know how much effective changing it would be.Pull Request Checklist
changelog.d/.(See documentation for details)