Skip to content

Commit

Permalink
Merge branch 'main' into feature/ignore-missing
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborcsardi committed Apr 5, 2024
2 parents b021072 + c6a7ac7 commit 8808a9d
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 46 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
dependencies that are unavailable
(https://github.com/r-lib/pak/issues/606).

* pkgdepends now automatically ignores soft dependencies that have an
incompatible OS type (`OS_type` entry in `DESCRIPTION`) when installing
packages.

# pkgdepends 0.7.2

* pkgdepends now supports the `*` wildcard for parameter specifications,
Expand Down
6 changes: 4 additions & 2 deletions R/resolution-df.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ res_make_empty_df <- local({
extra = list(), # any extra data (e.g. GitHub sha)
dep_types= list(),
params = list(),
sysreqs = character()
sysreqs = character(),
os_type = character()
)
}
data
Expand Down Expand Up @@ -70,7 +71,8 @@ res_df_defaults <- local({
extra = list(list()),
dep_types= list("default"),
params = list(character()),
sysreqs = NA_character_
sysreqs = NA_character_,
os_type = NA_character_
)
}
data
Expand Down
2 changes: 1 addition & 1 deletion R/resolution.R
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ resolve_from_metadata <- function(remotes, direct, config, cache,
"ref", "type", "status", "package", "version", "license",
"needscompilation", "priority", "md5sum", "platform",
"rversion", "repodir", "target", "deps", "sources", "mirror",
"filesize", "sha256", "sysreqs")
"filesize", "sha256", "sysreqs", "os_type")

cols <- intersect(names(data), cols)

