I was looking through my pip list and cleaning all my third party modules when I came across a module named 'distutils_hack'. I don't remember installing this, is this something I should be concerned about? The version I was using was Python 3.9.
It's used by setuptools to replace the stdlib distutils with setuptools' bundled distutils library.
Quoting ncoghlan from pypa/setuptools#417 on why this is necessary:
While CPython as a whole has many contributors, we don't have many folks contributing to
distutils
any more - folks need build tools that let them target currently deployed versions of Python, whichsetuptools
provides, butdistutils
really doesn't.So the challenge for pypa/packaging-problems#127 is as follows:
- assume that in some future version of Python (3.9? 3.10? 4.0? We dunno yet)
distutils
is no longer in the standard library per se, but is instead bundled the way we bundlepip
(i.e. by installing it from a wheel at Python installation time).- eventually, for new Python versions (where
distutils
isn't in the standard library), we'd like the "real" distutils code to live insetuptools
, and the code you get when you doimport distutils
to just be a backward compatibility shim that aliases thesetuptools
components into the right place- however, for old Python versions (where
distutils
is still in the standard library), thensetuptools
will still need to do its monkeypatching magic to allow plain distutils projects to emit the installation database metadata and to be built as wheel archivesThe scope of the eventual
distutils-compat
shim probably wouldn't need to be the full distutils API, but it wouldn't be the empty set either.So @jaraco's suggestion sounds like a reasonable starting point to me: give
setuptools
its own pre-patched copy ofdistutils
so it can work on adistutils
-free copy of Python, without providing an importabledistutils
facade.Building a suitable facade (with a
setuptools
dependency) would then be part of removingdistutils
from the standard library.
Here is where you can find the module's source code: https://github.com/pypa/setuptools/blob/main/_distutils_hack/__init__.py