Skip to content

Commit 86c36f5

Browse files
authored
Support for newer reticulate (#703)
1 parent d6656bb commit 86c36f5

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

crates/ark/src/modules/positron/reticulate.R

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,31 @@
2828
return(list(error = conditionMessage(config)))
2929
}
3030

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

36-
python <- config$python
37-
venv <- config$virtualenv
38-
3940
# Check that python can be loaded, if it can't we will throw
4041
# an error, which is unrecoverable.
4142
config <- tryCatch({
43+
# With reticulate >= v1.41.0, (if the previous config was NULL) this will trigger
44+
# an installation of `uv` and the creation of a temporary virtual environment for
45+
# the current session.
46+
# This may take a while, if `uv` has a lot of work to do (like downloading a bunch of packages).
47+
# Positron UI will display a progress bar and handle the timeout.
4248
reticulate::py_config()
4349
}, error = function(err) {
4450
err
4551
})
4652

53+
python <- config$python
54+
venv <- config$virtualenv
55+
4756
if (inherits(config, "error")) {
4857
return(list(python = python, venv = venv, error = conditionMessage(config)))
4958
}

0 commit comments

Comments
 (0)