Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PEP 632: Remove the distutils package (Python 3.12) #92584

Closed
vstinner opened this issue May 9, 2022 · 44 comments
Closed

PEP 632: Remove the distutils package (Python 3.12) #92584

vstinner opened this issue May 9, 2022 · 44 comments
Labels
3.12 bugs and security fixes type-bug An unexpected behavior, bug, or error

Comments

@vstinner
Copy link
Member

vstinner commented May 9, 2022

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.

@vstinner vstinner added the type-bug An unexpected behavior, bug, or error label May 9, 2022
@vstinner vstinner changed the title Remove the distutils package to _distutils Rename the distutils package to _distutils May 9, 2022
@vstinner
Copy link
Member Author

vstinner commented May 9, 2022

Right now, test_venv fails without distutils, because pip fails on importing the distutils module in pip/_internal/locations/_distutils.py

I reported this issue to pip: pypa/pip#11103

@vstinner
Copy link
Member Author

vstinner commented May 9, 2022

The distutils package was deprecated by the issue #85454.

@vstinner vstinner changed the title Rename the distutils package to _distutils PEP 632: Rename the distutils package to _distutils May 10, 2022
@vstinner
Copy link
Member Author

PEP 632 "Deprecate distutils module": https://peps.python.org/pep-0632/

@FFY00
Copy link
Member

FFY00 commented May 10, 2022

That seems like a good plan. Thanks.

@jaraco
Copy link
Member

jaraco commented 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
Copy link
Member Author

Why not address the dependencies and fully remove the functionality?

Someone has to modify Python to no longer depend on distutils. The issue description lists code using it. It doesn't seem trivial.

@FFY00
Copy link
Member

FFY00 commented 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
Copy link
Member Author

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?

With my PR, the Lib/_distutils/ directory is not installed by make install.

@jkloth
Copy link
Contributor

jkloth commented 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 _distutils is not available.

@vstinner
Copy link
Member Author

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 _distutils is not available.

I propose skipping tests relying on _distutils if _distutils is not available.

@vstinner
Copy link
Member Author

I wrote two PRs to avoid the deprecated distutils module in two tests:

vstinner added a commit that referenced this issue May 10, 2022
test_decimal now uses shutil.which() rather than deprecated
distutils.spawn.find_executable().
vstinner added a commit that referenced this issue May 12, 2022
Rewrite test_cppext to run in a virtual environment and to build the
C++ extension with setuptools rather than distutils.
@AbhigyanBose
Copy link
Contributor

AbhigyanBose commented May 15, 2022

Hi @vstinner

I think #92639 is causing a test failure, details here #92820

PS: Commented here as I thought those changes are related to this PEP.

@encukou
Copy link
Member

encukou commented Jun 23, 2022

Marking as 3.12.0a1 release blocker. We want to have public-facing distutils gone in the first alpha, to have as much time as possible to deal with the fallout.

@pablogsal pablogsal added the 3.12 bugs and security fixes label Jun 23, 2022
@vstinner vstinner changed the title PEP 632: Rename the distutils package to _distutils PEP 632: Rename the distutils package to _distutils (Python 3.12) Jul 7, 2022
@tiran
Copy link
Member

tiran commented Jul 7, 2022

Actually we can get rid of distutils entirely. I have a working PR that gets rid of our setup.py and builds all extension modules with configure and make.

@pradyunsg
Copy link
Member

For the curious, the PR that @tiran is refering to is #94474

