Skip to content

More flexible dependency versions filters #613

@jeroen

Description

@jeroen

Currently we simply call install.packages() to get dependencies, which always prefers the highest version of each R package. However in some cases may need something else.

For example, in we want 'basilisk.utils' from the first repo, however the one in the second repo is higher.

# Problem: we want 'basilisk.utils' from myrepo even though it has a lower version
db <- available.packages(repos = c(
  myrepo = 'https://bioconductor-source.r-universe.dev',
  bioc = 'https://bioc.r-universe.dev'
))

# Gives us the latter
subset(db, row.names(db) == 'basilisk.utils')

The "filters" argument in availabe.packages() allows us to customize this (search base R source for available_packages_filters_db). For example this should filter duplicates left-to-right I think:

db <- available.packages(repos = c(
  myrepo = 'https://bioconductor-source.r-universe.dev',
  bioc = 'https://bioc.r-universe.dev/'
), filters = list(
  "R_version", 
  "OS_type",
  "subarch",
  function(db){
    db[!duplicated(row.names(db)),]
  }
))

Or to make this apply only to bioc we could do like

options(available_packages_filters = list(
  "R_version", "OS_type", "subarch",
  function(db){
    isbioc <- grepl("https://bioc.r-universe.dev", fixed = TRUE, db[,'Repository'])
    biocdups <- duplicated(row.names(db)) & isbioc
    db[!biocdups,]
  },
  "duplicates"
))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions