diff options
| author | Jason R. Coombs <jaraco@jaraco.com> | 2020-08-20 21:40:53 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-20 21:40:53 -0400 |
| commit | e20e85ed73fcf4cd127f11c0c2aaa1cbdb8cfbac (patch) | |
| tree | c1cc25c3fc2ce279c113cacbd48256d5f6e09612 /_distutils_hack | |
| parent | 8d508965e49028b68e09b930a10340ba09687d35 (diff) | |
| parent | 3d404fd3268b0fb7d84916779ca2e282f4586396 (diff) | |
| download | python-setuptools-git-e20e85ed73fcf4cd127f11c0c2aaa1cbdb8cfbac.tar.gz | |
Merge pull request #2255 from pypa/bugfix/2232-adopt-distutils-default
Re-enable distutils patch by default.
Diffstat (limited to '_distutils_hack')
| -rw-r--r-- | _distutils_hack/__init__.py | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/_distutils_hack/__init__.py b/_distutils_hack/__init__.py index 1e7b294b..074bd5e9 100644 --- a/_distutils_hack/__init__.py +++ b/_distutils_hack/__init__.py @@ -37,7 +37,7 @@ def enabled(): """ Allow selection of distutils by environment variable. """ - which = os.environ.get('SETUPTOOLS_USE_DISTUTILS', 'stdlib') + which = os.environ.get('SETUPTOOLS_USE_DISTUTILS', 'local') return which == 'local' @@ -66,12 +66,14 @@ def do_override(): class DistutilsMetaFinder: def find_spec(self, fullname, path, target=None): - if path is not None or fullname != "distutils": - return None + if path is not None: + return - return self.get_distutils_spec() + method_name = 'spec_for_{fullname}'.format(**locals()) + method = getattr(self, method_name, lambda: None) + return method() - def get_distutils_spec(self): + def spec_for_distutils(self): import importlib.util class DistutilsLoader(importlib.util.abc.Loader): @@ -84,6 +86,14 @@ class DistutilsMetaFinder: return importlib.util.spec_from_loader('distutils', DistutilsLoader()) + def spec_for_pip(self): + """ + Ensure stdlib distutils when running under pip. + See pypa/pip#8761 for rationale. + """ + clear_distutils() + self.spec_for_distutils = lambda: None + DISTUTILS_FINDER = DistutilsMetaFinder() |
