Skip to content

Commit dc4fcfd

Browse files
authored
Merge pull request #2247 from pypa/distutils-adopt-escape-hatch
Re-enable distutils adoption with escape hatch
2 parents cd8ac41 + bedaf13 commit dc4fcfd

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

changelog.d/2232.misc.patch

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
In preparation for re-enabling a local copy of distutils, Setuptools now honors an environment variable, SETUPTOOLS_USE_DISTUTILS. If set to 'stdlib' (current default), distutils will be used from the standard library. If set to 'local' (default in a imminent backward-incompatible release), the local copy of distutils will be used.

setuptools/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import functools
55

66
# Disabled for now due to: #2228, #2230
7-
# import setuptools.distutils_patch # noqa: F401
7+
import setuptools.distutils_patch # noqa: F401
88

99
import distutils.core
1010
import distutils.filelist

setuptools/distutils_patch.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import sys
99
import re
10+
import os
1011
import importlib
1112
import warnings
1213

@@ -20,6 +21,14 @@ def clear_distutils():
2021
del sys.modules[name]
2122

2223

24+
def enabled():
25+
"""
26+
Allow selection of distutils by environment variable.
27+
"""
28+
which = os.environ.get('SETUPTOOLS_USE_DISTUTILS', 'stdlib')
29+
return which == 'local'
30+
31+
2332
def ensure_local_distutils():
2433
clear_distutils()
2534
distutils = importlib.import_module('setuptools._distutils')
@@ -31,4 +40,5 @@ def ensure_local_distutils():
3140
assert '_distutils' in core.__file__, core.__file__
3241

3342

34-
ensure_local_distutils()
43+
if enabled():
44+
ensure_local_distutils()

0 commit comments

Comments
 (0)