async def METHOD_NAME(
    request: GenerateEntryPointsTxtFromStevedoreExtensionRequest,
) -> PytestPluginSetup:
    requested_namespaces = request.target[StevedoreNamespacesField]
    if not requested_namespaces.value:
        return PytestPluginSetup(EMPTY_DIGEST)
    stevedore_targets = await Get(
        StevedoreExtensionTargets,
        StevedoreNamespacesProviderTargetsRequest(requested_namespaces),
    )
    all_resolved_entry_points = await MultiGet(
        Get(
            ResolvedPythonDistributionEntryPoints,
            ResolvePythonDistributionEntryPointsRequest(tgt[PythonDistributionEntryPointsField]),
        )
        for tgt in stevedore_targets
    )
    possible_paths = [
        {
            f"{tgt.address.spec_path}/{ep.entry_point.module.split('.')[0]}"
            for _, entry_points in (resolved_eps.val or {}).items()
            for ep in entry_points.values()
        }
        for tgt, resolved_eps in zip(stevedore_targets, all_resolved_entry_points)
    ]
    resolved_paths = await MultiGet(
        Get(Paths, PathGlobs(module_candidate_paths)) for module_candidate_paths in possible_paths
    )
    # arrange in sibling groups
    stevedore_extensions_by_path: dict[
        str, list[ResolvedPythonDistributionEntryPoints]
    ] = defaultdict(list)
    for resolved_ep, paths in zip(all_resolved_entry_points, resolved_paths):
        path = paths.dirs[0]  # just take the first match
        stevedore_extensions_by_path[path].append(resolved_ep)
    entry_points_txt_files = []
    for module_path, resolved_eps in stevedore_extensions_by_path.items():
        namespace_sections = {}
        for resolved_ep in resolved_eps:
            namespace: str
            entry_points: FrozenDict[str, PythonDistributionEntryPoint]
            for namespace, entry_points in resolved_ep.val.items():
                if not entry_points or namespace not in requested_namespaces.value:
                    continue
                entry_points_txt_section = f"[{namespace}]\n"
                for entry_point_name, ep in sorted(entry_points.items()):
                    entry_points_txt_section += f"{entry_point_name} = {ep.entry_point.spec}\n"
                entry_points_txt_section += "\n"
                namespace_sections[namespace] = entry_points_txt_section
        # consistent sorting
        entry_points_txt_contents = "".join(
            namespace_sections[ns] for ns in sorted(namespace_sections)
        )
        entry_points_txt_path = f"{module_path}.egg-info/entry_points.txt"
        entry_points_txt_files.append(
            FileContent(entry_points_txt_path, entry_points_txt_contents.encode("utf-8"))
        )
    digest = await Get(Digest, CreateDigest(entry_points_txt_files))
    return PytestPluginSetup(digest)