Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for newer reticulate #703

Merged
merged 1 commit into from
Feb 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions crates/ark/src/modules/positron/reticulate.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,31 @@
return(list(error = conditionMessage(config)))
}

if (is.null(config) || is.null(config$python)) {
# Starting with reticulate v1.41, `py_discover_config()` is NULL if reticulate
# didn't find a forced python environment and will eventually use `uv` to
# install and manage environments.
version <- utils::packageVersion("reticulate")
if (version <= "1.40.0" && (is.null(config) || is.null(config$python))) {
# The front-end will offer to install Python.
return(list(python = NULL, error = NULL))
}

python <- config$python
venv <- config$virtualenv

# Check that python can be loaded, if it can't we will throw
# an error, which is unrecoverable.
config <- tryCatch({
# With reticulate >= v1.41.0, (if the previous config was NULL) this will trigger
# an installation of `uv` and the creation of a temporary virtual environment for
# the current session.
# This may take a while, if `uv` has a lot of work to do (like downloading a bunch of packages).
# Positron UI will display a progress bar and handle the timeout.
reticulate::py_config()
}, error = function(err) {
err
})

python <- config$python
venv <- config$virtualenv

if (inherits(config, "error")) {
return(list(python = python, venv = venv, error = conditionMessage(config)))
}
Expand Down
Loading