Skip to content

Commit

Permalink
avoid reinstalling (and potentially downgrading) if req already satis…
Browse files Browse the repository at this point in the history
…fied
  • Loading branch information
infotroph committed Dec 11, 2023
1 parent 34c4981 commit b8a29ae
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 21 deletions.
45 changes: 27 additions & 18 deletions docker/depends/pecan.depends.R
Original file line number Diff line number Diff line change
Expand Up @@ -143,21 +143,30 @@ options(repos = c(
getOption('repos'),
sub(r'(\d{4}-\d{2}-\d{2})', 'latest', getOption('repos'))
))
remotes::install_version('abind', '>= 1.4.5', dependencies = TRUE, upgrade = FALSE)
remotes::install_version('coda', '>= 0.18', dependencies = TRUE, upgrade = FALSE)
remotes::install_version('geonames', '> 0.998', dependencies = TRUE, upgrade = FALSE)
remotes::install_version('lubridate', '>= 1.7.0', dependencies = TRUE, upgrade = FALSE)
remotes::install_version('magic', '>= 1.5.0', dependencies = TRUE, upgrade = FALSE)
remotes::install_version('mockery', '>= 0.4.3', dependencies = TRUE, upgrade = FALSE)
remotes::install_version('MODISTools', '>= 1.1.0', dependencies = TRUE, upgrade = FALSE)
remotes::install_version('ncdf4', '>= 1.15', dependencies = TRUE, upgrade = FALSE)
remotes::install_version('plyr', '>= 1.8.4', dependencies = TRUE, upgrade = FALSE)
remotes::install_version('purrr', '>= 0.2.3', dependencies = TRUE, upgrade = FALSE)
remotes::install_version('reshape2', '>= 1.4.2', dependencies = TRUE, upgrade = FALSE)
remotes::install_version('rlang', '>= 0.2.0', dependencies = TRUE, upgrade = FALSE)
remotes::install_version('rmarkdown', '>= 2.19', dependencies = TRUE, upgrade = FALSE)
remotes::install_version('stringr', '>= 1.1.0', dependencies = TRUE, upgrade = FALSE)
remotes::install_version('testthat', '>= 3.0.4', dependencies = TRUE, upgrade = FALSE)
remotes::install_version('TruncatedNormal', '>= 2.2', dependencies = TRUE, upgrade = FALSE)
remotes::install_version('vdiffr', '>= 1.0.2', dependencies = TRUE, upgrade = FALSE)
remotes::install_version('XML', '>= 3.98-1.4', dependencies = TRUE, upgrade = FALSE)
install_if_version <- function(pkg, version) {
vers <- gsub('[^[:digit:].-]+', '', version)
cmp <- get(gsub('[^<>=]+', '', version))
ok <- requireNamespace(pkg, quietly = TRUE) &&
cmp(packageVersion(pkg), vers)
if (!ok) {
remotes::install_version(pkg, version, dependencies = TRUE, upgrade = FALSE)
}
}
install_if_version('abind', '>= 1.4.5')
install_if_version('coda', '>= 0.18')
install_if_version('geonames', '> 0.998')
install_if_version('lubridate', '>= 1.7.0')
install_if_version('magic', '>= 1.5.0')
install_if_version('mockery', '>= 0.4.3')
install_if_version('MODISTools', '>= 1.1.0')
install_if_version('ncdf4', '>= 1.15')
install_if_version('plyr', '>= 1.8.4')
install_if_version('purrr', '>= 0.2.3')
install_if_version('reshape2', '>= 1.4.2')
install_if_version('rlang', '>= 0.2.0')
install_if_version('rmarkdown', '>= 2.19')
install_if_version('stringr', '>= 1.1.0')
install_if_version('testthat', '>= 3.0.4')
install_if_version('TruncatedNormal', '>= 2.2')
install_if_version('vdiffr', '>= 1.0.2')
install_if_version('XML', '>= 3.98-1.4')
13 changes: 10 additions & 3 deletions scripts/generate_dependencies.R
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,7 @@ unversioned_deps <- uniq_deps[uniq_deps$version == "*",]$package
versioned_dep_install_calls <- uniq_deps[uniq_deps$version != "*",] |>
dplyr::mutate(
inst_call = paste0(
"remotes::install_version(",
shQuote(package), ", ", shQuote(version),
", dependencies = TRUE, upgrade = FALSE)")) |>
"install_if_version(", shQuote(package), ", ", shQuote(version), ")")) |>
dplyr::pull(inst_call) |>
sort()

Expand Down Expand Up @@ -193,5 +191,14 @@ cat("#!/usr/bin/env Rscript",
" getOption('repos'),",
" sub(r'(\\d{4}-\\d{2}-\\d{2})', 'latest', getOption('repos'))",
"))",
"install_if_version <- function(pkg, version) {",
" vers <- gsub('[^[:digit:].-]+', '', version)",
" cmp <- get(gsub('[^<>=]+', '', version))",
" ok <- requireNamespace(pkg, quietly = TRUE) &&",
" cmp(packageVersion(pkg), vers)",
" if (!ok) {",
" remotes::install_version(pkg, version, dependencies = TRUE, upgrade = FALSE)",
" }",
"}",
paste(versioned_dep_install_calls, collapse = "\n"),
file = "docker/depends/pecan.depends.R", sep = "\n", append = FALSE)

0 comments on commit b8a29ae

Please sign in to comment.