diff --git a/DESCRIPTION b/DESCRIPTION index 5a03d6aaa5779c8c4252c3d4c3370925eeea5aa7..45a9c8841e7a08eec16c092c1f902867bb455fa8 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: reticulate Type: Package Title: Interface to 'Python' -Version: 1.18-9006 +Version: 1.18-9007 Authors@R: c( person("Kevin", "Ushey", role = c("aut", "cre"), email = "kevin@rstudio.com"), diff --git a/R/config.R b/R/config.R index 454917cc61b67e840575e83ee2a85e37d79c2074..141c8861b963a80650082bb8f43c47162fa8de4e 100644 --- a/R/config.R +++ b/R/config.R @@ -185,6 +185,17 @@ py_discover_config <- function(required_module = NULL, use_environment = NULL) { config <- python_config(python_version, required_module, python_version, forced = "use_python function") return(config) } + + # if RETICULATE_PYTHON_FALLBACK is specified then use it + reticulate_env <- Sys.getenv("RETICULATE_PYTHON_FALLBACK", unset = NA) + if (!is.na(reticulate_env)) { + python_version <- normalize_python_path(reticulate_env) + if (!python_version$exists) + stop("Python specified in RETICULATE_PYTHON_FALLBACK (", reticulate_env, ") does not exist") + python_version <- python_version$path + config <- python_config(python_version, required_module, python_version, forced = "RETICULATE_PYTHON_FALLBACK") + return(config) + } # create a list of possible python versions to bind to # (start with versions specified via environment variable or use_* function)