fix(build): build packages requiring newer R on compatible minors (#216)
Some checks failed
ci/crow/cron/process-updates/12 Pipeline failed
ci/crow/cron/process-updates/2 Pipeline was successful
ci/crow/cron/process-updates/9 Pipeline was successful
ci/crow/cron/process-updates/8 Pipeline failed
ci/crow/cron/process-updates/16 Pipeline failed
ci/crow/cron/process-updates/14 Pipeline failed
ci/crow/cron/process-updates/15 Pipeline was successful
ci/crow/cron/process-updates/10 Pipeline was successful
ci/crow/cron/process-updates/4 Pipeline was successful
ci/crow/cron/process-updates/3 Pipeline was successful
ci/crow/cron/process-updates/11 Pipeline was successful
ci/crow/cron/process-updates/13 Pipeline was successful
ci/crow/cron/process-updates/5 Pipeline was successful
ci/crow/cron/process-updates/7 Pipeline was successful
ci/crow/cron/process-updates/1 Pipeline was successful
ci/crow/cron/process-updates/6 Pipeline was successful
Some checks failed
ci/crow/cron/process-updates/12 Pipeline failed
ci/crow/cron/process-updates/2 Pipeline was successful
ci/crow/cron/process-updates/9 Pipeline was successful
ci/crow/cron/process-updates/8 Pipeline failed
ci/crow/cron/process-updates/16 Pipeline failed
ci/crow/cron/process-updates/14 Pipeline failed
ci/crow/cron/process-updates/15 Pipeline was successful
ci/crow/cron/process-updates/10 Pipeline was successful
ci/crow/cron/process-updates/4 Pipeline was successful
ci/crow/cron/process-updates/3 Pipeline was successful
ci/crow/cron/process-updates/11 Pipeline was successful
ci/crow/cron/process-updates/13 Pipeline was successful
ci/crow/cron/process-updates/5 Pipeline was successful
ci/crow/cron/process-updates/7 Pipeline was successful
ci/crow/cron/process-updates/1 Pipeline was successful
ci/crow/cron/process-updates/6 Pipeline was successful
This commit is contained in:
parent
d80d3e814e
commit
6b764d2014
1 changed files with 256 additions and 0 deletions
75
local/newer-r-helpers.R
Normal file
75
local/newer-r-helpers.R
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
# Evaluate every R constraint, including patch-level and upper bounds.
|
||||
r_requirement_satisfied <- function(depends, r_version) {
|
||||
if (is.na(depends) || !nzchar(trimws(depends))) {
|
||||
return(TRUE)
|
||||
}
|
||||
entries <- trimws(strsplit(depends, ",", fixed = TRUE)[[1L]])
|
||||
entries <- entries[grepl("^R(\\s|\\(|$)", entries)]
|
||||
all(vapply(
|
||||
entries,
|
||||
function(entry) {
|
||||
if (entry == "R") {
|
||||
return(TRUE)
|
||||
}
|
||||
match <- regmatches(
|
||||
entry,
|
||||
regexec(
|
||||
"^R\\s*\\(\\s*(>=|<=|==|>|<)\\s*([0-9]+(?:[.-][0-9]+)*)\\s*\\)$",
|
||||
entry,
|
||||
perl = TRUE
|
||||
)
|
||||
)[[1L]]
|
||||
if (length(match) != 3L) {
|
||||
stop("Cannot parse R dependency: ", entry)
|
||||
}
|
||||
comparison <- utils::compareVersion(r_version, match[3L])
|
||||
switch(
|
||||
match[2L],
|
||||
">=" = comparison >= 0L,
|
||||
"<=" = comparison <= 0L,
|
||||
"==" = comparison == 0L,
|
||||
">" = comparison > 0L,
|
||||
"<" = comparison < 0L
|
||||
)
|
||||
},
|
||||
logical(1L)
|
||||
))
|
||||
}
|
||||
|
||||
# Use unfiltered current CRAN metadata: available.packages() would hide exactly
|
||||
# the packages that cannot run under the primary interpreter.
|
||||
# Propagate R incompatibility through required dependencies, not Suggests.
|
||||
newer_r_candidates <- function(db, primary_r, target_r) {
|
||||
db <- as.data.frame(db, stringsAsFactors = FALSE)
|
||||
# CRAN also lists R-specific Recommended copies (e.g. Matrix for R-devel).
|
||||
# Prefer the ordinary contrib record, or a future-R copy can incorrectly
|
||||
# block every package depending on Matrix on all released interpreters.
|
||||
if ("Path" %in% names(db)) {
|
||||
db <- db[order(!is.na(db$Path) & nzchar(db$Path)), , drop = FALSE]
|
||||
}
|
||||
db <- db[!duplicated(db$Package), , drop = FALSE]
|
||||
deps <- tools::package_dependencies(
|
||||
packages = db$Package,
|
||||
db = as.matrix(db),
|
||||
which = c("Depends", "Imports", "LinkingTo"),
|
||||
recursive = FALSE
|
||||
)
|
||||
supported <- function(version) {
|
||||
ok <- vapply(db$Depends, r_requirement_satisfied, logical(1L), version)
|
||||
repeat {
|
||||
blocked <- db$Package[!ok]
|
||||
next_ok <- ok &
|
||||
!vapply(deps, function(x) any(x %in% blocked), logical(1L))
|
||||
if (identical(ok, next_ok)) {
|
||||
return(ok)
|
||||
}
|
||||
ok <- next_ok
|
||||
}
|
||||
}
|
||||
selected <- !supported(primary_r) & supported(target_r)
|
||||
if ("OS_type" %in% names(db)) {
|
||||
selected <- selected & (is.na(db$OS_type) | db$OS_type != "windows")
|
||||
}
|
||||
result <- db[selected, c("Package", "Version"), drop = FALSE]
|
||||
result[order(result$Package), , drop = FALSE]
|
||||
}
|
||||
Loading…
Reference in a new issue