File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change 12
12
import warnings
13
13
14
14
15
+ is_pypy = '__pypy__' in sys .builtin_module_names
16
+
17
+
18
+ def warn_distutils_present ():
19
+ if 'distutils' not in sys .modules :
20
+ return
21
+ if is_pypy and sys .version_info < (3 , 7 ):
22
+ # PyPy for 3.6 unconditionally imports distutils, so bypass the warning
23
+ # https://foss.heptapod.net/pypy/pypy/-/blob/be829135bc0d758997b3566062999ee8b23872b4/lib-python/3/site.py#L250
24
+ return
25
+ warnings .warn (
26
+ "Distutils was imported before Setuptools. This usage is discouraged "
27
+ "and may exhibit undesirable behaviors or errors. Please use "
28
+ "Setuptools' objects directly or at least import Setuptools first." )
29
+
30
+
15
31
def clear_distutils ():
16
32
if 'distutils' not in sys .modules :
17
33
return
18
- warnings .warn ("Setuptools is replacing distutils" )
34
+ warnings .warn ("Setuptools is replacing distutils. " )
19
35
mods = [name for name in sys .modules if re .match (r'distutils\b' , name )]
20
36
for name in mods :
21
37
del sys .modules [name ]
@@ -40,5 +56,6 @@ def ensure_local_distutils():
40
56
assert '_distutils' in core .__file__ , core .__file__
41
57
42
58
59
+ warn_distutils_present ()
43
60
if enabled ():
44
61
ensure_local_distutils ()
You can’t perform that action at this time.
0 commit comments