tiran added a commit to tiran/cpython that referenced this issue Aug 5, 2022
`make test_cppmods` compiles C++ test extension modules.
Yhg1s pushed a commit that referenced this issue Aug 16, 2023
…H-108031) (#108039)

GH-92584: Drop reference to Distutils in ``site.USER_BASE`` (GH-108031)

Drop reference to Distutils in ``site.USER_BASE``
(cherry picked from commit f2a9dfd)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Yhg1s pushed a commit that referenced this issue Aug 16, 2023
…cription (GH-108047) (#108057)

GH-92584: Remove reference to Distutils in ``cx_Freeze``'s description (GH-108047)

Remove reference to Distutils in ``cx_Freeze``'s description
(cherry picked from commit 57fcf96)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Yhg1s pushed a commit that referenced this issue Aug 16, 2023
…GH-108040) (#108060)

GH-92584: Remove references to Distutils in ``PYTHONUSERBASE`` (GH-108040)

Remove references to Distutils in ``PYTHONUSERBASE``
(cherry picked from commit 636ca31)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Yhg1s pushed a commit that referenced this issue Aug 16, 2023
…108044) (#108058)

GH-92584: Redirect macOS package installation to the PPUG (GH-108044)
(cherry picked from commit 9028642)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Yhg1s pushed a commit that referenced this issue Aug 16, 2023
…108043) (#108063)

GH-92584: Remove references to Distutils in configure.rst (GH-108043)

Remove references to Distutils in configure.rst
(cherry picked from commit e88eb37)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Yhg1s pushed a commit that referenced this issue Aug 17, 2023
…GH-108020) (#108062)

* [3.12] GH-92584: Remove Installing Python Modules (Distutils version) (GH-108020).
(cherry picked from commit fbb7cbc)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Aug 22, 2023
…ythonGH-108024)

(cherry picked from commit e97b7be)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Yhg1s pushed a commit that referenced this issue Aug 22, 2023
…GH-108024) (#108333)

GH-92584: Remove distutils from the newtypes tutorial includes (GH-108024)
(cherry picked from commit e97b7be)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
ppigazzini added a commit to ppigazzini/fishtest that referenced this issue Aug 28, 2023
The package `distutils` is deprecated since python 3.10
and it is scheduled to be removed with python 3.12, see:
https://docs.python.org/3.12/whatsnew/3.12.html
python/cpython#92584

`shutil.copytree()` is able to copy the source directory tree to an existing
destination directory only from python 3.8 (parameter `dirs_exist_ok=True`),
for python < 3.8 still use `distutils.dir_util.copy_tree()`
ppigazzini added a commit to ppigazzini/fishtest that referenced this issue Aug 28, 2023
The package `distutils` is deprecated since python 3.10
and it is scheduled to be removed with python 3.12, see:
https://docs.python.org/3.12/whatsnew/3.12.html
python/cpython#92584

`shutil.copytree()` is able to copy the source directory tree to an existing
destination directory only from python 3.8 (parameter `dirs_exist_ok=True`),
for python < 3.8 still use `distutils.dir_util.copy_tree()`

Raise worker version to 214 (also server side)
ppigazzini added a commit to ppigazzini/fishtest that referenced this issue Aug 28, 2023
The package `distutils` is deprecated since python 3.10
and it is scheduled to be removed with python 3.12, see:
https://docs.python.org/3.12/whatsnew/3.12.html
python/cpython#92584

`shutil.copytree()` is able to copy the source directory tree to an existing
destination directory only from python 3.8 (parameter `dirs_exist_ok=True`),
for python < 3.8 still use `distutils.dir_util.copy_tree()`

While here:
- create in a safe way the temporary directory used for the update
- deal with possible download problems

Raise worker version to 214 (also server side)
ppigazzini added a commit to ppigazzini/fishtest that referenced this issue Aug 28, 2023
The package `distutils` is deprecated since python 3.10
and it is scheduled to be removed with python 3.12, see:
https://docs.python.org/3.12/whatsnew/3.12.html
python/cpython#92584

`shutil.copytree()` is able to copy the source directory tree to an existing
destination directory only from python 3.8 (parameter `dirs_exist_ok=True`),
for python < 3.8 still use `distutils.dir_util.copy_tree()`

While here:
- create in a safe way the temporary directory used for the update
- deal with possible download problems

Raise worker version to 214 (also server side)
ppigazzini added a commit to ppigazzini/fishtest that referenced this issue Aug 28, 2023
The package `distutils` is deprecated since python 3.10
and it is scheduled to be removed with python 3.12, see:
https://docs.python.org/3.12/whatsnew/3.12.html
python/cpython#92584

`shutil.copytree()` is able to copy the source directory tree to an existing
destination directory only from python 3.8 (parameter `dirs_exist_ok=True`),
for python < 3.8 still use `distutils.dir_util.copy_tree()`

While here:
- create in a safe way the temporary directory used for the update
- deal with possible download problems

Raise worker version to 214 (also server side)
ppigazzini added a commit to official-stockfish/fishtest that referenced this issue Aug 28, 2023
The package `distutils` is deprecated since python 3.10
and it is scheduled to be removed with python 3.12, see:
https://docs.python.org/3.12/whatsnew/3.12.html
python/cpython#92584

`shutil.copytree()` is able to copy the source directory tree to an existing
destination directory only from python 3.8 (parameter `dirs_exist_ok=True`),
for python < 3.8 still use `distutils.dir_util.copy_tree()`

While here:
- create in a safe way the temporary directory used for the update
- deal with possible download problems

Raise worker version to 214 (also server side)
Yhg1s pushed a commit that referenced this issue Oct 2, 2023
* Add new installation path functions subsection

* Add content from install/index to sysconfig

* Fix table

* Update note about installers

* Clean up the list of schemes, remove references to Distutils
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Oct 2, 2023
…ythonGH-108018)

* Add new installation path functions subsection

* Add content from install/index to sysconfig

* Fix table

* Update note about installers

* Clean up the list of schemes, remove references to Distutils
(cherry picked from commit f16e81f)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
AA-Turner added a commit to AA-Turner/cpython that referenced this issue Oct 2, 2023
…g docs (pythonGH-108018)

* Add new installation path functions subsection

* Add content from install/index to sysconfig

* Fix table

* Update note about installers

* Clean up the list of schemes, remove references to Distutils.
(cherry picked from commit f16e81f)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Yhg1s pushed a commit that referenced this issue Oct 2, 2023
…GH-108018) (#110213)

GH-92584: Move installation schemes overview to sysconfig docs (GH-108018)

* Add new installation path functions subsection

* Add content from install/index to sysconfig

* Fix table

* Update note about installers

* Clean up the list of schemes, remove references to Distutils
(cherry picked from commit f16e81f)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
AA-Turner added a commit that referenced this issue Jan 11, 2024
…GH-108018) (#110214)

* Add new installation path functions subsection

* Add content from install/index to sysconfig

* Fix table

* Update note about installers

* Clean up the list of schemes, remove references to Distutils.
(cherry picked from commit f16e81f)
Glyphack pushed a commit to Glyphack/cpython that referenced this issue Sep 2, 2024
…ython#108018)

* Add new installation path functions subsection

* Add content from install/index to sysconfig

* Fix table

* Update note about installers

* Clean up the list of schemes, remove references to Distutils
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.12 bugs and security fixes type-bug An unexpected behavior, bug, or error
Projects
Development

No branches or pull requests