def METHOD_NAME(
    cfg: Config, tmp_dir: Optional[str], keep_dir: bool
) -> tuple[Path, bool]:
    if tmp_dir:
        if not tmp_dir.startswith("/"):
            temp_dir = Path(cfg.work_dir, tmp_dir).resolve()
        else:
            temp_dir = Path(tmp_dir).resolve()
        if cfg.debug:
            click.echo(
                " > Always setting `--keep-dir` when temp dir provided explicitly"
            )
        keep_dir = True
    else:
        temp_dir = Path(mkdtemp(prefix="package-")).resolve()
    return temp_dir, keep_dir