@rule(level=LogLevel.DEBUG)
async def create_python_repl_request(repl: PythonRepl, pex_env: PexEnvironment) -> ReplRequest:
    requirements_pex_request = (await Get(PexRequest, PexFromTargetsRequest, PexFromTargetsRequest.for_requirements((tgt.address for tgt in repl.targets), internal_only=True)))
    requirements_request = Get(Pex, PexRequest, requirements_pex_request)
    local_dists_request = Get(LocalDistsPex, LocalDistsPexRequest(Addresses((tgt.address for tgt in repl.targets)), interpreter_constraints=requirements_pex_request.interpreter_constraints))
    sources_request = Get(PythonSourceFiles, PythonSourceFilesRequest(repl.targets, 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(repl.in_chroot(requirements_pex.name), python=requirements_pex.python)
    chrooted_source_roots = [repl.in_chroot(sr) for sr in sources.source_roots]
    extra_env = {**complete_pex_env.environment_dict(python_configured=(requirements_pex.python is not None)), 'PEX_EXTRA_SYS_PATH': ':'.join(chrooted_source_roots), 'PEX_PATH': repl.in_chroot(local_dists.pex.name)}
    return ReplRequest(digest=merged_digest, args=args, extra_env=extra_env)
@rule(level=LogLevel.DEBUG)
async def create_python_repl_request(repl: PythonRepl, pex_env: PexEnvironment) -> ReplRequest:
    requirements_pex_request = (await Get(PexRequest, PexFromTargetsRequest, PexFromTargetsRequest.for_requirements((tgt.address for tgt in repl.targets), internal_only=True)))
    requirements_request = Get(Pex, PexRequest, requirements_pex_request)
    local_dists_request = Get(LocalDistsPex, LocalDistsPexRequest(Addresses((tgt.address for tgt in repl.targets)), interpreter_constraints=requirements_pex_request.interpreter_constraints))
    sources_request = Get(PythonSourceFiles, PythonSourceFilesRequest(repl.targets, 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(repl.in_chroot(requirements_pex.name), python=requirements_pex.python)
    chrooted_source_roots = [repl.in_chroot(sr) for sr in sources.source_roots]
    extra_env = {**complete_pex_env.environment_dict(python_configured=(requirements_pex.python is not None)), 'PEX_EXTRA_SYS_PATH': ':'.join(chrooted_source_roots), 'PEX_PATH': repl.in_chroot(local_dists.pex.name)}
    return ReplRequest(digest=merged_digest, args=args, extra_env=extra_env)