1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
from __future__ import annotations
from typing import ClassVar
class _Finder:
fullname = None
lock: ClassVar[list] = []
def find_spec(self, fullname, path, target=None): # noqa: ARG002
# This should handle the NameError gracefully
try:
distutils_patch = _DISTUTILS_PATCH
except NameError:
return
if fullname in distutils_patch and self.fullname is None:
return
return
@staticmethod
def exec_module(old, module):
old(module)
try:
distutils_patch = _DISTUTILS_PATCH
except NameError:
return
if module.__name__ in distutils_patch:
pass # Would call patch_dist(module)
@staticmethod
def load_module(old, name):
module = old(name)
try:
distutils_patch = _DISTUTILS_PATCH
except NameError:
return module
if module.__name__ in distutils_patch:
pass # Would call patch_dist(module)
return module
finder = _Finder()
|