Skip to content

Commit

Permalink
[r-apt]: installBspm option (#169)
Browse files Browse the repository at this point in the history
Close #69

Add a new option to set up bspm.
  • Loading branch information
eitsupi authored Aug 5, 2023
1 parent 1e2af2d commit 6149004
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/r-apt/NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@ Packages that cannot be installed via apt must be installed using the R function

For more information, please check [the Rocker Project website](https://rocker-project.org/use/extending.html).


### Binary installation via R with bspm

If set the `installBspm` option to `true`, this Feature will install and set up
the [`bspm` R package](https://github.com/Enchufa2/bspm).

`bspm` provides functions to manage packages via the distribution's package manager.

Known limitation: `bspm` does not seem to work correctly on Debian.
(<https://github.com/rocker-org/devcontainer-features/pull/169#issuecomment-1665839740>)

## Python package installation

This feature has some options to install Python packages such as `jupyterlab`.
Expand Down
7 changes: 6 additions & 1 deletion src/r-apt/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "R (via apt)",
"id": "r-apt",
"version": "0.3.4",
"version": "0.4.0",
"description": "Installs the latest R, some R packages, and needed dependencies. Note: May require source code compilation for some R packages.",
"documentationURL": "https://github.com/rocker-org/devcontainer-features/tree/main/src/r-apt",
"options": {
Expand Down Expand Up @@ -50,6 +50,11 @@
"type": "boolean",
"default": true,
"description": "For Debian, install packages from Debian testing. If false, the R package installed by apt may be out of date."
},
"installBspm": {
"type": "boolean",
"default": false,
"description": "Install and enable BSPM (Bridge to System Package Manager) to install R packages. This option is only working on Ubuntu now."
}
},
"installsAfter": [
Expand Down
11 changes: 11 additions & 0 deletions src/r-apt/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ INSTALL_RMARKDOWN=${INSTALLRMARKDOWN:-"false"}
INSTALL_JUPYTERLAB=${INSTALLJUPYTERLAB:-"false"}
INSTALL_RADIAN=${INSTALLRADIAN:-"false"}
INSTALL_VSCDEBUGGER=${INSTALLVSCDEBUGGER:-"false"}
INSTALL_BSPM=${INSTALLBSPM:-"false"}

USERNAME=${USERNAME:-${_REMOTE_USER:-"automatic"}}
R_LIBRARY_PATH="/usr/local/lib/R/site-library"
Expand Down Expand Up @@ -93,6 +94,10 @@ if [ "${INSTALL_JUPYTERLAB}" = "true" ]; then
PIP_PACKAGES+=(jupyterlab)
fi

if [ "${INSTALL_BSPM}" = "true" ]; then
APT_PACKAGES+=(make sudo python3-apt python3-gi)
fi

apt_get_update() {
if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then
echo "Running apt-get update..."
Expand Down Expand Up @@ -226,6 +231,12 @@ if [ "${INSTALL_VSCDEBUGGER}" = "true" ]; then
R -q -e "pak::pkg_install('ManuelHentschel/vscDebugger@$(git ls-remote --tags https://github.com/ManuelHentschel/vscDebugger | grep -oP "v[0-9]+\\.[0-9]+\\.[0-9]+" | sort -V | tail -n 1)')"
fi

if [ "${INSTALL_BSPM}" = "true" ]; then
R -q -e 'install.packages("bspm")'
echo "options(bspm.sudo = TRUE)" >>/etc/R/Rprofile.site
echo "bspm::enable()" >>/etc/R/Rprofile.site
fi

# Set up IRkernel
if [ "${INSTALL_JUPYTERLAB}" = "true" ]; then
echo "Register IRkernel..."
Expand Down
15 changes: 15 additions & 0 deletions test/r-apt/bspm-debian.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

set -e

# Optional: Import test library bundled with the devcontainer CLI
source dev-container-features-test-lib

R -q -e 'install.packages("curl")'

# Feature-specific tests
check "R" R -q -e "sessionInfo()"
check "R curl" R -q -e 'names(installed.packages()[, 3])' | grep curl

# Report result
reportResults
15 changes: 15 additions & 0 deletions test/r-apt/bspm-ubuntu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

set -e

# Optional: Import test library bundled with the devcontainer CLI
source dev-container-features-test-lib

R -q -e 'install.packages("curl")'

# Feature-specific tests
check "R" R -q -e "sessionInfo()"
check "R curl" R -q -e 'names(installed.packages()[, 3])' | grep curl

# Report result
reportResults
17 changes: 17 additions & 0 deletions test/r-apt/scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,22 @@
"installRadian": true
}
}
},
// TODO: enable tesing on debian
// "bspm-debian": {
// "image": "mcr.microsoft.com/devcontainers/base:debian",
// "features": {
// "r-apt": {
// "installBspm": true
// }
// }
// },
"bspm-ubuntu": {
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"r-apt": {
"installBspm": true
}
}
}
}

0 comments on commit 6149004

Please sign in to comment.