Repository navigation
PEP 632: Remove the distutils package (Python 3.12) #92584
Copy link
Copy link
Closed
Labels
3.12only security fixesonly security fixestype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
The distutils module was deprecated in Python 3.10 and is scheduled for removal in Python 3.12.
Right now, Python still uses distutils for different purpose:
- Build C extensions which can not be built by Makefile yet. Python 3.11 can build way more C extensions with Makefile than Python 3.10.
- peg_generator uses distutils to build C extensions.
- test_cppext uses distutils to check that the Python C API can be used in C++.
Tools/c-analyzer/uses distutils to get a C preprocessor.
Until Python can be built and used without distutils, I propose to first rename the distutils package to _distutils: rename th Lib/distutils/ directory to Lib/_distutils/.
Right now, test_venv fails without distutils, because pip fails on importing the distutils module in pip/_internal/locations/_distutils.py: https://github.com/pypa/pip/blob/cb24fb4052ca8ab8009866b0de61980c81a7e13c/src/pip/_internal/locations/_distutils.py#L9-L12
I created the PR #92585 which renames distutils to _distutils.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
3.12only security fixesonly security fixestype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Projects
- StatusShow more project fieldsDone
Activity
[-]Remove the distutils package to _distutils[/-][+]Rename the distutils package to _distutils[/+]vstinner commentedon May 9, 2022
I reported this issue to pip: pypa/pip#11103
vstinner commentedon May 9, 2022
The distutils package was deprecated by the issue #85454.
[-]Rename the distutils package to _distutils[/-][+]PEP 632: Rename the distutils package to _distutils[/+]vstinner commentedon May 10, 2022
PEP 632 "Deprecate distutils module": https://peps.python.org/pep-0632/
FFY00 commentedon May 10, 2022
That seems like a good plan. Thanks.
jaraco commentedon May 10, 2022
My fear with renaming it is that it lingers indefinitely, and diverging in subtle ways from pypa/distutils. Why not address the dependencies and fully remove the functionality?
Regardless, I agree renaming is preferable to not removing the module at all.
vstinner commentedon May 10, 2022
Someone has to modify Python to no longer depend on distutils. The issue description lists code using it. It doesn't seem trivial.
FFY00 commentedon May 10, 2022
Would it be reasonable to keep it around in the repo while we don't drop the dependency but not ship it as part of Python installations?
vstinner commentedon May 10, 2022
With my PR, the
Lib/_distutils/directory is not installed bymake install.jkloth commentedon May 10, 2022
Do note that we have buildbots that run from an installed Python. The tests would need to also be modified to fail gracefully
(or skip) when
_distutilsis not available.vstinner commentedon May 10, 2022
I propose skipping tests relying on _distutils if _distutils is not available.
vstinner commentedon May 10, 2022
I wrote two PRs to avoid the deprecated distutils module in two tests:
gh-92584: test_decimal uses shutil.which() (#92640)
75 remaining items
GH-92584: Remove distutils from the newtypes tutorial includes (#108024)
pythonGH-92584: Remove distutils from the newtypes tutorial includes (p…
[3.12] GH-92584: Remove distutils from the newtypes tutorial includes (…
Replace deprecated `distutils` package
Replace deprecated `distutils` package
Replace deprecated `distutils` package
Replace deprecated `distutils` package
Replace deprecated `distutils` package
Replace deprecated `distutils` package
GH-92584: Move installation schemes overview to sysconfig docs (#108018)
pythonGH-92584: Move installation schemes overview to sysconfig docs (p…
[3.11] pythonGH-92584: Move installation schemes overview to sysconfi…
[3.12] GH-92584: Move installation schemes overview to sysconfig docs (…
[3.11] GH-92584: Move installation schemes overview to sysconfig docs (…
pythonGH-92584: Move installation schemes overview to sysconfig docs (p…