Install devtools, shiny & irkernel from a pin

We were doing this from an old MRAN snapshot. I moved the pin
a little ahead, so IRKernel can also be installed from CRAN
instead of from GitHub. R <= 4.0 gets the old version, and anything
newer gets a more recent version of devtools. This gives us
fast installs for IRkernel with binary packages.

Also add a R 4.0 and R 4.1 test
pull/1104/head
YuviPanda 2021-12-17 15:44:49 +05:30
rodzic 290b008ac5
commit 1ed05b59c6
9 zmienionych plików z 32 dodań i 26 usunięć

Wyświetl plik

@ -13,13 +13,6 @@ RSTUDIO_CHECKSUM = "d33881b9ab786c09556c410e7dc477de"
SHINY_URL = "https://download3.rstudio.org/ubuntu-14.04/x86_64/shiny-server-1.5.12.933-amd64.deb"
SHINY_CHECKSUM = "9aeef6613e7f58f21c97a4600921340e"
# Version of MRAN to pull devtools from.
DEVTOOLS_VERSION = "2018-02-01"
# IRKernel version - specified as a tag in the IRKernel repository
IRKERNEL_VERSION = "1.1"
def rstudio_base_scripts():
"""Base steps to install RStudio and shiny-server."""
return [

Wyświetl plik

@ -6,7 +6,7 @@ from collections.abc import Mapping
from ruamel.yaml import YAML
from ..base import BaseImage
from .._r_base import rstudio_base_scripts, IRKERNEL_VERSION
from .._r_base import rstudio_base_scripts
from ...utils import is_local_pip_requirement
# pattern for parsing conda dependency line
@ -356,11 +356,11 @@ class CondaBuildPack(BaseImage):
(
"${NB_USER}",
r"""
mamba install -p {0} r-base{1} r-irkernel={2} r-devtools -y && \
mamba install -p {0} r-base{1} r-irkernel=1.2 r-devtools -y && \
mamba clean --all -f -y && \
mamba list -p {0}
""".format(
env_prefix, r_pin, IRKERNEL_VERSION
env_prefix, r_pin
),
)
)

Wyświetl plik

@ -6,7 +6,7 @@ import requests
from distutils.version import LooseVersion as V
from .python import PythonBuildPack
from ._r_base import rstudio_base_scripts, DEVTOOLS_VERSION, IRKERNEL_VERSION
from ._r_base import rstudio_base_scripts
class RBuildPack(PythonBuildPack):
@ -186,7 +186,6 @@ class RBuildPack(PythonBuildPack):
return super().get_packages().union(packages)
def get_cran_mirror_url(self, snapshot_date):
# Call the API to find out if we have a snapshot available for the given date.
# If so, use the URL for that snapshot. If not, fall back to MRAN.
snapshots = requests.post(
@ -209,6 +208,19 @@ class RBuildPack(PythonBuildPack):
snapshot_date.isoformat()
)
def get_devtools_snapshot_date(self):
"""
Return date of snapshot to use for getting devtools install
devtools is part of our 'core' base install, so we should have some
control over what version we install here.
"""
if V(self.r_version) <= V('4.0'):
# IRKernel gets into CRAN on Nov 16 2018 (https://packagemanager.rstudio.com/client/#/repos/1/packages/IRkernel),
# so we try snapshot to just after that.
return datetime.date(2018, 12, 1)
return datetime.date(2021, 12, 16)
def get_build_scripts(self):
"""
Return series of build-steps common to all R repositories
@ -312,26 +324,17 @@ class RBuildPack(PythonBuildPack):
),
(
"${NB_USER}",
# Install a pinned version of IRKernel and set it up for use!
# Install a pinner version of devtools, IRKernel and shiny
r"""
R --quiet -e "install.packages('devtools')" && \
R --quiet -e "devtools::install_github('IRkernel/IRkernel', ref='{irkernel_version}')" && \
R --quiet -e "install.packages(c('devtools', 'IRkernel', 'shiny'), repos='{devtools_cran_mirror_url}')" && \
R --quiet -e "IRkernel::installspec(prefix='$NB_PYTHON_PREFIX')"
""".format(
cran_mirror_url=cran_mirror_url,
devtools_version=DEVTOOLS_VERSION,
irkernel_version=IRKERNEL_VERSION,
devtools_cran_mirror_url=self.get_cran_mirror_url(self.get_devtools_snapshot_date()),
),
),
(
"${NB_USER}",
# Install shiny library
r"""
R --quiet -e "install.packages('shiny')"
""",
),
)
]
return super().get_build_scripts() + scripts
def get_preassemble_script_files(self):

Wyświetl plik

@ -0,0 +1 @@
r-4.0-2021-07-07

Wyświetl plik

@ -0,0 +1,8 @@
#!/usr/bin/env Rscript
library('ggplot2')
print(version)
# Fail if version is not 4.0
if (!(version$major == "4" && as.double(version$minor) >= 0 && as.double(version$minor) < 1)) {
quit("yes", 1)
}

Wyświetl plik

@ -0,0 +1 @@
install.packages("ggplot2")