[Distutils] Extracting distutils into setuptools

Nick Coghlan ncoghlan at gmail.com
Wed Sep 27 23:36:32 EDT 2017


On 28 September 2017 at 06:00, xoviat <xoviat at gmail.com> wrote:
> That's actually an interesting idea though: for Python 3.7 distutils ->
> _distutils (and then setuptools is required for building). For/against?

distutils works fine for its original purpose (building components for
the system Python in Linux distros), so we still need to avoid
breaking that. setuptools is only essential if you want full support
for modern *Python* level packaging features (PEP 376 install
metadata, venv compatibility, wheel files, etc), and a lot of Linux
system components simply don't worry about those things, and rely on
their system level equivalents instead (e.g. the RPM/deb databases,
chroots and containers, RPM/deb files)

However, what *could* be interesting is a proposal to move distutils
to the "ensurepip" model, where rather than maintaining distutils
directly as part of CPython, the CPython build process instead runs
setuptools/distutils from a bundled wheel file. Doing that would
entail having setuptools actually start installing a copy of distutils
into site-packages: older CPython releases would ignore it by default
(since the stdlib version would shadow it), while 3.7+ would offer
either "python3 -m ensuredistutils" or "python3 -m ensuresetuptools"
(bikeshed to be painted via the PEP process) to install the
setuptools-provided version.

I'm not claiming actually doing that would be particularly easy - I
just think it's the most viable path to get us away from the current
version coupling between the build infrastructure in distutils and the
runtime support infrastructure in the rest of the standard library,
and to avoid maintaining two distinct copies of distutils indefinitely
(one in the stdlib, one in setuptools).

That approach wouldn't even entail any *new* bundling at the CPython
level, as while it's currently formally an implementation detail
(pending potential removal in a post-PEP-517 world), setuptools is
already bundled as part of the support infrastructure for ensurepip:
https://github.com/python/cpython/tree/master/Lib/ensurepip/_bundled

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Distutils-SIG mailing list