diff options
-rw-r--r-- | _distutils_hack/__init__.py | 10 | ||||
-rw-r--r-- | changelog.d/2993.change.rst | 1 |
2 files changed, 11 insertions, 0 deletions
diff --git a/_distutils_hack/__init__.py b/_distutils_hack/__init__.py index c0170d09..4745f8b9 100644 --- a/_distutils_hack/__init__.py +++ b/_distutils_hack/__init__.py @@ -116,6 +116,8 @@ class DistutilsMetaFinder: """ 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 @@ class DistutilsMetaFinder: 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 00000000..cd528d57 --- /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. |