@@ -66,14 +66,14 @@ def do_override():
6666
6767class DistutilsMetaFinder :
6868 def find_spec (self , fullname , path , target = None ):
69- self ._disable_for_pip (fullname , path )
70-
71- if path is not None or fullname != "distutils" :
72- return None
69+ if path is not None :
70+ return
7371
74- return self .get_distutils_spec ()
72+ method_name = 'spec_for_{fullname}' .format (** locals ())
73+ method = getattr (self , method_name , lambda : None )
74+ return method ()
7575
76- def get_distutils_spec (self ):
76+ def spec_for_distutils (self ):
7777 import importlib .util
7878
7979 class DistutilsLoader (importlib .util .abc .Loader ):
@@ -86,17 +86,13 @@ def exec_module(self, module):
8686
8787 return importlib .util .spec_from_loader ('distutils' , DistutilsLoader ())
8888
89- def _disable_for_pip (self , fullname , path ):
89+ def spec_for_pip (self ):
9090 """
9191 Ensure stdlib distutils when running under pip.
9292 See pypa/pip#8761 for rationale.
9393 """
94- if path is not None or fullname != "pip" :
95- return
96-
97- # pip is being imported the first time.
9894 clear_distutils ()
99- self .get_distutils_spec = lambda : None
95+ self .spec_for_distutils = lambda : None
10096
10197
10298DISTUTILS_FINDER = DistutilsMetaFinder ()
0 commit comments