From a1a5af3bc4164fe7b03ff92c4048eb6acbec62c7 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 8 Oct 2022 20:57:44 -0400 Subject: [PATCH] Restore protection of distutils.log patching. --- setuptools/logging.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/setuptools/logging.py b/setuptools/logging.py index 70708adb7fb..98e0bb48763 100644 --- a/setuptools/logging.py +++ b/setuptools/logging.py @@ -24,7 +24,11 @@ def configure(): format="{message}", style='{', handlers=handlers, level=logging.DEBUG) if hasattr(distutils.log, 'Log'): monkey.patch_func(set_threshold, distutils.log, 'set_threshold') - + # For some reason `distutils.log` module is getting cached in `distutils.dist` + # and then loaded again when patched, + # implying: id(distutils.log) != id(distutils.dist.log). + # Make sure the same module object is used everywhere: + distutils.dist.log = distutils.log def set_threshold(level): logging.root.setLevel(level*10)