summaryrefslogtreecommitdiff
path: root/setuptools/distutils_patch.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2020-07-03 05:05:29 -0400
committerGitHub <noreply@github.com>2020-07-03 05:05:29 -0400
commit2daf7f68fee8d5b62ee067143aa5bf1ece66c331 (patch)
tree4057aeefb3d919e8af7b4d9a8ccde3dde3fe8046 /setuptools/distutils_patch.py
parentc486771a15642d69622b9afeb9178450daf02e24 (diff)
parent97192962e89a24a02effd1f7a541108335517253 (diff)
downloadpython-setuptools-git-2daf7f68fee8d5b62ee067143aa5bf1ece66c331.tar.gz
Merge pull request #2226 from pypa/distutils-nested
Move distutils to setuptools._distutils
Diffstat (limited to 'setuptools/distutils_patch.py')
-rw-r--r--setuptools/distutils_patch.py22
1 files changed, 7 insertions, 15 deletions
diff --git a/setuptools/distutils_patch.py b/setuptools/distutils_patch.py
index f9e63798..b2095fba 100644
--- a/setuptools/distutils_patch.py
+++ b/setuptools/distutils_patch.py
@@ -8,19 +8,7 @@ for more motivation.
import sys
import re
import importlib
-import contextlib
import warnings
-from os.path import dirname
-
-
-@contextlib.contextmanager
-def patch_sys_path():
- orig = sys.path[:]
- sys.path[:] = [dirname(dirname(__file__))]
- try:
- yield
- finally:
- sys.path[:] = orig
def clear_distutils():
@@ -34,9 +22,13 @@ def clear_distutils():
def ensure_local_distutils():
clear_distutils()
- with patch_sys_path():
- importlib.import_module('distutils')
- assert sys.modules['distutils'].local
+ distutils = importlib.import_module('setuptools._distutils')
+ distutils.__name__ = 'distutils'
+ sys.modules['distutils'] = distutils
+
+ # sanity check that submodules load as expected
+ core = importlib.import_module('distutils.core')
+ assert '_distutils' in core.__file__, core.__file__
ensure_local_distutils()