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

Get binary R packages from packagemanager.rstudio.com #1104

Merged
merged 21 commits into from
Jan 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 42 additions & 44 deletions repo2docker/buildpacks/_r_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,66 +3,64 @@

Keeping this in r.py would lead to cyclic imports.
"""
from distutils.version import LooseVersion as V

# Via https://rstudio.com/products/rstudio/download-server/debian-ubuntu/
RSTUDIO_URL = "https://download2.rstudio.org/server/bionic/amd64/rstudio-server-1.2.5001-amd64.deb"
# This is MD5, because that is what RStudio download page provides!
RSTUDIO_CHECKSUM = "d33881b9ab786c09556c410e7dc477de"

# Via https://www.rstudio.com/products/shiny/download-server/
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"
def rstudio_base_scripts(r_version):
"""Base steps to install RStudio and shiny-server."""

# IRKernel version - specified as a tag in the IRKernel repository
IRKERNEL_VERSION = "1.1"
# Shiny server (not the package!) seems to be the same version for all R versions
shiny_server_url = "https://download3.rstudio.org/ubuntu-14.04/x86_64/shiny-server-1.5.17.973-amd64.deb"
shiny_proxy_version = "1.1"
shiny_sha256sum = "80f1e48f6c824be7ef9c843bb7911d4981ac7e8a963e0eff823936a8b28476ee"

if V(r_version) <= V("4.1"):
# Older RStudio and jupyter-rsession-proxy for v4.1 and below
rstudio_url = "https://download2.rstudio.org/server/bionic/amd64/rstudio-server-1.3.959-amd64.deb"
rstudio_sha256sum = (
"187af05cab1221282487fdc33f4b161484c3228eaade3d6697b1d41c206ee6d9"
)
rsession_proxy_version = "1.4"
else:
rstudio_url = "https://download2.rstudio.org/server/bionic/amd64/rstudio-server-2021.09.1-372-amd64.deb"
rstudio_sha256sum = (
"c58df09468870b89f1796445853dce2dacaa0fc5b7bb1f92b036fa8da1d1f8a3"
)
rsession_proxy_version = "2.0.1"

def rstudio_base_scripts():
"""Base steps to install RStudio and shiny-server."""
return [
(
"root",
# Install RStudio!
r"""
curl --silent --location --fail {rstudio_url} > /tmp/rstudio.deb && \
echo '{rstudio_checksum} /tmp/rstudio.deb' | md5sum -c - && \
apt-get update > /dev/null && \
apt install -y /tmp/rstudio.deb > /dev/null && \
rm /tmp/rstudio.deb && \
apt-get -qq purge && \
apt-get -qq clean && \
rm -rf /var/lib/apt/lists/*
""".format(
rstudio_url=RSTUDIO_URL, rstudio_checksum=RSTUDIO_CHECKSUM
curl --silent --location --fail {rstudio_url} > /tmp/rstudio.deb && \
curl --silent --location --fail {shiny_server_url} > /tmp/shiny.deb && \
echo '{rstudio_sha256sum} /tmp/rstudio.deb' | sha256sum -c - && \
echo '{shiny_sha256sum} /tmp/shiny.deb' | sha256sum -c - && \
apt-get update > /dev/null && \
apt install -y /tmp/rstudio.deb /tmp/shiny.deb > /dev/null && \
rm /tmp/rstudio.deb && \
apt-get -qq purge && \
apt-get -qq clean && \
rm -rf /var/lib/apt/lists/*
""".format(
rstudio_url=rstudio_url,
rstudio_sha256sum=rstudio_sha256sum,
shiny_server_url=shiny_server_url,
shiny_sha256sum=shiny_sha256sum,
),
),
(
"root",
# Install Shiny Server!
"${NB_USER}",
# Install jupyter-rsession-proxy
r"""
curl --silent --location --fail {url} > {deb} && \
echo '{checksum} {deb}' | md5sum -c - && \
dpkg -i {deb} > /dev/null && \
rm {deb}
pip install --no-cache \
jupyter-rsession-proxy=={rsession_proxy_version} \
jupyter-shiny-proxy=={shiny_proxy_version}
""".format(
url=SHINY_URL, checksum=SHINY_CHECKSUM, deb="/tmp/shiny.deb"
rsession_proxy_version=rsession_proxy_version,
shiny_proxy_version=shiny_proxy_version,
),
),
(
"${NB_USER}",
# Install nbrsessionproxy
r"""
pip install --no-cache-dir jupyter-server-proxy==1.4.0 && \
pip install --no-cache-dir https://github.com/jupyterhub/jupyter-rsession-proxy/archive/d5efed5455870556fc414f30871d0feca675a4b4.zip && \
pip install --no-cache-dir https://github.com/ryanlovett/jupyter-shiny-proxy/archive/47557dc47e2aeeab490eb5f3eeae414cdde4a6a9.zip && \
jupyter serverextension enable jupyter_server_proxy --sys-prefix && \
jupyter nbextension install --py jupyter_server_proxy --sys-prefix && \
jupyter nbextension enable --py jupyter_server_proxy --sys-prefix
""",
),
(
# Not all of these locations are configurable; so we make sure
# they exist and have the correct permissions
Expand Down
8 changes: 4 additions & 4 deletions repo2docker/buildpacks/conda/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
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
Expand Down Expand Up @@ -356,15 +356,15 @@ def get_env_scripts(self):
(
"${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
),
)
)
scripts += rstudio_base_scripts()
scripts += rstudio_base_scripts(self.r_version)
scripts += [
(
"root",
Expand Down
Loading