def get_subproject_dep(self, name, display_name, dirname, varname, kwargs):
    required = kwargs.get('required', True)
    wanted = mesonlib.stringlistify(kwargs.get('version', []))
    subproj_path = os.path.join(self.subproject_dir, dirname)
    dep = self.notfound_dependency()
    try:
        subproject = self.subprojects[dirname]
        (_, cached_dep) = self._find_cached_dep(name, display_name, kwargs)
        if (varname is None):
            if cached_dep:
                if (required and (not cached_dep.found())):
                    m = 'Dependency {!r} is not satisfied'
                    raise DependencyException(m.format(display_name))
                return DependencyHolder(cached_dep, self.subproject)
            else:
                m = 'Subproject {} did not override dependency {}'
                raise DependencyException(m.format(subproj_path, display_name))
        if subproject.found():
            self.verify_fallback_consistency(dirname, varname, cached_dep)
            dep = self.subprojects[dirname].get_variable_method([varname], {})
    except InvalidArguments:
        pass
    if (not isinstance(dep, DependencyHolder)):
        raise InvalidCode('Fetched variable {!r} in the subproject {!r} is not a dependency object.'.format(varname, dirname))
    if (not dep.found()):
        if required:
            raise DependencyException('Could not find dependency {} in subproject {}'.format(varname, dirname))
        mlog.log('Dependency', mlog.bold(display_name), 'from subproject', mlog.bold(subproj_path), 'found:', mlog.red('NO'))
        return dep
    found = dep.held_object.get_version()
    if (not self.check_version(wanted, found)):
        if required:
            raise DependencyException('Version {} of subproject dependency {} already cached, requested incompatible version {} for dep {}'.format(found, dirname, wanted, display_name))
        mlog.log('Dependency', mlog.bold(display_name), 'from subproject', mlog.bold(subproj_path), 'found:', mlog.red('NO'), 'found', mlog.normal_cyan(found), 'but need:', mlog.bold(', '.join(["'{}'".format(e) for e in wanted])))
        return self.notfound_dependency()
    found = (mlog.normal_cyan(found) if found else None)
    mlog.log('Dependency', mlog.bold(display_name), 'from subproject', mlog.bold(subproj_path), 'found:', mlog.green('YES'), found)
    return dep
def get_subproject_dep(self, name, display_name, dirname, varname, kwargs):
    required = kwargs.get('required', True)
    wanted = mesonlib.stringlistify(kwargs.get('version', []))
    subproj_path = os.path.join(self.subproject_dir, dirname)
    dep = self.notfound_dependency()
    try:
        subproject = self.subprojects[dirname]
        (_, cached_dep) = self._find_cached_dep(name, display_name, kwargs)
        if (varname is None):
            if cached_dep:
                if (required and (not cached_dep.found())):
                    m = 'Dependency {!r} is not satisfied'
                    raise DependencyException(m.format(display_name))
                return DependencyHolder(cached_dep, self.subproject)
            else:
                m = 'Subproject {} did not override dependency {}'
                raise DependencyException(m.format(subproj_path, display_name))
        if subproject.found():
            self.verify_fallback_consistency(dirname, varname, cached_dep)
            dep = self.subprojects[dirname].get_variable_method([varname], {})
    except InvalidArguments:
        pass
    if (not isinstance(dep, DependencyHolder)):
        raise InvalidCode('Fetched variable {!r} in the subproject {!r} is not a dependency object.'.format(varname, dirname))
    if (not dep.found()):
        if required:
            raise DependencyException('Could not find dependency {} in subproject {}'.format(varname, dirname))
        mlog.log('Dependency', mlog.bold(display_name), 'from subproject', mlog.bold(subproj_path), 'found:', mlog.red('NO'))
        return dep
    found = dep.held_object.get_version()
    if (not self.check_version(wanted, found)):
        if required:
            raise DependencyException('Version {} of subproject dependency {} already cached, requested incompatible version {} for dep {}'.format(found, dirname, wanted, display_name))
        mlog.log('Dependency', mlog.bold(display_name), 'from subproject', mlog.bold(subproj_path), 'found:', mlog.red('NO'), 'found', mlog.normal_cyan(found), 'but need:', mlog.bold(', '.join(["'{}'".format(e) for e in wanted])))
        return self.notfound_dependency()
    found = (mlog.normal_cyan(found) if found else None)
    mlog.log('Dependency', mlog.bold(display_name), 'from subproject', mlog.bold(subproj_path), 'found:', mlog.green('YES'), found)
    return dep