2929class  PkgConfigInterface :
3030    '''Base class wrapping a pkg-config implementation''' 
3131
32-     class_impl : PerMachine [T .Union [Literal [False ], T .Optional [PkgConfigInterface ]]] =  PerMachine (False , False )
33-     class_cli_impl : PerMachine [T .Union [Literal [False ], T .Optional [PkgConfigCLI ]]] =  PerMachine (False , False )
32+     # keyed on machine and extra_paths 
33+     class_impl : PerMachine [T .Dict [T .Optional [T .Tuple [str , ...]], T .Union [Literal [False ], T .Optional [PkgConfigInterface ]]]] =  PerMachine ({}, {})
34+     class_cli_impl : PerMachine [T .Dict [T .Optional [T .Tuple [str , ...]], T .Union [Literal [False ], T .Optional [PkgConfigCLI ]]]] =  PerMachine ({}, {})
3435    pkg_bin_per_machine : PerMachine [T .Optional [ExternalProgram ]] =  PerMachine (None , None )
3536
3637    @staticmethod  
@@ -45,14 +46,15 @@ def instance(env: Environment, for_machine: MachineChoice, silent: bool,
4546                 extra_paths : T .Optional [T .List [str ]] =  None ) ->  T .Optional [PkgConfigInterface ]:
4647        '''Return a pkg-config implementation singleton''' 
4748        for_machine  =  for_machine  if  env .is_cross_build () else  MachineChoice .HOST 
48-         impl  =  PkgConfigInterface .class_impl [for_machine ]
49+         extra_paths_key  =  tuple (extra_paths ) if  extra_paths  is  not   None  else  None 
50+         impl  =  PkgConfigInterface .class_impl [for_machine ].get (extra_paths_key , False )
4951        if  impl  is  False :
5052            impl  =  PkgConfigCLI (env , for_machine , silent , PkgConfigInterface .pkg_bin_per_machine [for_machine ], extra_paths )
5153            if  not  impl .found ():
5254                impl  =  None 
5355            if  not  impl  and  not  silent :
5456                mlog .log ('Found pkg-config:' , mlog .red ('NO' ))
55-             PkgConfigInterface .class_impl [for_machine ] =  impl 
57+             PkgConfigInterface .class_impl [for_machine ][ extra_paths_key ]  =  impl 
5658        return  impl 
5759
5860    @staticmethod  
@@ -67,12 +69,13 @@ def _cli(env: Environment, for_machine: MachineChoice,
6769        impl : T .Union [Literal [False ], T .Optional [PkgConfigInterface ]] # Help confused mypy 
6870        impl  =  PkgConfigInterface .instance (env , for_machine , silent )
6971        if  impl  and  not  isinstance (impl , PkgConfigCLI ):
70-             impl  =  PkgConfigInterface .class_cli_impl [for_machine ]
72+             extra_paths_key  =  tuple (extra_paths ) if  extra_paths  is  not   None  else  None 
73+             impl  =  PkgConfigInterface .class_cli_impl [for_machine ].get (extra_paths_key , False )
7174            if  impl  is  False :
7275                impl  =  PkgConfigCLI (env , for_machine , silent , PkgConfigInterface .pkg_bin_per_machine [for_machine ], extra_paths )
7376                if  not  impl .found ():
7477                    impl  =  None 
75-                 PkgConfigInterface .class_cli_impl [for_machine ] =  impl 
78+                 PkgConfigInterface .class_cli_impl [for_machine ][ extra_paths_key ]  =  impl 
7679        return  T .cast ('T.Optional[PkgConfigCLI]' , impl ) # Trust me, mypy 
7780
7881    @staticmethod  
0 commit comments