diff options
| author | Jason R. Coombs <jaraco@jaraco.com> | 2020-07-11 02:16:44 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-11 02:16:44 -0400 |
| commit | dc4fcfd23750e28a02123eb50e174f430c2e6234 (patch) | |
| tree | 866cc2ddac5a86e0686e62195c22fbaaeb1e98ec | |
| parent | cd8ac41d2f40de096251b78a55a74b2705a7af8f (diff) | |
| parent | bedaf1309d2633831a7fb7dea561642e7da704df (diff) | |
| download | python-setuptools-git-dc4fcfd23750e28a02123eb50e174f430c2e6234.tar.gz | |
Merge pull request #2247 from pypa/distutils-adopt-escape-hatch
Re-enable distutils adoption with escape hatch
| -rw-r--r-- | changelog.d/2232.misc.patch | 1 | ||||
| -rw-r--r-- | setuptools/__init__.py | 2 | ||||
| -rw-r--r-- | setuptools/distutils_patch.py | 12 |
3 files changed, 13 insertions, 2 deletions
diff --git a/changelog.d/2232.misc.patch b/changelog.d/2232.misc.patch new file mode 100644 index 00000000..4a956e1e --- /dev/null +++ b/changelog.d/2232.misc.patch @@ -0,0 +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. diff --git a/setuptools/__init__.py b/setuptools/__init__.py index a6cbe132..83882511 100644 --- a/setuptools/__init__.py +++ b/setuptools/__init__.py @@ -4,7 +4,7 @@ import os import functools # Disabled for now due to: #2228, #2230 -# import setuptools.distutils_patch # noqa: F401 +import setuptools.distutils_patch # noqa: F401 import distutils.core import distutils.filelist diff --git a/setuptools/distutils_patch.py b/setuptools/distutils_patch.py index b2095fba..c5f273dd 100644 --- a/setuptools/distutils_patch.py +++ b/setuptools/distutils_patch.py @@ -7,6 +7,7 @@ for more motivation. import sys import re +import os import importlib import warnings @@ -20,6 +21,14 @@ def clear_distutils(): del sys.modules[name] +def enabled(): + """ + Allow selection of distutils by environment variable. + """ + which = os.environ.get('SETUPTOOLS_USE_DISTUTILS', 'stdlib') + return which == 'local' + + def ensure_local_distutils(): clear_distutils() distutils = importlib.import_module('setuptools._distutils') @@ -31,4 +40,5 @@ def ensure_local_distutils(): assert '_distutils' in core.__file__, core.__file__ -ensure_local_distutils() +if enabled(): + ensure_local_distutils() |
