-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
warnings raised by test_peg_generator when setuptools_scm is installed #133509
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
Comments
I just reproduced this with latest main, with just setuptools 80.3.1 and setuptools_scm 8.3.1 available in |
The test is failing because the test suite doesn't like it when |
I don't think that #131802 just uncovered something that was always the case. As I mentioned above, when I remove That seems like there's more going on than just Also, it doesn't really explain (at least to me) how does the same exact handler (it's the same weakref to the same handler) appear for the second time in the |
To be clear--I don't think there's a bug, on our end or on It's not immediately obvious why removing |
Well, the main issue I am trying to solve is that the test suite is failing. I can live with the warning, but we'd really like to have the test suite pass, and there doesn't seem to be a simple way to ignore this warning-turned-to-error. BTW, I just reproduced this on Fedora with 3.13.3 as well, so it's not a platform diff. I will ask in setuptools_scm issues; maybe somebody will have some more insight there. |
In general, running the tests with third-party packages installed is not a supported (or supportable) configuration. There's no limit to what such packages can change. |
The whole point is that warnings won't freely pass in tests anymore, hopefully catching bugs. What's the use case here, anyway? I can't think of many reasons why you'd need to run the CPython test suite with packages installed. |
That makes sense. But it would still be nice if it worked with at least a subset of packages known to be installed on machine used to build python stuff ;).
I understand that, but as you mentioned above, this is likely not a bug. And there doesn't seem to be a way to suppress the warning for
That's the way we are building all packages for Oracle Solaris (and I wouldn't be surprised if we were alone in this). The build machine contains everything that is necessary to build the whole Userland, and since I tried running tests isolated from the machine with Maybe the simplest thing is to skip the pegen tests... Or would you have another suggestion on how to handle this? Being able to ignore the warning for this specific test would be nice, though I don't think there is a nice place to put a warning filter into. |
Im happy to adjust how setuptools_scm creates its handlers |
AFAICS, the problem is that it initializes handlers in a pth file, which the test suite notices. An easy fix would be to put that behavior behind an environment variable (e.g., |
There's no pth But setuptools plugin import |
Maybe setuptools itself has a pth file? There's definitely some pth file that triggers it if |
Its possible that setuptools tries to ensure its distutils package is getting used via a pth Someone needs to validate |
I am no expert on the import process, but I don't think that foo.py (setuptools part) import logging
from importlib import metadata
print(logging._handlerList)
group = "foo.finalize_distribution_options"
defined = metadata.entry_points(group=group)
for ep in defined:
func = ep.load() # this triggers the new handler creation
#func()
print(logging._handlerList) local/bar.py (setuptools_scm part) import logging
handler = logging.StreamHandler()
def infer_version():
pass $> cat local/bar.dist-info/entry_points.txt
[foo.finalize_distribution_options]
bar = bar:infer_version
$> PYTHONPATH=`pwd`/local python3.13 -S foo.py
[<weakref at 0x7fcb47a5b2d90; to 'logging._StderrHandler' at 0x7fcb47a5a92b0>]
[<weakref at 0x7fcb47a5b2d90; to 'logging._StderrHandler' at 0x7fcb47a5a92b0>, <weakref at 0x7fcb478411710; to 'logging.StreamHandler' at 0x7fcb47a5a96a0>] As for the potential solutions, the issue is that the new handler is always created globally on import. Even if it was created later on demand, it would likely be necessary when I am not sure what is the reason to always create the new logging handler (maybe to ensure one always exists? Though the |
The logging details changed a number of times due to ux concerns Im happy to drop the creation But i have to ensure correct configuration and working logging Its only necessary to actually configure logging if one of the entrypoints starts the machinery |
Let's continue in pypa/setuptools-scm#1139 - seems that is a better place for this issue. |
Uh oh!
There was an error while loading. Please reload this page.
Bug report
Bug description:
Hi, since #131802, we see
test_peg_generator
failing with the following warning:For some reason, during the execution, second reference to the same 'setuptools_scm._log.AlwaysStdErrHandler' appears in the
_handlerList
.When I remove
setuptools_scm
, the issue is gone.Interestingly (at least to me), when I revert changes done in #131802 in
lib/test/support/__init__.py
andos_helper.py
(commenting outimport logging
is enough), the issue is gone as well, so it seems like some weird side effect of the import?I tried to track the issue and got through setuptools all the way to
ep.load()
infinalize_options()
which triggers the issue (see trace below).I added some debug prints to
_addHandlerRef
function, and it's apparently called only once with this handler. Though I also see a single call for thelogging._StderrHandler'
and it's there twice as well, so I am probably overlooking something...Here is the trace from when the handler ref is being added during the test execution:
All this is with Python 3.13 (latest changes), setuptools 80.3.1, setuptools_scm 8.3.1, and on Oracle Solaris, but I don't think this is necessarily platform dependent.
I also reproduced this with older setuptools 73.0.1 and setuptools_scm 8.1.0.
CPython versions tested on:
3.13
Operating systems tested on:
Other
The text was updated successfully, but these errors were encountered: