Commit 6952ae89 authored by Jason R. Coombs's avatar Jason R. Coombs Committed by GitHub

Merge pull request #2381 from...

Merge pull request #2381 from pypa/bugfix/2355-keep-distutils-patched-when-pip-imported-during-build

When pip is imported as part of a build, leave distutils patched.
parents 54af6855 7c07fec3
...@@ -92,9 +92,22 @@ class DistutilsMetaFinder: ...@@ -92,9 +92,22 @@ class DistutilsMetaFinder:
Ensure stdlib distutils when running under pip. Ensure stdlib distutils when running under pip.
See pypa/pip#8761 for rationale. See pypa/pip#8761 for rationale.
""" """
if self.pip_imported_during_build():
return
clear_distutils() clear_distutils()
self.spec_for_distutils = lambda: None self.spec_for_distutils = lambda: None
@staticmethod
def pip_imported_during_build():
"""
Detect if pip is being imported in a build script. Ref #2355.
"""
import traceback
return any(
frame.f_globals['__file__'].endswith('setup.py')
for frame, line in traceback.walk_stack(None)
)
DISTUTILS_FINDER = DistutilsMetaFinder() DISTUTILS_FINDER = DistutilsMetaFinder()
......
When pip is imported as part of a build, leave distutils patched.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment