Skip to content

Commit

Permalink
Extract frame_file_is_setup.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Dec 21, 2021
1 parent 34006b3 commit 82726bb
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions _distutils_hack/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,21 @@ def spec_for_pip(self):
clear_distutils()
self.spec_for_distutils = lambda: None

@staticmethod
def pip_imported_during_build():
@classmethod
def pip_imported_during_build(cls):
"""
Detect if pip is being imported in a build script. Ref #2355.
"""
import traceback
return any(
frame.f_globals['__file__'].endswith('setup.py')
cls.frame_file_is_setup(frame)
for frame, line in traceback.walk_stack(None)
)

@staticmethod
def frame_file_is_setup(frame):
return frame.f_globals['__file__'].endswith('setup.py')


DISTUTILS_FINDER = DistutilsMetaFinder()

Expand Down

0 comments on commit 82726bb

Please sign in to comment.