From a4da920aadf2e5aa4d7712558b9d73c765a25a2b Mon Sep 17 00:00:00 2001 From: Luca Belmonte Date: Tue, 22 Jul 2025 16:15:18 +0000 Subject: [PATCH 1/3] aligns with databricks and other packages dependencies --- renv.lock | 10 ++--- renv/activate.R | 105 +++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 100 insertions(+), 15 deletions(-) diff --git a/renv.lock b/renv.lock index 587205d..fecacde 100644 --- a/renv.lock +++ b/renv.lock @@ -156,13 +156,13 @@ }, "jsonlite": { "Package": "jsonlite", - "Version": "1.8.8", + "Version": "1.8.7", "Source": "Repository", - "Repository": "CRAN", + "Repository": "RSPM", "Requirements": [ "methods" ], - "Hash": "e1b9c55281c5adc4dd113652d9e26768" + "Hash": "266a20443ca13c65688b2116d5220f76" }, "lifecycle": { "Package": "lifecycle", @@ -251,13 +251,13 @@ }, "renv": { "Package": "renv", - "Version": "1.0.7", + "Version": "1.0.11", "Source": "Repository", "Repository": "CRAN", "Requirements": [ "utils" ], - "Hash": "397b7b2a265bc5a7a06852524dabae20" + "Hash": "47623f66b4e80b3b0587bc5d7b309888" }, "rlang": { "Package": "rlang", diff --git a/renv/activate.R b/renv/activate.R index d13f993..0eb5108 100644 --- a/renv/activate.R +++ b/renv/activate.R @@ -2,7 +2,7 @@ local({ # the requested version of renv - version <- "1.0.7" + version <- "1.0.11" attr(version, "sha") <- NULL # the project directory @@ -98,6 +98,66 @@ local({ unloadNamespace("renv") # load bootstrap tools + ansify <- function(text) { + if (renv_ansify_enabled()) + renv_ansify_enhanced(text) + else + renv_ansify_default(text) + } + + renv_ansify_enabled <- function() { + + override <- Sys.getenv("RENV_ANSIFY_ENABLED", unset = NA) + if (!is.na(override)) + return(as.logical(override)) + + pane <- Sys.getenv("RSTUDIO_CHILD_PROCESS_PANE", unset = NA) + if (identical(pane, "build")) + return(FALSE) + + testthat <- Sys.getenv("TESTTHAT", unset = "false") + if (tolower(testthat) %in% "true") + return(FALSE) + + iderun <- Sys.getenv("R_CLI_HAS_HYPERLINK_IDE_RUN", unset = "false") + if (tolower(iderun) %in% "false") + return(FALSE) + + TRUE + + } + + renv_ansify_default <- function(text) { + text + } + + renv_ansify_enhanced <- function(text) { + + # R help links + pattern <- "`\\?(renv::(?:[^`])+)`" + replacement <- "`\033]8;;ide:help:\\1\a?\\1\033]8;;\a`" + text <- gsub(pattern, replacement, text, perl = TRUE) + + # runnable code + pattern <- "`(renv::(?:[^`])+)`" + replacement <- "`\033]8;;ide:run:\\1\a\\1\033]8;;\a`" + text <- gsub(pattern, replacement, text, perl = TRUE) + + # return ansified text + text + + } + + renv_ansify_init <- function() { + + envir <- renv_envir_self() + if (renv_ansify_enabled()) + assign("ansify", renv_ansify_enhanced, envir = envir) + else + assign("ansify", renv_ansify_default, envir = envir) + + } + `%||%` <- function(x, y) { if (is.null(x)) y else x } @@ -142,7 +202,10 @@ local({ # compute common indent indent <- regexpr("[^[:space:]]", lines) common <- min(setdiff(indent, -1L)) - leave - paste(substring(lines, common), collapse = "\n") + text <- paste(substring(lines, common), collapse = "\n") + + # substitute in ANSI links for executable renv code + ansify(text) } @@ -305,8 +368,11 @@ local({ quiet = TRUE ) - if ("headers" %in% names(formals(utils::download.file))) - args$headers <- renv_bootstrap_download_custom_headers(url) + if ("headers" %in% names(formals(utils::download.file))) { + headers <- renv_bootstrap_download_custom_headers(url) + if (length(headers) && is.character(headers)) + args$headers <- headers + } do.call(utils::download.file, args) @@ -385,10 +451,21 @@ local({ for (type in types) { for (repos in renv_bootstrap_repos()) { + # build arguments for utils::available.packages() call + args <- list(type = type, repos = repos) + + # add custom headers if available -- note that + # utils::available.packages() will pass this to download.file() + if ("headers" %in% names(formals(utils::download.file))) { + headers <- renv_bootstrap_download_custom_headers(repos) + if (length(headers) && is.character(headers)) + args$headers <- headers + } + # retrieve package database db <- tryCatch( as.data.frame( - utils::available.packages(type = type, repos = repos), + do.call(utils::available.packages, args), stringsAsFactors = FALSE ), error = identity @@ -470,6 +547,14 @@ local({ } + renv_bootstrap_github_token <- function() { + for (envvar in c("GITHUB_TOKEN", "GITHUB_PAT", "GH_TOKEN")) { + envval <- Sys.getenv(envvar, unset = NA) + if (!is.na(envval)) + return(envval) + } + } + renv_bootstrap_download_github <- function(version) { enabled <- Sys.getenv("RENV_BOOTSTRAP_FROM_GITHUB", unset = "TRUE") @@ -477,16 +562,16 @@ local({ return(FALSE) # prepare download options - pat <- Sys.getenv("GITHUB_PAT") - if (nzchar(Sys.which("curl")) && nzchar(pat)) { + token <- renv_bootstrap_github_token() + if (nzchar(Sys.which("curl")) && nzchar(token)) { fmt <- "--location --fail --header \"Authorization: token %s\"" - extra <- sprintf(fmt, pat) + extra <- sprintf(fmt, token) saved <- options("download.file.method", "download.file.extra") options(download.file.method = "curl", download.file.extra = extra) on.exit(do.call(base::options, saved), add = TRUE) - } else if (nzchar(Sys.which("wget")) && nzchar(pat)) { + } else if (nzchar(Sys.which("wget")) && nzchar(token)) { fmt <- "--header=\"Authorization: token %s\"" - extra <- sprintf(fmt, pat) + extra <- sprintf(fmt, token) saved <- options("download.file.method", "download.file.extra") options(download.file.method = "wget", download.file.extra = extra) on.exit(do.call(base::options, saved), add = TRUE) From 85f8334bdf2db47eea3398143733955e527a0fec Mon Sep 17 00:00:00 2001 From: Luca Belmonte Date: Tue, 22 Jul 2025 16:15:45 +0000 Subject: [PATCH 2/3] EUPL license plus library versioning to fullfil the ones in databricks renv.lock --- DESCRIPTION | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index a0608ea..d9bd1f3 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -29,14 +29,14 @@ Description: A wrapper around the European and Mediterranean Plant Protection wrangling function to integrate taxonomy and rank information, and a function that returns the list of member countries for each Regional Plant Protection Organization acronym which is used in the 'EPPO' database. -License: GPL-3 +License: EUPL (>= 1.2) URL: https://github.com/openefsa/eppoFindeR, https://openefsa.github.io/eppoFindeR/ BugReports: https://github.com/openefsa/eppoFindeR/issues Depends: R (>= 4.0.0) Imports: httr (>= 1.4.7), - jsonlite (>= 1.8.8), + jsonlite (>= 1.8.7), tidyr (>= 1.3.1), dplyr (>= 1.1.4), glue (>= 1.7.0), @@ -46,8 +46,8 @@ Imports: lifecycle (>= 1.0.4) Suggests: devtools (>= 2.4.5), - roxygen2 (>= 7.3.1), - testthat (>= 3.2.1), + roxygen2 (>= 7.2.1), + testthat (>= 3.0.0), usethis (>= 2.2.3), knitr (>= 1.0), rmarkdown (>= 2.0), @@ -60,3 +60,4 @@ VignetteBuilder: knitr Config/Needs/website: pkgdown Repository: CRAN Roxygen: list(markdown = TRUE) +Depends: R (>= 4.0.0) From edc3b1264bd6e8b9e1c7a72b9cc8fb26e710520d Mon Sep 17 00:00:00 2001 From: Luca Belmonte Date: Tue, 22 Jul 2025 16:16:34 +0000 Subject: [PATCH 3/3] drops duplicated dependencies lines --- DESCRIPTION | 1 - 1 file changed, 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index d9bd1f3..0828e32 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -60,4 +60,3 @@ VignetteBuilder: knitr Config/Needs/website: pkgdown Repository: CRAN Roxygen: list(markdown = TRUE) -Depends: R (>= 4.0.0)