summaryrefslogtreecommitdiff
path: root/_distutils_hack
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2021-12-28 14:34:37 -0500
committerJason R. Coombs <jaraco@jaraco.com>2021-12-28 14:35:25 -0500
commit9c9c91c0a3951a7c521bd6eddc3aa5f84f0cfd9f (patch)
treee68cee58098dda6077c06ef23631dd918378fa44 /_distutils_hack
parentdcdeedbed77711549f41e1f46f186c94ef9c4657 (diff)
downloadpython-setuptools-git-9c9c91c0a3951a7c521bd6eddc3aa5f84f0cfd9f.tar.gz
Bypass distutils loader when setuptools module is no longer available on sys.path. Fixes #2980.
Diffstat (limited to '_distutils_hack')
-rw-r--r--_distutils_hack/__init__.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/_distutils_hack/__init__.py b/_distutils_hack/__init__.py
index 85a51370..55ea0825 100644
--- a/_distutils_hack/__init__.py
+++ b/_distutils_hack/__init__.py
@@ -86,6 +86,13 @@ class DistutilsMetaFinder:
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):