Skip to content

Commit

Permalink
Add another exception for the exclusion for pip. Fixes #2993.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Jan 3, 2022
1 parent 80045ce commit 41fa663
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions _distutils_hack/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ def spec_for_pip(self):
"""
if self.pip_imported_during_build():
return
if self.is_get_pip():
return
clear_distutils()
self.spec_for_distutils = lambda: None

Expand All @@ -130,6 +132,14 @@ def pip_imported_during_build(cls):
for frame, line in traceback.walk_stack(None)
)

@classmethod
def is_get_pip(cls):
"""
Detect if get-pip is being invoked. Ref #2993.
"""
import __main__
return os.path.basename(__main__.__file__) == 'get-pip.py'

@staticmethod
def frame_file_is_setup(frame):
"""
Expand Down
1 change: 1 addition & 0 deletions changelog.d/2993.change.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
In _distutils_hack, bypass the distutils exception for pip when get-pip is being invoked, because it imports setuptools.

0 comments on commit 41fa663

Please # to comment.