Skip to content

Commit 34f9518

Browse files
authored
Merge pull request #4410 from pypa/debt/4137-deprecate-distutils-stdlib
Deprecate distutils from the stdlib
2 parents e9f0be9 + 70cda3d commit 34f9518

File tree

4 files changed

+129
-1
lines changed

4 files changed

+129
-1
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
---
2+
name: 📇 Distutils Deprecation Report
3+
description: >-
4+
Report a use-case affected by the deprecation of distutils
5+
labels:
6+
- distutils deprecation
7+
- Needs Triage
8+
projects:
9+
- pypa/6
10+
body:
11+
- type: markdown
12+
attributes:
13+
value: >
14+
So you've encountered an issue with the deprecation of distutils.
15+
16+
First, sorry for the inconvenience while we work to untangle the
17+
legacy which is setuptools/distutils. Our goal is to ensure that
18+
the vast majority of use cases are satisfied prior to removing
19+
the legacy support.
20+
21+
Please check the
22+
[existing reports](https://github.com/pypa/setuptools/issues?q=label%3A%22distutils+deprecation%22+)
23+
to see if the affecting condition has been reported previously.
24+
25+
- type: markdown
26+
attributes:
27+
value: >-
28+
**Environment**
29+
- type: input
30+
attributes:
31+
label: setuptools version
32+
placeholder: For example, setuptools==69.1.0
33+
description: >-
34+
Please also test with the **latest version** of `setuptools`.
35+
36+
Typically, this involves modifying `requires` in `[build-system]` of
37+
[`pyproject.toml`](https://setuptools.pypa.io/en/latest/userguide/quickstart.html#basic-use),
38+
not just updating `setuptools` using `pip`.
39+
validations:
40+
required: true
41+
- type: input
42+
attributes:
43+
label: Python version
44+
placeholder: For example, Python 3.10
45+
description: >-
46+
Please ensure you are using a [supported version of Python](https://devguide.python.org/versions/#supported-versions).
47+
48+
Setuptools does not support versions that have reached [`end-of-life`](https://devguide.python.org/versions/#unsupported-versions).
49+
50+
Support for versions of Python under development (i.e. without a stable release) is experimental.
51+
validations:
52+
required: true
53+
- type: input
54+
attributes:
55+
label: OS
56+
placeholder: For example, Gentoo Linux, RHEL 8, Arch Linux, macOS etc.
57+
validations:
58+
required: true
59+
- type: textarea
60+
attributes:
61+
label: Additional environment information
62+
description: >-
63+
Feel free to add more information about your environment here.
64+
placeholder: >-
65+
This is only happening when I run setuptools on my fridge's patched firmware 🤯
66+
67+
- type: textarea
68+
attributes:
69+
label: Description
70+
description: >-
71+
A clear and concise description of the circumstances leading to the warning.
72+
validations:
73+
required: true
74+
75+
- type: textarea
76+
attributes:
77+
label: How to Reproduce
78+
description: >-
79+
Describe the steps to reproduce the warning.
80+
81+
Please try to create a [minimal reproducer](https://stackoverflow.com/help/minimal-reproducible-example),
82+
and avoid things like "see the steps in the CI logs".
83+
placeholder: |
84+
1. Clone a simplified example: `git clone ...`
85+
2. Create a virtual environment for isolation with `...`
86+
2. Build the project with setuptools via '...'
87+
2. Then run '...'
88+
3. An error occurs.
89+
validations:
90+
required: true
91+
92+
- type: textarea
93+
attributes:
94+
label: Other detail
95+
description: >-
96+
Paste the output of the steps above, including the commands
97+
themselves and setuptools' output/traceback etc.
98+
value: |
99+
```console
100+
101+
```
102+
103+
...

_distutils_hack/__init__.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
import os
44

55

6+
report_url = (
7+
"https://github.com/pypa/setuptools/issues/new?"
8+
"template=distutils-deprecation.yml"
9+
)
10+
11+
612
def warn_distutils_present():
713
if 'distutils' not in sys.modules:
814
return
@@ -23,7 +29,12 @@ def clear_distutils():
2329
return
2430
import warnings
2531

26-
warnings.warn("Setuptools is replacing distutils.")
32+
warnings.warn(
33+
"Setuptools is replacing distutils. Support for replacing "
34+
"an already imported distutils is deprecated. In the future, "
35+
"this condition will fail. "
36+
f"Register concerns at {report_url}"
37+
)
2738
mods = [
2839
name
2940
for name in sys.modules
@@ -38,6 +49,16 @@ def enabled():
3849
Allow selection of distutils by environment variable.
3950
"""
4051
which = os.environ.get('SETUPTOOLS_USE_DISTUTILS', 'local')
52+
if which == 'stdlib':
53+
import warnings
54+
55+
warnings.warn(
56+
"Reliance on distutils from stdlib is deprecated. Users "
57+
"must rely on setuptools to provide the distutils module. "
58+
"Avoid importing distutils or import setuptools first, "
59+
"and avoid setting SETUPTOOLS_USE_DISTUTILS=stdlib. "
60+
f"Register concerns at {report_url}"
61+
)
4162
return which == 'local'
4263

4364

newsfragments/4137.feature.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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.

pytest.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ filterwarnings=
7373
# suppress warnings in deprecated msvc compilers
7474
ignore:(bcpp|msvc9?)compiler is deprecated
7575

76+
# Ignore warnings about deprecated stdlib distutils pypa/setuptools#4137
77+
ignore:Reliance on distutils from stdlib is deprecated
78+
7679
ignore::setuptools.command.editable_wheel.InformationOnly
7780

7881
# https://github.com/pypa/setuptools/issues/3655

0 commit comments

Comments
 (0)