For the last few years, we've stopped updating distutils to support new packaging interoperability standards, and have instead recommended that folks that want to rely on features in metadata 1.2+, or to generate wheel archives, switch to using setuptools. This has allowed the packaging metadata support to evolve independently of the exact version of Python that folks are using to publish their packages, and it's worked well enough that I'm willing to call the approach a success.
However, it has left us with a maintainability issue, which is that we still have a distutils API implementation shipping with CPython that we don't actually want people to be using, and the source of the problem isn't always obvious when folks using that implementation aren't getting the behaviour they expect or want.
pip has long injected the setuptools monkeypatches of distutils before running setup.py scripts, and the setuptools folks are considering switching to providing their own setuptools-maintained copy of distutils rather than continuing to monkeypatch the standard library version at import time: pypa/setuptools#417
I think the cleanest way to resolve this will be to actively seek to switch distutils over to the ensurepip model of maintenance: add an ensuredistutils module to the standard library that installs bundled versions of setuptools and wheel, just as ensurepip installs a bundled copy of pip.
Identified substeps:
For the last few years, we've stopped updating
distutilsto support new packaging interoperability standards, and have instead recommended that folks that want to rely on features in metadata 1.2+, or to generate wheel archives, switch to usingsetuptools. This has allowed the packaging metadata support to evolve independently of the exact version of Python that folks are using to publish their packages, and it's worked well enough that I'm willing to call the approach a success.However, it has left us with a maintainability issue, which is that we still have a
distutilsAPI implementation shipping with CPython that we don't actually want people to be using, and the source of the problem isn't always obvious when folks using that implementation aren't getting the behaviour they expect or want.piphas long injected thesetuptoolsmonkeypatches ofdistutilsbefore runningsetup.pyscripts, and thesetuptoolsfolks are considering switching to providing their ownsetuptools-maintained copy ofdistutilsrather than continuing to monkeypatch the standard library version at import time: pypa/setuptools#417I think the cleanest way to resolve this will be to actively seek to switch
distutilsover to theensurepipmodel of maintenance: add anensuredistutilsmodule to the standard library that installs bundled versions ofsetuptoolsandwheel, just asensurepipinstalls a bundled copy ofpip.Identified substeps:
setuptoolsdependency on stdlibdistutils)distutilsAPI in thesetuptoolsdocumentation.ensuredistutilsmodule targeting either Python 3.9 (feature freeze early 2020) or 3.10 (feature freeze early 2021)pkg_resourcesat runtime should be explicitly declaring a dependency onsetuptoolsanyway)