-
Notifications
You must be signed in to change notification settings - Fork 122
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
How to turn backend warnings into errors? #482
Comments
As @agoose77 points out, $ PYTHONWARNINGS=error python -m build . works as desired. 👍 |
That was spoken too soon. I guess I really just want to turn |
OK, I looked into this and it looks like the commandline warning configuration is pretty lacklustre right now in Python. You can pass a |
Can't you use colons? The (little used) fourth colon separated part is a module name, IIRC. |
If colons worked, then shouldn't this $ PYTHONWARNINGS=error::SetuptoolsDeprecationWarning python -m build . work? This allows for
to pass without error.
Yeah, the warnings docs say
but $ PYTHONWARNINGS=error::SetuptoolsDeprecationWarning:setuptools python -m build . gives Invalid -W option ignored: unknown warning category: 'SetuptoolsDeprecationWarning' |
You could raise any warnings from setuptools instead of the specific deprecation warning. I think that's what @henryiii is implying? I've tested that it works, though it will not discriminate between warning kinds. |
Hm, I'm confused as to what I'm doing wrong then as $ PYTHONWARNINGS=error:::setuptools python -m build . fails to detect
but $ PYTHONWARNINGS=error python -m build . properly raises
|
It expects the fully-qualified module name, which in this case would be |
Thanks @layday — this is the last bit that I was missing. |
* Add `PYTHONWARNINGS=error,default::DeprecationWarning` to the environment to cause Python to treat warnings as errors (but use default for DeprecationWarning as probably internal to build tools) during the package build to ensure that the build configuration conforms to the latest standards. Use the 'PYTHONWARNINGS' environment variable as `build` runs in a new process and so something like `python -Werror -m build .` won't be able to pass the flags into the new process, but the shell environment will be picked up. - c.f. https://docs.python.org/3/library/warnings.html#describing-warning-filters - c.f. pypa/build#482 * Remove `--outdir` option from `build` to use default.
In scikit-hep/pyhf#1881 I noticed and fixed a
SetuptoolsDeprecationWarning
thatpyhf
had in its setup. Aspyhf
runsbuild
in its CI to ensure things are working I would like to have these warnings get turned into errors so that the dev team is alerted to them in advance (I just noticed thisSetuptoolsDeprecationWarning
by looking at the logs by chance).My naive attempt at
$ python -Werror -m build .
doesn't work, but I guess I'm unclear on how one should pass in warning filters to
build
and the commands that it will run as$ python -m build --config-setting=-Werror .
also doesn't work (though that makes sense as
--config-setting
is going to the backend (setuptools
) and not to Python).The text was updated successfully, but these errors were encountered: