-
Notifications
You must be signed in to change notification settings - Fork 0
/
r-package-recommendations-check.R
44 lines (41 loc) · 1.6 KB
/
r-package-recommendations-check.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
## recommended version numbers, just because these are the versions
## that sw happens to have. this sourced r file is automatically
## produced using R/update-r-package-recommendations.R
dependencies = source("global-metadata/r-package-recommendations.R")$value
inst_deps = names(dependencies) %in% installed.packages()[, "Package"]
if (!all(inst_deps)) {
missing_pkgs = names(dependencies)[!inst_deps]
message(
"------------\n"
, "attempting to install the following r packages because they\nare required for at least some scripts:\n"
, paste0(sprintf(" %s", missing_pkgs), collapse = "\n")
, "\n------------"
)
canmod = c("iidda", "iidda.analysis", "iidda.api", "rapiclient", "LBoM.tools") ## can we drop LBoM.tools?
missing_canmod = intersect(missing_pkgs, canmod)
missing_cran = setdiff(missing_pkgs, missing_canmod)
install.packages(missing_cran, repos = list(CRAN = "https://cran.r-project.org"))
install.packages(missing_canmod
, repos = c("https://canmod.r-universe.dev", "https://cran.r-project.org")
)
}
dependencies = dependencies[inst_deps]
versions = (dependencies
|> names()
|> lapply(packageVersion)
|> vapply(as.character, character(1L))
|> setNames(names(dependencies))
)
if (!identical(dependencies, versions)) {
for (dep in names(dependencies)) {
if (as.package_version(dependencies[dep]) > as.package_version(versions[dep])) {
warning(
"package "
, dep
, " is older than is recommended. "
, "you might want to update it. "
, "see https://github.com/canmod/iidda#requirements for details."
)
}
}
}