Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refining system requirements #523

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

michaelmayer2
Copy link

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.

@gaborcsardi
Copy link
Member

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.

@michaelmayer2
Copy link
Author

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 ?

@gaborcsardi
Copy link
Member

Right. The sysreqs.R and sysreqs2.R files are used in the pkgdepends package.

@gaborcsardi
Copy link
Member

With r-lib/pkgcache#96 and r-lib/pkgcache#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 ─────────────────────────────────────────────────────────
CHRONOSdefault-jdk, pandoc
curllibcurl4-openssl-dev, libssl-dev
igraphlibglpk-dev, libgmp3-dev, libxml2-dev
openssllibssl-dev
pnglibpng-dev
RCurllibcurl4-openssl-dev, make
rJavadefault-jdk, make
stringilibicu-dev
XMLlibxml2-dev
xml2libxml2-dev

I hope this will solve your use cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants