11# # Install dependencies of R package for testing. The list might not be
22# # up-to-date, check DESCRIPTION for the latest list and update this one if
33# # inconsistent is found.
4- pkgs <- c(
5- # # CI
4+ ci_pkgs <- c(
65 " pkgbuild" ,
76 " roxygen2" ,
87 " XML" ,
98 " cplm" ,
10- " e1071" ,
11- # # suggests
9+ " e1071"
10+ )
11+
12+ suggests_pkgs <- c(
1213 " knitr" ,
1314 " rmarkdown" ,
1415 " ggplot2" ,
@@ -23,31 +24,62 @@ pkgs <- c(
2324 " igraph" ,
2425 " float" ,
2526 " titanic" ,
26- " RhpcBLASctl" ,
27- # # imports
27+ " RhpcBLASctl"
28+ )
29+
30+ imports_pkgs <- c(
2831 " Matrix" ,
2932 " data.table" ,
3033 " jsonlite"
3134)
3235
36+ dependency_scopes <- list (
37+ ci = ci_pkgs ,
38+ suggests = suggests_pkgs ,
39+ imports = imports_pkgs ,
40+ doc_test = c(imports_pkgs , " DirichletReg" , " testthat" )
41+ )
42+
43+ scopes <- commandArgs(trailingOnly = TRUE )
44+ if (! length(scopes )) {
45+ scopes <- c(" ci" , " suggests" , " imports" )
46+ }
47+ scopes <- gsub(" -" , " _" , scopes , fixed = TRUE )
48+ if (" all" %in% scopes ) {
49+ scopes <- names(dependency_scopes )
50+ }
51+
52+ unknown_scopes <- setdiff(scopes , names(dependency_scopes ))
53+ if (length(unknown_scopes )) {
54+ stop(
55+ " Unknown dependency scope(s): " ,
56+ paste(unknown_scopes , collapse = " , " ),
57+ " . Valid scopes are: " ,
58+ paste(c(names(dependency_scopes ), " all" ), collapse = " , " )
59+ )
60+ }
61+
62+ pkgs <- unique(unlist(dependency_scopes [scopes ], use.names = FALSE ))
63+
3364ncpus <- parallel :: detectCores()
3465print(paste0(" Using " , ncpus , " cores to install dependencies." ))
66+ print(paste0(" Installing dependency scopes: " , paste(scopes , collapse = " , " )))
3567
3668if (.Platform $ OS.type == " unix" ) {
3769 print(" Installing source packages on unix." )
3870 install.packages(
3971 pkgs ,
40- repo = " https://cloud.r-project.org" ,
72+ repos = " https://cloud.r-project.org" ,
4173 dependencies = c(" Depends" , " Imports" , " LinkingTo" ),
42- Ncpus = parallel :: detectCores()
74+ Ncpus = ncpus
4375 )
4476} else {
4577 print(" Installing binary packages on Windows." )
4678 install.packages(
4779 pkgs ,
48- repo = " https://cloud.r-project.org" ,
80+ repos = " https://cloud.r-project.org" ,
4981 dependencies = c(" Depends" , " Imports" , " LinkingTo" ),
50- Ncpus = parallel :: detectCores() ,
82+ Ncpus = ncpus ,
5183 type = " binary"
5284 )
5385}
0 commit comments