async def METHOD_NAME(
    request: PythonRepl, pex_env: PexEnvironment, python_setup: PythonSetup
) -> ReplRequest:
    validate_compatible_resolve(request.targets, python_setup)
    interpreter_constraints, transitive_targets = await MultiGet(
        Get(InterpreterConstraints, InterpreterConstraintsRequest(request.addresses)),
        Get(TransitiveTargets, TransitiveTargetsRequest(request.addresses)),
    )
    requirements_request = Get(Pex, RequirementsPexRequest(request.addresses))
    local_dists_request = Get(
        LocalDistsPex,
        LocalDistsPexRequest(
            request.addresses,
            internal_only=True,
            interpreter_constraints=interpreter_constraints,
        ),
    )
    sources_request = Get(
        PythonSourceFiles, PythonSourceFilesRequest(transitive_targets.closure, include_files=True)
    )
    requirements_pex, local_dists, sources = await MultiGet(
        requirements_request, local_dists_request, sources_request
    )
    merged_digest = await Get(
        Digest,
        MergeDigests(
            (requirements_pex.digest, local_dists.pex.digest, sources.source_files.snapshot.digest)
        ),
    )
    complete_pex_env = pex_env.in_workspace()
    args = complete_pex_env.create_argv(request.in_chroot(requirements_pex.name))
    chrooted_source_roots = [request.in_chroot(sr) for sr in sources.source_roots]
    extra_env = {
        **complete_pex_env.environment_dict(python=requirements_pex.python),
        "PEX_EXTRA_SYS_PATH": ":".join(chrooted_source_roots),
        "PEX_PATH": request.in_chroot(local_dists.pex.name),
        "PEX_INTERPRETER_HISTORY": "1" if python_setup.repl_history else "0",
    }
    return ReplRequest(digest=merged_digest, args=args, extra_env=extra_env)