diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2020-08-10 08:43:14 -0400 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2020-08-10 08:43:14 -0400 |
commit | c85bdd84783be705f1dc1ce8b080fab18ddf2f52 (patch) | |
tree | f6c6fe0422c27f8d55810913e14a753f5cb6522d /setuptools/sandbox.py | |
parent | 9e58d95017656ee33d2cf642cf1be6c77298f16d (diff) | |
parent | 9d7b246c0f40fabb25741a023849bf14919e408d (diff) | |
download | external_python_setuptools-c85bdd84783be705f1dc1ce8b080fab18ddf2f52.tar.gz external_python_setuptools-c85bdd84783be705f1dc1ce8b080fab18ddf2f52.tar.bz2 external_python_setuptools-c85bdd84783be705f1dc1ce8b080fab18ddf2f52.zip |
Merge branch 'master' into bugfix/2232-adopt-distutils-defaultbugfix/2232-adopt-distutils-default
Diffstat (limited to 'setuptools/sandbox.py')
-rw-r--r-- | setuptools/sandbox.py | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/setuptools/sandbox.py b/setuptools/sandbox.py index 93ae8eb4..24a36080 100644 --- a/setuptools/sandbox.py +++ b/setuptools/sandbox.py @@ -185,8 +185,8 @@ def setup_context(setup_dir): temp_dir = os.path.join(setup_dir, 'temp') with save_pkg_resources_state(): with save_modules(): - hide_setuptools() with save_path(): + hide_setuptools() with save_argv(): with override_temp(temp_dir): with pushd(setup_dir): @@ -195,6 +195,15 @@ def setup_context(setup_dir): yield +_MODULES_TO_HIDE = { + 'setuptools', + 'distutils', + 'pkg_resources', + 'Cython', + '_distutils_hack', +} + + def _needs_hiding(mod_name): """ >>> _needs_hiding('setuptools') @@ -212,8 +221,8 @@ def _needs_hiding(mod_name): >>> _needs_hiding('Cython') True """ - pattern = re.compile(r'(setuptools|pkg_resources|distutils|Cython)(\.|$)') - return bool(pattern.match(mod_name)) + base_module = mod_name.split('.', 1)[0] + return base_module in _MODULES_TO_HIDE def hide_setuptools(): @@ -223,6 +232,10 @@ def hide_setuptools(): necessary to avoid issues such as #315 where setuptools upgrading itself would fail to find a function declared in the metadata. """ + _distutils_hack = sys.modules.get('_distutils_hack', None) + if _distutils_hack is not None: + _distutils_hack.remove_shim() + modules = filter(_needs_hiding, sys.modules) _clear_modules(modules) |