-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
BUG: importing numpy.distutils replaces the global logger with a custom class which doesn't support kwargs #24213
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 am going to close this. Distutils is very old and now deprecated, we are moving to meson for NumPy 2.0.0 and 1.26.0 builds. Python itself dropped distutils in Python 3.12. If you have questions about the transition, feel free to continue the discussion here. |
Fair enough. For completeness and for other's reference, I should point out that this does not only affect importing |
Is this in the main branch, or in a release? If this is still in the main branch, it will need fixing. You might try one of the nightly wheels to see if there are still problems: https://anaconda.org/scientific-python-nightly-wheels/numpy/ . |
The main branch still uses At some point after finishing #24206 (which allows removing |
It doesn't: Lines 131 to 142 in b0ff5c5
1.25.x branch is clean.
I searched the repo again, it's a bit difficult to do because of the many comments, setup.py files etc. where I agree with closing this issue, because of the orginal reason given: |
Got, thanks. I must have been looking at a different branch. Thanks for re-checking. Closing. |
Uh oh!
There was an error while loading. Please reload this page.
Describe the issue:
Importing
numpy.distutils
silently replaces the global logger returned bylogging.getLogger()
with the custom class fromnumpy.distutils.log
. This is surprising in of itself, but additionally the signature ofnumpy.distutils.log.Log._log()
is outdated/incorrect and does not support the kwargsexc_info
,stack_info
,stacklevel
orextra
. In particular, this means theexception()
method of the custom logger does not work.Reproduce the code example:
Error message:
Runtime information:
Context for the issue:
Any package that imports anything from
numpy.distutils
will accidentally break the root logger for the whole program/script. In addition, because it's not obvious that the root logger is replaced in this way, this problem can be (and sadly was) challenging to diagnose.For a real world example, importing
pyscf
also recreates this behaviour:The text was updated successfully, but these errors were encountered: