From 38f656064bc7ebb81d5b58b98dd62013ee9cb0f6 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 24 Nov 2023 14:25:07 -0500 Subject: [PATCH 1/7] Add warning when SETUPTOOLS_USE_DISTUTILS=stdlib. Ref #4137. --- _distutils_hack/__init__.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/_distutils_hack/__init__.py b/_distutils_hack/__init__.py index b951c2defd..0b47d17435 100644 --- a/_distutils_hack/__init__.py +++ b/_distutils_hack/__init__.py @@ -45,6 +45,15 @@ def enabled(): Allow selection of distutils by environment variable. """ which = os.environ.get('SETUPTOOLS_USE_DISTUTILS', 'local') + if which == 'stdlib': + import warnings + + warnings.warn( + "Reliance on distutils from stdlib is deprecated. Users " + "must rely on setuptools to provide the distutils module. " + "Avoid importing distutils or import setuptools first, " + "and avoid setting SETUPTOOLS_USE_DISTUTILS=stdlib." + ) return which == 'local' From 2832216ada28985a9a972be9c7e8adf93e724a3b Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 24 Nov 2023 14:44:38 -0500 Subject: [PATCH 2/7] Announce the deprecation of imported distutils from stdlib. Ref #4137. --- _distutils_hack/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/_distutils_hack/__init__.py b/_distutils_hack/__init__.py index 0b47d17435..b8322fc182 100644 --- a/_distutils_hack/__init__.py +++ b/_distutils_hack/__init__.py @@ -30,7 +30,11 @@ def clear_distutils(): return import warnings - warnings.warn("Setuptools is replacing distutils.") + warnings.warn( + "Setuptools is replacing distutils. Support for replacing " + "an already imported distutils is deprecated. In the future, " + "this condition will fail.", + ) mods = [ name for name in sys.modules From ac4f52ad8c34613bd82579bd3a3b38d57914bda9 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 1 Jun 2024 05:02:27 -0400 Subject: [PATCH 3/7] Suppress deprecation warning about stdlib distutils being deprecated. --- pytest.ini | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pytest.ini b/pytest.ini index 57ab865366..e49b81561a 100644 --- a/pytest.ini +++ b/pytest.ini @@ -73,6 +73,9 @@ filterwarnings= # suppress warnings in deprecated msvc compilers ignore:(bcpp|msvc9?)compiler is deprecated + # Ignore warnings about deprecated stdlib distutils pypa/setuptools#4137 + ignore:Reliance on distutils from stdlib is deprecated + ignore::setuptools.command.editable_wheel.InformationOnly # https://github.com/pypa/setuptools/issues/3655 From dc90abca19072da5807ba57c2077e00f6e47fb8c Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 1 Jun 2024 05:06:52 -0400 Subject: [PATCH 4/7] Add news fragment. --- newsfragments/4137.feature.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 newsfragments/4137.feature.rst diff --git a/newsfragments/4137.feature.rst b/newsfragments/4137.feature.rst new file mode 100644 index 0000000000..89ca0cb758 --- /dev/null +++ b/newsfragments/4137.feature.rst @@ -0,0 +1 @@ +Support for loading distutils from the standard library is now deprecated, including use of SETUPTOOLS_USE_DISTUTILS=stdlib and importing distutils before importing setuptools. \ No newline at end of file From bd1d338614fa1ab7e424fb4ceb6d41927dfaeb33 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 2 Jul 2024 12:26:26 -0400 Subject: [PATCH 5/7] Add issue template for distutils deprecation reports. --- .../ISSUE_TEMPLATE/distutils-deprecation.yaml | 103 ++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/distutils-deprecation.yaml diff --git a/.github/ISSUE_TEMPLATE/distutils-deprecation.yaml b/.github/ISSUE_TEMPLATE/distutils-deprecation.yaml new file mode 100644 index 0000000000..7ac1f8bbb9 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/distutils-deprecation.yaml @@ -0,0 +1,103 @@ +--- +name: 📇 Distutils Deprecation Report +description: >- + Report a use-case affected by the deprecation of distutils +labels: +- distutils deprecation +- Needs Triage +projects: +- pypa/6 +body: +- type: markdown + attributes: + value: > + So you've encountered an issue with the deprecation of distutils. + + First, sorry for the inconvenience while we work to untangle the + legacy which is setuptools/distutils. Our goal is to ensure that + the vast majority of use cases are satisfied prior to removing + the legacy support. + + Please check the + [existing reports](https://github.com/pypa/setuptools/issues?q=label%3A%22distutils+deprecation%22+) + to see if the affecting condition has been reported previously. + +- type: markdown + attributes: + value: >- + **Environment** +- type: input + attributes: + label: setuptools version + placeholder: For example, setuptools==69.1.0 + description: >- + Please also test with the **latest version** of `setuptools`. + + Typically, this involves modifying `requires` in `[build-system]` of + [`pyproject.toml`](https://setuptools.pypa.io/en/latest/userguide/quickstart.html#basic-use), + not just updating `setuptools` using `pip`. + validations: + required: true +- type: input + attributes: + label: Python version + placeholder: For example, Python 3.10 + description: >- + Please ensure you are using a [supported version of Python](https://devguide.python.org/versions/#supported-versions). + + Setuptools does not support versions that have reached [`end-of-life`](https://devguide.python.org/versions/#unsupported-versions). + + Support for versions of Python under development (i.e. without a stable release) is experimental. + validations: + required: true +- type: input + attributes: + label: OS + placeholder: For example, Gentoo Linux, RHEL 8, Arch Linux, macOS etc. + validations: + required: true +- type: textarea + attributes: + label: Additional environment information + description: >- + Feel free to add more information about your environment here. + placeholder: >- + This is only happening when I run setuptools on my fridge's patched firmware 🤯 + +- type: textarea + attributes: + label: Description + description: >- + A clear and concise description of the circumstances leading to the warning. + validations: + required: true + +- type: textarea + attributes: + label: How to Reproduce + description: >- + Describe the steps to reproduce the warning. + + Please try to create a [minimal reproducer](https://stackoverflow.com/help/minimal-reproducible-example), + and avoid things like "see the steps in the CI logs". + placeholder: | + 1. Clone a simplified example: `git clone ...` + 2. Create a virtual environment for isolation with `...` + 2. Build the project with setuptools via '...' + 2. Then run '...' + 3. An error occurs. + validations: + required: true + +- type: textarea + attributes: + label: Other detail + description: >- + Paste the output of the steps above, including the commands + themselves and setuptools' output/traceback etc. + value: | + ```console + + ``` + +... From ef37d17fa7de624cc6e89491827e14ed5db9d023 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 2 Jul 2024 12:32:34 -0400 Subject: [PATCH 6/7] In the warnings, provide link to issue template. --- _distutils_hack/__init__.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/_distutils_hack/__init__.py b/_distutils_hack/__init__.py index 881090d590..1e688f1738 100644 --- a/_distutils_hack/__init__.py +++ b/_distutils_hack/__init__.py @@ -3,6 +3,12 @@ import os +report_url = ( + "https://github.com/pypa/setuptools/issues/new?" + "template=distutils-deprecation.yaml" +) + + def warn_distutils_present(): if 'distutils' not in sys.modules: return @@ -26,7 +32,8 @@ def clear_distutils(): warnings.warn( "Setuptools is replacing distutils. Support for replacing " "an already imported distutils is deprecated. In the future, " - "this condition will fail.", + "this condition will fail. " + f"Register concerns at {report_url}" ) mods = [ name @@ -49,7 +56,8 @@ def enabled(): "Reliance on distutils from stdlib is deprecated. Users " "must rely on setuptools to provide the distutils module. " "Avoid importing distutils or import setuptools first, " - "and avoid setting SETUPTOOLS_USE_DISTUTILS=stdlib." + "and avoid setting SETUPTOOLS_USE_DISTUTILS=stdlib. " + f"Register concerns at {report_url}" ) return which == 'local' From 70cda3d1e8bb8a9602256f235c9a023934dd6065 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 2 Jul 2024 12:33:18 -0400 Subject: [PATCH 7/7] Use '.yml' for consistency. --- .../{distutils-deprecation.yaml => distutils-deprecation.yml} | 0 _distutils_hack/__init__.py | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename .github/ISSUE_TEMPLATE/{distutils-deprecation.yaml => distutils-deprecation.yml} (100%) diff --git a/.github/ISSUE_TEMPLATE/distutils-deprecation.yaml b/.github/ISSUE_TEMPLATE/distutils-deprecation.yml similarity index 100% rename from .github/ISSUE_TEMPLATE/distutils-deprecation.yaml rename to .github/ISSUE_TEMPLATE/distutils-deprecation.yml diff --git a/_distutils_hack/__init__.py b/_distutils_hack/__init__.py index 1e688f1738..35ab5cad49 100644 --- a/_distutils_hack/__init__.py +++ b/_distutils_hack/__init__.py @@ -5,7 +5,7 @@ report_url = ( "https://github.com/pypa/setuptools/issues/new?" - "template=distutils-deprecation.yaml" + "template=distutils-deprecation.yml" )