From 76bfec83a18a2913529151be9220e5452dda2475 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 11 Feb 2022 11:56:22 -0500 Subject: [PATCH] Remove workaround for pypa/get-pip#137. --- _distutils_hack/__init__.py | 35 ----------------------------------- changelog.d/2993.change.rst | 1 + 2 files changed, 1 insertion(+), 35 deletions(-) create mode 100644 changelog.d/2993.change.rst diff --git a/_distutils_hack/__init__.py b/_distutils_hack/__init__.py index 1f8daf498b..c6f7de6066 100644 --- a/_distutils_hack/__init__.py +++ b/_distutils_hack/__init__.py @@ -139,33 +139,6 @@ def spec_for_pip(self): clear_distutils() self.spec_for_distutils = lambda: None - def spec_for_setuptools(self): - """ - get-pip imports setuptools solely for the purpose of - determining if it's installed. In this case, provide - a stubbed spec to represent setuptools being present - without invoking any behavior. - - Workaround for pypa/get-pip#137. Ref #2993. - """ - if not self.is_script('get-pip'): - return - - import importlib - - class StubbedLoader(importlib.abc.Loader): - - def create_module(self, spec): - import types - return types.ModuleType('setuptools') - - def exec_module(self, module): - pass - - return importlib.util.spec_from_loader( - 'setuptools', StubbedLoader(), - ) - @classmethod def pip_imported_during_build(cls): """ @@ -177,14 +150,6 @@ def pip_imported_during_build(cls): for frame, line in traceback.walk_stack(None) ) - @staticmethod - def is_script(name): - try: - import __main__ - return os.path.basename(__main__.__file__) == f'{name}.py' - except AttributeError: - pass - @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..5cb9d6aa6a --- /dev/null +++ b/changelog.d/2993.change.rst @@ -0,0 +1 @@ +Removed workaround in distutils hack for get-pip now that pypa/get-pip#137 is closed.