Skip to content

Commit

Permalink
cache resolved_python_version in uv_run_tool()
Browse files Browse the repository at this point in the history
Observed to take 0.5 seconds on a Windows machine.
  • Loading branch information
t-kalinowski committed Feb 28, 2025
1 parent 64c5ce0 commit 2def327
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions R/py_require.R
Original file line number Diff line number Diff line change
Expand Up @@ -781,12 +781,19 @@ uv_run_tool <- function(tool,
UV_PYTHON_INSTALL_DIR = reticulate_data_dir("uv", "python")
)
))
python <- resolve_python_version(constraints = python_version, uv = uv)

python <- .globals$cached_uv_run_tool_python_version[[python_version %||% "default"]]
if (is.null(python)) {
.globals$cached_uv_run_tool_python_version[[python_version %||% "default"]] <-
python <-
resolve_python_version(constraints = python_version, uv = uv)
}

system2(uv, c(
"tool",
"run",
"--isolated",
if (length(python)) c("--python", python),
"--python", python,
if (length(exclude_newer)) c("--exclude-newer", exclude_newer),
if (length(from)) c("--from", maybe_shQuote(from)),
if (length(with)) c(rbind("--with", maybe_shQuote(with))),
Expand Down

0 comments on commit 2def327

Please sign in to comment.