|
28 | 28 | return(list(error = conditionMessage(config)))
|
29 | 29 | }
|
30 | 30 |
|
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))) { |
32 | 36 | # The front-end will offer to install Python.
|
33 | 37 | return(list(python = NULL, error = NULL))
|
34 | 38 | }
|
35 | 39 |
|
36 |
| - python <- config$python |
37 |
| - venv <- config$virtualenv |
38 |
| - |
39 | 40 | # Check that python can be loaded, if it can't we will throw
|
40 | 41 | # an error, which is unrecoverable.
|
41 | 42 | 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. |
42 | 48 | reticulate::py_config()
|
43 | 49 | }, error = function(err) {
|
44 | 50 | err
|
45 | 51 | })
|
46 | 52 |
|
| 53 | + python <- config$python |
| 54 | + venv <- config$virtualenv |
| 55 | + |
47 | 56 | if (inherits(config, "error")) {
|
48 | 57 | return(list(python = python, venv = venv, error = conditionMessage(config)))
|
49 | 58 | }
|
|
0 commit comments