Skip to content

Commit

Permalink
Remove workaround for pypa/get-pip#137.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Feb 11, 2022
1 parent f38d139 commit 76bfec8
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 35 deletions.
35 changes: 0 additions & 35 deletions _distutils_hack/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand All @@ -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):
"""
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 @@
Removed workaround in distutils hack for get-pip now that pypa/get-pip#137 is closed.

0 comments on commit 76bfec8

Please sign in to comment.