diff --git a/_distutils_hack/__init__.py b/_distutils_hack/__init__.py index c0170d0908..4745f8b9da 100644 --- a/_distutils_hack/__init__.py +++ b/_distutils_hack/__init__.py @@ -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 @@ -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): """ diff --git a/changelog.d/2993.change.rst b/changelog.d/2993.change.rst new file mode 100644 index 0000000000..cd528d57f9 --- /dev/null +++ b/changelog.d/2993.change.rst @@ -0,0 +1 @@ +In _distutils_hack, bypass the distutils exception for pip when get-pip is being invoked, because it imports setuptools.