[bumpversion]
-current_version = 65.6.2
+current_version = 65.6.3
commit = True
tag = True
+v65.6.3
+-------
+
+
+Misc
+^^^^
+* #3709: Fix condition to patch ``distutils.dist.log`` to only apply when using
+ ``distutils`` from the stdlib.
+
+
v65.6.2
-------
[metadata]
name = setuptools
-version = 65.6.2
+version = 65.6.3
author = Python Packaging Authority
author_email = distutils-sig@python.org
description = Easily download, build, install, upgrade, and uninstall Python packages
import sys
+import inspect
import logging
import distutils.log
from . import monkey
handlers = err_handler, out_handler
logging.basicConfig(
format="{message}", style='{', handlers=handlers, level=logging.DEBUG)
- if hasattr(distutils.log, 'Log'):
+ if inspect.ismodule(distutils.dist.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,
+import inspect
import logging
+import os
import pytest
log_level = logger.getEffectiveLevel()
log_level_name = logging.getLevelName(log_level)
assert log_level_name == expected_level
+
+
+def test_patching_does_not_cause_problems():
+ # Ensure `dist.log` is only patched if necessary
+
+ import setuptools.logging
+ from distutils import dist
+
+ setuptools.logging.configure()
+
+ if os.getenv("SETUPTOOLS_USE_DISTUTILS", "local").lower() == "local":
+ # Modern logging infra, no problematic patching.
+ assert isinstance(dist.log, logging.Logger)
+ else:
+ assert inspect.ismodule(dist.log)