Skip to content

Commit

Permalink
support python 3.10 from registry
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinushey committed Dec 6, 2021
1 parent 5422e46 commit 3544f7a
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions R/config.R
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ py_discover_config <- function(required_module = NULL, use_environment = NULL) {

# provide other common locations
python_versions <- c(python_versions, py_discover_config_fallbacks())

# next add all known virtual environments
python_versions <- c(python_versions, python_envs$python)

Expand All @@ -349,14 +349,14 @@ py_discover_config <- function(required_module = NULL, use_environment = NULL) {

# get the config
config <- python_config(python_version, required_module, python_versions)

# if this is a conda python installation, then create an r-reticulate
# environment and use that instead
initenv <-
identical(getOption("reticulate.conda.autoclone", FALSE), TRUE) &&
identical(getOption("reticulate.python.initializing"), TRUE) &&
identical(config$conda, TRUE)

if (initenv) {
fmt <- "* Found conda installation at %s; creating 'r-reticulate' environment ..."
messagef(fmt, pretty_path(config$prefix))
Expand Down Expand Up @@ -389,43 +389,43 @@ py_discover_config <- function(required_module = NULL, use_environment = NULL) {
}

py_discover_config_fallbacks <- function() {

# prefer conda python if available
conda <- find_conda()
if (!is.null(conda) && file.exists(conda)) {

pythons <- tryCatch(
conda_python(envname = "base", conda = conda, all = TRUE),
error = identity
)

if (is.character(pythons))
return(pythons)

}

# on Windows, try looking in the registry
if (is_windows())
return(py_versions_windows()$executable_path)

# otherwise, just search some default locations
prefixes <- c(
"/opt/local/python",
"/opt/python",
"/usr/local",
"/usr"
)

suffixes <- c("bin/python3", "bin/python")
grid <- expand.grid(
prefix = prefixes,
suffix = suffixes,
KEEP.OUT.ATTRS = FALSE,
stringsAsFactors = FALSE
)

paste(grid$prefix, grid$suffix, sep = "/")

}


Expand Down Expand Up @@ -1016,7 +1016,7 @@ read_python_versions_from_registry <- function(hive, key,type=key) {
arch <- NA
}
} else { # type == "PythonCore"
matches <- regexec("^(\\d)\\.(\\d)(?:-(32|64))?$", version)
matches <- regexec("^(\\d+)\\.(\\d+)(?:-(32|64))?$", version)
matches <- regmatches(version, matches)[[1]]
if (length(matches) == 4) {
version <- paste(matches[[2]], matches[[3]], sep = ".")
Expand Down

2 comments on commit 3544f7a

@brry
Copy link

@brry brry commented on 3544f7a Jan 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you update reticulate on CRAN? I just spent a lot of time tracking down 'Unexpected format for PythonCore version: 3.10', finding this needed change, finding it's already implemented and I only need remotes::install_github("rstudio/reticulate") solves it...

@kevinushey
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the trouble. We're aiming to get the next version of reticulate up on CRAN within the next couple of weeks.

Please sign in to comment.