(self, versions: T.List[str], returncode: int = 0)
return best_match
Helper method that searches for config tool binaries in PATH and
        returns the one that best matches the given version requirements.
Helper method that searches for config tool binaries in PATH and
        returns the one that best matches the given version requirements.
Helper method that searches for config tool binaries in PATH and returns the one that best matches the given version requirements .
def find_config(self, versions: T.List[str], returncode: int = 0) \
            -> T.Tuple[T.Optional[T.List[str]], T.Optional[str]]:
        """Helper method that searches for config tool binaries in PATH and
        returns the one that best matches the given version requirements.
        """
        best_match: T.Tuple[T.Optional[T.List[str]], T.Optional[str]] = (None, None)
        for potential_bin in find_external_program(
                self.env, self.for_machine, self.tool_name,
                self.tool_name, self.tools, allow_default_for_cross=False):
            if not potential_bin.found():
                continue
            tool = potential_bin.get_command()
            try:
                p, out = Popen_safe(tool + [self.version_arg])[:2]
            except (FileNotFoundError, PermissionError):
                continue
            if p.returncode != returncode:
                continue

            out = self._sanitize_version(out.strip())
            # Some tools, like pcap-config don't supply a version, but also
            # don't fail with --version, in that case just assume that there is
            # only one version and return it.
            if not out:
                return (tool, None)
            if versions:
                is_found = version_compare_many(out, versions)[0]
                # This allows returning a found version without a config tool,
                # which is useful to inform the user that you found version x,
                # but y was required.
                if not is_found:
                    tool = None
            if best_match[1]:
                if version_compare(out, '> {}'.format(best_match[1])):
                    best_match = (tool, out)
            else:
                best_match = (tool, out)

        return best_match
def find_config ( self , versions : T . List [ str ] , returncode : int = 0 ) -> T . Tuple [ T . Optional [ T . List [ str ] ] , T . Optional [ str ] ] : best_match : T . Tuple [ T . Optional [ T . List [ str ] ] , T . Optional [ str ] ] = ( None , None ) for potential_bin in find_external_program ( self . env , self . for_machine , self . tool_name , self . tool_name , self . tools , allow_default_for_cross = False ) : if not potential_bin . found ( ) : continue tool = potential_bin . get_command ( ) try : p , out = Popen_safe ( tool + [ self . version_arg ] ) [ : 2 ] except ( FileNotFoundError , PermissionError ) : continue if p . returncode != returncode : continue out = self . _sanitize_version ( out . strip ( ) ) # Some tools, like pcap-config don't supply a version, but also # don't fail with --version, in that case just assume that there is # only one version and return it. if not out : return ( tool , None ) if versions : is_found = version_compare_many ( out , versions ) [ 0 ] # This allows returning a found version without a config tool, # which is useful to inform the user that you found version x, # but y was required. if not is_found : tool = None if best_match [ 1 ] : if version_compare ( out , '> {}' . format ( best_match [ 1 ] ) ) : best_match = ( tool , out ) else : best_match = ( tool , out ) return best_match