From 26ad5b9429c5c24c5d7244b4bc43e4447426e958 Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Wed, 27 Jan 2021 20:53:07 +0000 Subject: [PATCH 1/3] bpo-41282: Add deprecation warning and docs for distutils --- Doc/distutils/index.rst | 7 +++++++ Doc/install/index.rst | 7 +++++++ Doc/library/distutils.rst | 5 +++++ Doc/whatsnew/3.10.rst | 16 ++++++++++++++++ Lib/distutils/__init__.py | 5 +++++ .../2021-01-27-20-49-32.bpo-41282.SEPdV0.rst | 1 + 6 files changed, 41 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2021-01-27-20-49-32.bpo-41282.SEPdV0.rst diff --git a/Doc/distutils/index.rst b/Doc/distutils/index.rst index 1f72a25542494a..39272f5cada592 100644 --- a/Doc/distutils/index.rst +++ b/Doc/distutils/index.rst @@ -12,6 +12,13 @@ :ref:`distributing-index` The up to date module distribution documentations +.. note:: + + The ``distutils`` namespace has been deprecated and will be removed in + Python 3.12. This documentation is retained as a reference only, and + will be removed with the package. See the + :ref:`What's New ` entry for more information. + .. include:: ./_setuptools_disclaimer.rst .. note:: diff --git a/Doc/install/index.rst b/Doc/install/index.rst index e6d5a3e6ebde60..97d972bb6aee01 100644 --- a/Doc/install/index.rst +++ b/Doc/install/index.rst @@ -10,6 +10,13 @@ .. TODO: Fill in XXX comments +.. note:: + + The ``distutils`` namespace has been deprecated and will be removed in + Python 3.12. This documentation is retained as a reference only, and + will be removed with the package. See the + :ref:`What's New ` entry for more information. + .. seealso:: :ref:`installing-index` diff --git a/Doc/library/distutils.rst b/Doc/library/distutils.rst index 62abc85ac397a4..31c4ae5b23906b 100644 --- a/Doc/library/distutils.rst +++ b/Doc/library/distutils.rst @@ -9,6 +9,11 @@ -------------- +:mod:`distutils` is deprecated with removal planned for Python 3.12. +See the :ref:`What's New ` entry for more information. + +-------------- + The :mod:`distutils` package provides support for building and installing additional modules into a Python installation. The new modules may be either 100%-pure Python, or may be extension modules written in C, or may be diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst index 16bb8fb28178ab..2bdf2a170f5f17 100644 --- a/Doc/whatsnew/3.10.rst +++ b/Doc/whatsnew/3.10.rst @@ -341,9 +341,21 @@ The ``BUTTON5_*`` constants are now exposed in the :mod:`curses` module if they are provided by the underlying curses library. (Contributed by Zackery Spytz in :issue:`39273`.) +.. _distutils-deprecated: + distutils --------- +The entire ``distutils`` namespace is deprecated, to be removed in Python +3.12. Its functionality for specifying package builds has already been +completely replaced by third-party packages ``setuptools`` and +``packaging``, and most other commonly used APIs are available elsewhere +in the standard library (such as :mod:`platform`, :mod:`shutil`, +:mod:`subprocess` or :mod:`sysconfig`). There are no plans to migrate +any other functionality from ``distutils``, and applications that are +using other functions should plan to make private copies of the code. +Refer to :pep:`632` for discussion. + The ``bdist_wininst`` command deprecated in Python 3.8 has been removed. The ``bdist_wheel`` command is now recommended to distribute binary packages on Windows. @@ -583,6 +595,10 @@ Deprecated as appropriate to help identify code which needs updating during this transition. +* The entire ``distutils`` namespace is deprecated, to be removed in + Python 3.12. Refer to the :ref:`module changes ` + section for more information. + * Non-integer arguments to :func:`random.randrange` are deprecated. The :exc:`ValueError` is deprecated in favor of a :exc:`TypeError`. (Contributed by Serhiy Storchaka and Raymond Hettinger in :issue:`37319`.) diff --git a/Lib/distutils/__init__.py b/Lib/distutils/__init__.py index d823d040a1c1e6..3a8c0ac1508327 100644 --- a/Lib/distutils/__init__.py +++ b/Lib/distutils/__init__.py @@ -9,5 +9,10 @@ """ import sys +import warnings __version__ = sys.version[:sys.version.index(' ')] + +warnings.warn("distutils is deprecated and slated for removal in " + "Python 3.12. Use setuptools or try PEP 632 for " + "potential alternatives", DeprecationWarning) diff --git a/Misc/NEWS.d/next/Library/2021-01-27-20-49-32.bpo-41282.SEPdV0.rst b/Misc/NEWS.d/next/Library/2021-01-27-20-49-32.bpo-41282.SEPdV0.rst new file mode 100644 index 00000000000000..c7b6b5233e8f21 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2021-01-27-20-49-32.bpo-41282.SEPdV0.rst @@ -0,0 +1 @@ +Deprecate ``distutils`` in documentation and add warning on import. From 6a6a40d98e02bd5e71e263292f7a4b5efb34979a Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Wed, 27 Jan 2021 22:54:34 +0000 Subject: [PATCH 2/3] Update warning to satisfy tests --- Lib/distutils/__init__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Lib/distutils/__init__.py b/Lib/distutils/__init__.py index 3a8c0ac1508327..5ddb95923809c9 100644 --- a/Lib/distutils/__init__.py +++ b/Lib/distutils/__init__.py @@ -13,6 +13,7 @@ __version__ = sys.version[:sys.version.index(' ')] -warnings.warn("distutils is deprecated and slated for removal in " - "Python 3.12. Use setuptools or try PEP 632 for " - "potential alternatives", DeprecationWarning) +warnings.warn("The distutils package deprecated and slated for " + "removal in Python 3.12. Use setuptools or check " + "PEP 632 for potential alternatives", + DeprecationWarning) From d3af18979f941cf9486603cf7d7a660c3d2ee2de Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Fri, 29 Jan 2021 20:44:50 +0000 Subject: [PATCH 3/3] Improve wording of deprecation notes in docs --- Doc/distutils/index.rst | 6 +++--- Doc/install/index.rst | 6 +++--- Doc/whatsnew/3.10.rst | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Doc/distutils/index.rst b/Doc/distutils/index.rst index 39272f5cada592..2ccddc38b5f26f 100644 --- a/Doc/distutils/index.rst +++ b/Doc/distutils/index.rst @@ -14,9 +14,9 @@ .. note:: - The ``distutils`` namespace has been deprecated and will be removed in - Python 3.12. This documentation is retained as a reference only, and - will be removed with the package. See the + The entire ``distutils`` package has been deprecated and will be + removed in Python 3.12. This documentation is retained as a + reference only, and will be removed with the package. See the :ref:`What's New ` entry for more information. .. include:: ./_setuptools_disclaimer.rst diff --git a/Doc/install/index.rst b/Doc/install/index.rst index 97d972bb6aee01..b6b7085fb35aa9 100644 --- a/Doc/install/index.rst +++ b/Doc/install/index.rst @@ -12,9 +12,9 @@ .. note:: - The ``distutils`` namespace has been deprecated and will be removed in - Python 3.12. This documentation is retained as a reference only, and - will be removed with the package. See the + The entire ``distutils`` package has been deprecated and will be + removed in Python 3.12. This documentation is retained as a + reference only, and will be removed with the package. See the :ref:`What's New ` entry for more information. .. seealso:: diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst index 2bdf2a170f5f17..cf7d1e80758a07 100644 --- a/Doc/whatsnew/3.10.rst +++ b/Doc/whatsnew/3.10.rst @@ -346,7 +346,7 @@ they are provided by the underlying curses library. distutils --------- -The entire ``distutils`` namespace is deprecated, to be removed in Python +The entire ``distutils`` package is deprecated, to be removed in Python 3.12. Its functionality for specifying package builds has already been completely replaced by third-party packages ``setuptools`` and ``packaging``, and most other commonly used APIs are available elsewhere