Skip to content

Commit 41fa663

Browse files
committed
Add another exception for the exclusion for pip. Fixes #2993.
1 parent 80045ce commit 41fa663

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

_distutils_hack/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ def spec_for_pip(self):
116116
"""
117117
if self.pip_imported_during_build():
118118
return
119+
if self.is_get_pip():
120+
return
119121
clear_distutils()
120122
self.spec_for_distutils = lambda: None
121123

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

135+
@classmethod
136+
def is_get_pip(cls):
137+
"""
138+
Detect if get-pip is being invoked. Ref #2993.
139+
"""
140+
import __main__
141+
return os.path.basename(__main__.__file__) == 'get-pip.py'
142+
133143
@staticmethod
134144
def frame_file_is_setup(frame):
135145
"""

changelog.d/2993.change.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
In _distutils_hack, bypass the distutils exception for pip when get-pip is being invoked, because it imports setuptools.

0 commit comments

Comments
 (0)