Refining system requirements
This is an early version of a PR that will enhance pak::pkg_system_requirements() so that it will check all R and Bioconductor type repositories on a given packagemanager (only URL of packagemanager needs to be specified) and extract system dependencies of a given set of packages.
Previously, pak::pkg_system_requirements() only worked for a single repository and the list of packages had to be split before making a function call.
In addition, the PR also automatically detects if a repository is of type Bioconductor and then appends bioc_version=x.y to the API call.
Example:
> pak::pkg_system_requirements(c("tidyverse","clustermq","flowcatchR"), os="ubuntu", os_release="20.04")
[1] "apt-get install -y imagemagick libmagick++-dev gsfonts libfreetype6-dev libfribidi-dev libharfbuzz-dev libfontconfig1-dev pandoc libicu-dev libjpeg-dev libpng-dev libtiff-dev libzmq3-dev zlib1g-dev libssl-dev make libxml2-dev libcurl4-openssl-dev"
> pak::pkg_system_requirements(c("tidyverse","clustermq","flowcatchR"), os="centos", os_release="7")
[1] "yum install -y epel-release"
[2] "yum install -y ImageMagick ImageMagick-c++-devel freetype-devel fribidi-devel harfbuzz-devel fontconfig-devel pandoc libicu-devel libjpeg-turbo-devel libpng-devel libtiff-devel zeromq-devel zlib-devel openssl-devel make libxml2-devel libcurl-devel"
Without the PR pak will report
> pak::pkg_system_requirements(c("tidyverse","clustermq","flowcatchR"), os="ubuntu", os_release="20.04")
Error:
! error in pak subprocess
Caused by error in `asNamespace("pak")$system_requirements_internal(...)`:
! Could not locate package 'flowcatchR'
Type .Last.error to see the more details.
which is expected as flowcatchR is a Bioconductor package and as such not in the (default) CRAN repo.
Note:
- I deliberately left some verbose debug statements in. Also the code probably can be streamlined further by a more skilled R developers. Just wanted to make a start to get this functionality in in order to increase it's usability.
- the question around Bioconductor support probably needs to be discussed in more detail as the current PR has a hard dependency on the R package
BiocManager.
Thanks! Unfortunately, this approach is not going to work, for a number of reasons. pak does not use the PPM API any more, to be able to match system requirements to individual R packages. Instead it matches SystemRequirements fields manually to the database at https://github.com/rstudio/r-system-requirements.
We could easily do the same for Bioc packages, but we would need another DB that lists the SystemRequirements fields of Bioc packages, as this is not part of the repository metadata.
Thanks for your feedback - does this mean the code https://github.com/r-lib/pak/blob/main/R/system-requirements.R#L72-L93 that still uses the RSPM API is no longer in use ?
Right. The sysreqs.R and sysreqs2.R files are used in the pkgdepends package.
With https://github.com/r-lib/pkgcache/pull/96 and https://github.com/r-lib/pkgcache/pull/97 (devel) pak now supports system requirements for Bioconductor packages:
> pak::pkg_sysreqs(c("r-lib/xml2", "CHRONOS"))
── Install scripts ──────────────────────────────────────────────────────────────── Ubuntu 22.04 ──
apt-get -y update
apt-get -y install libcurl4-openssl-dev libssl-dev libglpk-dev libgmp3-dev libxml2-dev \
libpng-dev make default-jdk libicu-dev pandoc
R CMD javareconf
R CMD javareconf
── Packages and their system dependencies ─────────────────────────────────────────────────────────
CHRONOS – default-jdk, pandoc
curl – libcurl4-openssl-dev, libssl-dev
igraph – libglpk-dev, libgmp3-dev, libxml2-dev
openssl – libssl-dev
png – libpng-dev
RCurl – libcurl4-openssl-dev, make
rJava – default-jdk, make
stringi – libicu-dev
XML – libxml2-dev
xml2 – libxml2-dev
I hope this will solve your use cases.