Expand Down
22 changes: 22 additions & 0 deletions R/solve.R
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ pkgplan_i_create_lp_problem <- function(pkgs, config, policy) {

lp <- pkgplan_i_lp_init(pkgs, config, policy)
lp <- pkgplan_i_lp_objectives(lp)
lp <- pkgplan_i_lp_os_type(config, lp)
lp <- pkgplan_i_lp_force_source(lp)
lp <- pkgplan_i_lp_failures(lp)
lp <- pkgplan_i_lp_ignore(lp)
Expand Down Expand Up @@ -301,6 +302,20 @@ pkgplan_i_lp_objectives <- function(lp) {
lp
}

pkgplan_i_lp_os_type <- function(config, lp) {
if (config$get("goal") != "install") return(lp)
if (! "os_type" %in% names(lp$pkgs)) return(lp)
os <- os_type()
bad <- which(!is.na(lp$pkgs$os_type) & lp$pkgs$os_type != os)
for (wh in bad) {
lp <- pkgplan_i_lp_add_cond(lp, wh, op = "==", rhs = 0,
type = "matching-platform")
}
lp$ruled_out <- c(lp$ruled_out, bad)

lp
}

pkgplan_i_lp_force_source <- function(lp) {
# if source package is forced, then rule out binaries
src_req <- vlapply(lp$pkgs$params, is_true_param, "source")
Expand Down Expand Up @@ -623,6 +638,13 @@ pkgplan_i_lp_dependencies <- function(lp, config) {
failed <- pkgs$status == "FAILED"
ignored <- ignored | (ignore_unavail & failed)

# ignore packages with the wrong OS type
if (config$get("goal") == "install") {
os <- os_type()
bad <- which(!is.na(pkgs$os_type) & pkgs$os_type != os)
if (length(bad) > 0) ignored[bad] <- TRUE
}

soft_deps <- tolower(pkg_dep_types_soft())

## 4. Package dependencies must be satisfied
Expand Down
6 changes: 5 additions & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -494,4 +494,8 @@ backtick <- function(x) {

collapse <- function(x, ...) {
cli::ansi_collapse(x, ...)
}
}

na_omit <- function(x) {
x[!is.na(x)]
}
3 changes: 3 additions & 0 deletions tests/testthat/_snaps/pillar-1.9.0/type-bioc.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,7 @@
$sysreqs
[1] NA
$os_type
[1] NA

3 changes: 3 additions & 0 deletions tests/testthat/_snaps/pillar-1.9.0/type-git.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@
$sysreqs
[1] ""
$os_type
[1] NA
$cache_status
[1] "miss"
Expand Down
84 changes: 42 additions & 42 deletions tests/testthat/_snaps/type-cran.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Code
snapshot(res, extra = "all")
Output
# A data frame: 1 x 30
# A data frame: 1 x 31
ref type direct directpkg status package version license
<chr> <chr> <lgl> <lgl> <chr> <chr> <chr> <chr>
1 pkg1 standard TRUE TRUE OK pkg1 1.0.0 <NA>
Expand All @@ -16,9 +16,9 @@
mirror sources remote error metadata
<chr> <list> <list> <list> <list>
1 http://127.0.0.1:<port>/ <chr [2]> <rmt_rf_s [6]> <list [0]> <chr [6]>
extra dep_types params sysreqs cache_status
<list> <list> <list> <chr> <chr>
1 <list [0]> <chr [3]> <chr [0]> <NA> miss
extra dep_types params sysreqs os_type cache_status
<list> <list> <list> <chr> <chr> <chr>
1 <list [0]> <chr [3]> <chr [0]> <NA> <NA> miss
+ sources:
http://127.0.0.1:<port>//src/contrib/pkg1_1.0.0.tar.gz, http://127.0.0.1:<port>//src/contrib/Archive/pkg1/pkg1_1.0.0.tar.gz
+ remote:
Expand All @@ -35,7 +35,7 @@
Code
snapshot(res, extra = "all")
Output
# A data frame: 3 x 30
# A data frame: 3 x 31
ref type direct directpkg status package version license
<chr> <chr> <lgl> <lgl> <chr> <chr> <chr> <chr>
1 pkg2 standard FALSE FALSE OK pkg2 1.0.0 <NA>
Expand All @@ -56,11 +56,11 @@
1 http://127.0.0.1:<port>/ <chr [2]> <rmt_rf_s [6]> <list [0]> <chr [6]>
2 http://127.0.0.1:<port>/ <chr [2]> <rmt_rf_c [6]> <list [0]> <chr [6]>
3 http://127.0.0.1:<port>/ <chr [2]> <rmt_rf_s [6]> <list [0]> <chr [6]>
extra dep_types params sysreqs cache_status
<list> <list> <list> <chr> <chr>
1 <list [0]> <chr [3]> <chr [0]> <NA> miss
2 <list [0]> <chr [3]> <chr [0]> <NA> miss
3 <list [0]> <chr [3]> <chr [0]> <NA> miss
extra dep_types params sysreqs os_type cache_status
<list> <list> <list> <chr> <chr> <chr>
1 <list [0]> <chr [3]> <chr [0]> <NA> <NA> miss
2 <list [0]> <chr [3]> <chr [0]> <NA> <NA> miss
3 <list [0]> <chr [3]> <chr [0]> <NA> <NA> miss
+ sources:
http://127.0.0.1:<port>//src/contrib/pkg2_1.0.0.tar.gz, http://127.0.0.1:<port>//src/contrib/Archive/pkg2/pkg2_1.0.0.tar.gz
http://127.0.0.1:<port>//src/contrib/pkg3_1.0.0.tar.gz, http://127.0.0.1:<port>//src/contrib/Archive/pkg3/pkg3_1.0.0.tar.gz
Expand All @@ -87,7 +87,7 @@
Code
snapshot(res, extra = "all")
Output
# A data frame: 3 x 30
# A data frame: 3 x 31
ref type direct directpkg status package version license
<chr> <chr> <lgl> <lgl> <chr> <chr> <chr> <chr>
1 pkg1 standard FALSE FALSE OK pkg1 1.0.0 <NA>
Expand All @@ -108,11 +108,11 @@
1 http://127.0.0.1:<port>/ <chr [2]> <rmt_rf_s [6]> <list [0]> <chr [6]>
2 http://127.0.0.1:<port>/ <chr [2]> <rmt_rf_s [6]> <list [0]> <chr [6]>
3 http://127.0.0.1:<port>/ <chr [2]> <rmt_rf_s [6]> <list [0]> <chr [6]>
extra dep_types params sysreqs cache_status
<list> <list> <list> <chr> <chr>
1 <list [0]> <chr [3]> <chr [0]> <NA> miss
2 <list [0]> <chr [3]> <chr [0]> <NA> miss
3 <list [0]> <chr [3]> <chr [0]> <NA> miss
extra dep_types params sysreqs os_type cache_status
<list> <list> <list> <chr> <chr> <chr>
1 <list [0]> <chr [3]> <chr [0]> <NA> <NA> miss
2 <list [0]> <chr [3]> <chr [0]> <NA> <NA> miss
3 <list [0]> <chr [3]> <chr [0]> <NA> <NA> miss
+ sources:
http://127.0.0.1:<port>//src/contrib/pkg1_1.0.0.tar.gz, http://127.0.0.1:<port>//src/contrib/Archive/pkg1/pkg1_1.0.0.tar.gz
http://127.0.0.1:<port>//src/contrib/pkg2_1.0.0.tar.gz, http://127.0.0.1:<port>//src/contrib/Archive/pkg2/pkg2_1.0.0.tar.gz
Expand All @@ -139,7 +139,7 @@
Code
snapshot(res, extra = "all")
Output
# A data frame: 1 x 30
# A data frame: 1 x 31
ref type direct directpkg status package
<chr> <chr> <lgl> <lgl> <chr> <chr>
1 cran::xxyyzzqwertyqwerty cran TRUE TRUE FAILED xxyyzzqwertyqwerty
Expand All @@ -155,9 +155,9 @@
remote error metadata extra dep_types params sysreqs
<list> <list> <list> <list> <list> <list> <chr>
1 <rmt_rf_c [6]> <error> <list [0]> <list [0]> <chr [3]> <chr [0]> <NA>
cache_status
<chr>
1 miss
os_type cache_status
<chr> <chr>
1 <NA> miss
+ sources:
NA
+ remote:
Expand All @@ -174,7 +174,7 @@
Code
snapshot(res, extra = "all")
Output
# A data frame: 2 x 30
# A data frame: 2 x 31
ref type direct directpkg status package
<chr> <chr> <lgl> <lgl> <chr> <chr>
1 cran::pkg1 cran TRUE TRUE OK pkg1
Expand All @@ -195,10 +195,10 @@
<list> <list> <list> <list> <list> <list> <list>
1 <chr [2]> <rmt_rf_c [6]> <list [0]> <chr [6]> <list [0]> <chr [3]> <chr [0]>
2 <chr [1]> <rmt_rf_c [6]> <error> <list [0]> <list [0]> <chr [3]> <chr [0]>
sysreqs cache_status
<chr> <chr>
1 <NA> miss
2 <NA> miss
sysreqs os_type cache_status
<chr> <chr> <chr>
1 <NA> <NA> miss
2 <NA> <NA> miss
+ sources:
http://127.0.0.1:<port>//src/contrib/pkg1_1.0.0.tar.gz, http://127.0.0.1:<port>//src/contrib/Archive/pkg1/pkg1_1.0.0.tar.gz
NA
Expand All @@ -220,7 +220,7 @@
Code
snapshot(res, extra = "all")
Output
# A data frame: 1 x 30
# A data frame: 1 x 31
ref type direct directpkg status package version license
<chr> <chr> <lgl> <lgl> <chr> <chr> <chr> <chr>
1 cran::pkg1@current cran TRUE TRUE OK pkg1 1.0.0 <NA>
Expand All @@ -233,9 +233,9 @@
mirror sources remote error metadata
<chr> <list> <list> <list> <list>
1 http://127.0.0.1:<port>/ <chr [2]> <rmt_rf_c [6]> <list [0]> <chr [6]>
extra dep_types params sysreqs cache_status
<list> <list> <list> <chr> <chr>
1 <list [0]> <chr [3]> <chr [0]> <NA> miss
extra dep_types params sysreqs os_type cache_status
<list> <list> <list> <chr> <chr> <chr>
1 <list [0]> <chr [3]> <chr [0]> <NA> <NA> miss
+ sources:
http://127.0.0.1:<port>//src/contrib/pkg1_1.0.0.tar.gz, http://127.0.0.1:<port>//src/contrib/Archive/pkg1/pkg1_1.0.0.tar.gz
+ remote:
Expand All @@ -252,7 +252,7 @@
Code
snapshot(res, extra = "all")
Output
# A data frame: 2 x 30
# A data frame: 2 x 31
ref type direct directpkg status package version license
<chr> <chr> <lgl> <lgl> <chr> <chr> <chr> <chr>
1 [email protected] standard TRUE TRUE OK pkg1 0.9.0 <NA>
Expand All @@ -269,10 +269,10 @@
<chr> <list> <list> <list> <list>
1 <NA> <chr [1]> <rmt_rf_s [8]> <list [0]> <chr [8]>
2 http://127.0.0.1:<port>/ <chr [2]> <rmt_rf_s [6]> <list [0]> <chr [6]>
extra dep_types params sysreqs cache_status
<list> <list> <list> <chr> <chr>
1 <named list [1]> <chr [3]> <chr [0]> "" miss
2 <list [0]> <chr [3]> <chr [0]> <NA> miss
extra dep_types params sysreqs os_type cache_status
<list> <list> <list> <chr> <chr> <chr>
1 <named list [1]> <chr [3]> <chr [0]> "" <NA> miss
2 <list [0]> <chr [3]> <chr [0]> <NA> <NA> miss
+ sources:
http://127.0.0.1:<port>//src/contrib/Archive/pkg1/pkg1_0.9.0.tar.gz
http://127.0.0.1:<port>//src/contrib/pkg1_1.0.0.tar.gz, http://127.0.0.1:<port>//src/contrib/Archive/pkg1/pkg1_1.0.0.tar.gz
Expand All @@ -294,7 +294,7 @@
Code
snapshot(res, extra = "all")
Output
# A data frame: 1 x 30
# A data frame: 1 x 31
ref type direct directpkg status package version license
<chr> <chr> <lgl> <lgl> <chr> <chr> <chr> <chr>
1 [email protected] standard TRUE TRUE OK pkg1 1.0.0 <NA>
Expand All @@ -307,9 +307,9 @@
mirror sources remote error metadata
<chr> <list> <list> <list> <list>
1 http://127.0.0.1:<port>/ <chr [2]> <rmt_rf_s [6]> <list [0]> <chr [6]>
extra dep_types params sysreqs cache_status
<list> <list> <list> <chr> <chr>
1 <list [0]> <chr [3]> <chr [0]> <NA> miss
extra dep_types params sysreqs os_type cache_status
<list> <list> <list> <chr> <chr> <chr>
1 <list [0]> <chr [3]> <chr [0]> <NA> <NA> miss
+ sources:
http://127.0.0.1:<port>//src/contrib/pkg1_1.0.0.tar.gz, http://127.0.0.1:<port>//src/contrib/Archive/pkg1/pkg1_1.0.0.tar.gz
+ remote:
Expand All @@ -326,7 +326,7 @@
Code
snapshot(res, extra = "all")
Output
# A data frame: 1 x 30
# A data frame: 1 x 31
ref type direct directpkg status package version license
<chr> <chr> <lgl> <lgl> <chr> <chr> <chr> <chr>
1 pkg1@>=0.9.0 standard TRUE TRUE FAILED pkg1 <NA> <NA>
Expand All @@ -339,9 +339,9 @@
remote error metadata extra dep_types params sysreqs
<list> <list> <list> <list> <list> <list> <chr>
1 <rmt_rf_s [6]> <async_rj> <list [0]> <list [0]> <chr [3]> <chr [0]> <NA>
cache_status
<chr>
1 miss
os_type cache_status
<chr> <chr>
1 <NA> miss
+ sources:
NA
+ remote:
Expand Down

0 comments on commit 8808a9d

Please sign in to comment.