File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -92,9 +92,22 @@ def spec_for_pip(self):
9292 Ensure stdlib distutils when running under pip.
9393 See pypa/pip#8761 for rationale.
9494 """
95+ if self .pip_imported_during_build ():
96+ return
9597 clear_distutils ()
9698 self .spec_for_distutils = lambda : None
9799
100+ @staticmethod
101+ def pip_imported_during_build ():
102+ """
103+ Detect if pip is being imported in a build script. Ref #2355.
104+ """
105+ import traceback
106+ return any (
107+ frame .f_globals ['__file__' ].endswith ('setup.py' )
108+ for frame , line in traceback .walk_stack (None )
109+ )
110+
98111
99112DISTUTILS_FINDER = DistutilsMetaFinder ()
100113
Original file line number Diff line number Diff line change 1+ When pip is imported as part of a build, leave distutils patched.
You can’t perform that action at this time.
0 commit comments