diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2020-07-03 03:53:46 -0400 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2020-07-03 04:13:14 -0400 |
commit | bb9fb1fcfe37c1ef1e29e1e6d1fc4e483c743380 (patch) | |
tree | 053ee5d48b9f73587e8b8d30334ae1d0b581518d /setuptools/distutils_patch.py | |
parent | c486771a15642d69622b9afeb9178450daf02e24 (diff) | |
download | python-setuptools-git-bb9fb1fcfe37c1ef1e29e1e6d1fc4e483c743380.tar.gz |
Move distutils into a submodule of setuptools.
Diffstat (limited to 'setuptools/distutils_patch.py')
-rw-r--r-- | setuptools/distutils_patch.py | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/setuptools/distutils_patch.py b/setuptools/distutils_patch.py index f9e63798..06eed82f 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,12 @@ 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') + 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() |