diff options
| author | Jason R. Coombs <jaraco@jaraco.com> | 2021-12-29 11:35:11 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-29 11:35:11 -0500 |
| commit | 104f8b40ba36999b81d88470900f01c20654d3ce (patch) | |
| tree | 155995772cd45b9ad365046a327e7e2dc327f3d4 /_distutils_hack | |
| parent | e401134914cea9fe9863b6f745716071a98ee611 (diff) | |
| parent | 6eb6350caebbb36537722c7a0ec532b9ff98168f (diff) | |
| download | python-setuptools-git-104f8b40ba36999b81d88470900f01c20654d3ce.tar.gz | |
Merge pull request #2962 from nitzmahone/setuptools_picky_shim
distutils shim should ignore setuptools on another path
Diffstat (limited to '_distutils_hack')
| -rw-r--r-- | _distutils_hack/__init__.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/_distutils_hack/__init__.py b/_distutils_hack/__init__.py index 0a8f0473..c0170d09 100644 --- a/_distutils_hack/__init__.py +++ b/_distutils_hack/__init__.py @@ -86,17 +86,23 @@ 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'): + try: + mod = importlib.import_module('setuptools._distutils') + except Exception: + # There are a couple of cases where setuptools._distutils + # may not be present: + # - An older Setuptools without a local distutils is + # taking precedence. Ref #2957. + # - Path manipulation during sitecustomize removes + # setuptools from the path but only after the hook + # has been loaded. Ref #2980. + # In either case, fall back to stdlib behavior. return class DistutilsLoader(importlib.abc.Loader): def create_module(self, spec): - return importlib.import_module('setuptools._distutils') + return mod def exec_module(self, module): pass |
