There's an effort underway to move the functionality of distutils into Setuptools and other libraries, with a goal to remove distutils from the standard library.
Re:
(Though replacing distutils with setuptools wherever possible is worthwhile irrespective of the distutils injection strategy.)
setuptools will be the canonical implementation of "distutils" in the future. Some of the distutils hierarchy already is duplicated in setuptools (like commands), the parts that are likely to remain supported will likely move into the setuptools (I suspect that will include things like exceptions) namespace, and some stuff that is no longer necessary will be deprecated and removed.
If you need something from the distutils namespace and it's not available in setuptools, continue to use it until we provide an alternative (I would say "raise an issue" but I am not sure if we're going to just do a bulk migration or not), but if there's already an equivalent in setuptools, switching over to using setuptools now is the best thing you can do (and you should report any issues you encounter when doing this).
... setuptools is not exposing its version of distutils as setuptools.distutils (and to the extent that it exists under the setuptools namespace, that location is not necessarily stable). setuptools replaces the top-level distutils module with its own version of distutils, so import distutils pulls the version from setuptools.
This is one phase of an ongoing project to remove distutils from the standard library (and probably eventually retire the project entirely in favor of setuptools).
Here's where we're using disutils:
| File |
Use |
Replacement |
Tests/test_image_access.py and setup.py |
from distutils import ccompiler, sysconfig |
#4809, #4814, #4817 |
Tests/test_imagefont.py |
distutils.version.StrictVersion |
packaging.version.parse #4797 |
setup.py |
from distutils.command.build_ext import build_ext |
from setuptools.command.build_ext import build_ext #4829 |
setup.py |
from distutils import cygwinccompiler |
#4890 |
There's an effort underway to move the functionality of distutils into Setuptools and other libraries, with a goal to remove distutils from the standard library.
Re:
Here's where we're using disutils:
Tests/test_image_access.pyandsetup.pyfrom distutils import ccompiler, sysconfigTests/test_imagefont.pydistutils.version.StrictVersionpackaging.version.parse#4797setup.pyfrom distutils.command.build_ext import build_extfrom setuptools.command.build_ext import build_ext#4829setup.pyfrom distutils import cygwinccompiler