Repository: pypa/setuptools

Issue:
[BUG] release v65.6.0 breaks packages downstream due to removal of `distutils.log.Log`
### setuptools version

65.6.0

### Python version

Python 3.10

### OS

Ubuntu

### Additional environment information

_No response_

### Description

The `distutils.log.Log` class was removed in https://github.com/pypa/setuptools/commit/74652cabdeaacadc76ccf126563bed8ee2ccf3ef. This causes popular packages downstream, such as `numpy`, to fail: see https://github.com/numpy/numpy/issues/22623

### Expected behavior

The module `distutils.log` module was not officially marked as deprecated even though https://github.com/pypa/setuptools/commit/74652cabdeaacadc76ccf126563bed8ee2ccf3ef added to the docstring that the module is `Retained for compatibility and should not be used.`. It would be great if the removed class could be reinstated and a deprecation pathway be provided.

### How to Reproduce

1. `pip install setuptools==65.6.0`
2. `from numpy.distutils import Log`

### Output

```
In [4]: from numpy.distutils import Log
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-4-f8e71815afcd> in <module>
----> 1 from numpy.distutils import Log

~/.virtualenvs/aiida_dev/lib/python3.9/site-packages/numpy/distutils/__init__.py in <module>
     22 # Must import local ccompiler ASAP in order to get
     23 # customized CCompiler.spawn effective.
---> 24 from . import ccompiler
     25 from . import unixccompiler
     26 

~/.virtualenvs/aiida_dev/lib/python3.9/site-packages/numpy/distutils/ccompiler.py in <module>
     18 from distutils.version import LooseVersion
     19 
---> 20 from numpy.distutils import log
     21 from numpy.distutils.exec_command import (
     22     filepath_from_subprocess_output, forward_bytes_to_stdout

~/.virtualenvs/aiida_dev/lib/python3.9/site-packages/numpy/distutils/log.py in <module>
      2 import sys
      3 from distutils.log import *  # noqa: F403
----> 4 from distutils.log import Log as old_Log
      5 from distutils.log import _global_log
      6 

ImportError: cannot import name 'Log' from 'distutils.log' (/home/sph/.virtualenvs/aiida_dev/lib/python3.9/site-packages/setuptools/_distutils/log.py)
```


Discussion:
This actually breaks just importing `numpy.distutils` altogether:
```python
In [2]: import numpy.distutils
---------------------------------------------------------------------------
ImportError
...
~/38venv/lib/python3.8/site-packages/numpy/distutils/log.py in <module>
      2 import sys
      3 from distutils.log import *  # noqa: F403
----> 4 from distutils.log import Log as old_Log
      5 from distutils.log import _global_log
      6 

ImportError: cannot import name 'Log' from 'distutils.log' (~/38venv/lib/python3.8/site-packages/setuptools/_distutils/log.py)

```
This is a serious issue for people using older numpy (that can only install with distutils) and poetry (as poetry doesn't respect PEP-518 AFAICT). We have no way to install our dependencies except to manually install numpy with the `--no-build-isolation` flag.
Also running into this, numpy 1.23.5 is also affected.
`export SETUPTOOLS_USE_DISTUTILS=stdlib` appears to be another workaround, which allowed me then to build/install `scipy==1.4.1` on ARM (where there are no prebuilt binaries).

@bentheiii 's alternative above of `pip install --no-build-isolation scipy==1.4.1` after pinning back setuptools was the only other way I got to work so far.
Note that this only appears in the latest poetry, downgrading to `1.1.15` appears to fix the issue
@bentheiii I'm running into this from numpy 1.19.4 also. what do I need to downgrade 1.1.15 to? 
we are supposed to be on setuptools==53.0.0 but still running into this somehow started recently..
Running into this for statsmodels==0.13.0 and numpy==1.22.0
For numpy, follow one of the two options I listed for scipy.  (Scipy hits it because of its dependence on numpy.)

Resolving patch:
diff --git a/setuptools/_distutils/log.py b/setuptools/_distutils/log.py
--- a/setuptools/_distutils/log.py
+++ b/setuptools/_distutils/log.py
@@ -5,6 +5,7 @@
 """
 
 import logging
+import warnings
 
 from ._log import log as _global_log
 
@@ -36,3 +37,21 @@ def set_verbosity(v):
         set_threshold(logging.INFO)
     elif v >= 2:
         set_threshold(logging.DEBUG)
+
+
+class Log(logging.Logger):
+    """distutils.log.Log is deprecated, please use an alternative from `logging`."""
+
+    def __init__(self, threshold=WARN):
+        warnings.warn(Log.__doc__)  # avoid DeprecationWarning to ensure warn is shown
+        super().__init__(__name__, level=threshold)
+
+    @property
+    def threshold(self):
+        return self.level
+
+    @threshold.setter
+    def threshold(self, level):
+        self.setLevel(level)
+
+    warn = logging.Logger.warning


Test patch: