Skip to content

Commit

Permalink
Bypass distutils loader when setuptools module is no longer available…
Browse files Browse the repository at this point in the history
… on sys.path. Fixes #2980.
  • Loading branch information
jaraco committed Dec 28, 2021
1 parent dcdeedb commit 9c9c91c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions _distutils_hack/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ def spec_for_distutils(self):
import importlib.abc
import importlib.util

# In cases of path manipulation during sitecustomize,
# Setuptools might actually not be present even though
# the hook has been loaded. Allow the caller to fall
# back to stdlib behavior. See #2980.
if not importlib.util.find_spec('setuptools'):
return

class DistutilsLoader(importlib.abc.Loader):

def create_module(self, spec):
Expand Down
1 change: 1 addition & 0 deletions changelog.d/2980.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Bypass distutils loader when setuptools module is no longer available on sys.path.

0 comments on commit 9c9c91c

Please sign in to comment.