Skip to content

Commit 3eec1c5

Browse files
committed
Use system installation of R for extra packages
1 parent 237bc49 commit 3eec1c5

File tree

1 file changed

+29
-35
lines changed

1 file changed

+29
-35
lines changed

contrib/vm/container_manager.py

+29-35
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,32 @@
254254
'unattended-upgrades',
255255
'unzip',
256256
'wget',
257+
# R packages
258+
'r-cran-desolve',
259+
'r-cran-ggally',
260+
'r-cran-ggplot2',
261+
'r-cran-lazyeval',
262+
'r-cran-pracma',
263+
'r-cran-reticulate',
264+
'r-cran-rhandsontable',
265+
'r-cran-rms',
266+
'r-cran-survey',
267+
'r-cran-tidyverse',
268+
]
269+
270+
# R packages that are not available as system ones
271+
R_packages = [
272+
"flextable",
273+
"formattable",
274+
"gt",
275+
"gtExtras",
276+
"huxtable",
277+
"kable",
278+
"kableExtra",
279+
"pixiedust",
280+
"reactable",
281+
"reactablefmtr",
282+
"swirl",
257283
]
258284

259285
# Optional Sage packages to be installed
@@ -398,30 +424,6 @@
398424
"moss", # This one only complains about missing dependencies
399425
]
400426

401-
# R packages
402-
R_packages = [
403-
"deSolve",
404-
"flextable",
405-
"formattable",
406-
"GGally",
407-
"ggplot2",
408-
"gt",
409-
"gtExtras",
410-
"huxtable",
411-
"kable",
412-
"kableExtra",
413-
"lazyeval",
414-
"pixiedust",
415-
"pracma",
416-
"reactable",
417-
"reactablefmtr",
418-
"reticulate",
419-
"rhandsontable",
420-
"rms",
421-
"survey",
422-
"swirl",
423-
"tidyverse",
424-
]
425427

426428
# limits configuration for the host - will not be overwritten later
427429
limits_conf = """\
@@ -733,17 +735,6 @@ def install_packages():
733735
check_call("./sage -pip install --upgrade pip")
734736
for package in python_packages:
735737
check_call("./sage -pip install {}".format(package))
736-
log.info("installing R packages")
737-
for package in R_packages:
738-
communicate("./sage", r"""
739-
r.eval("install.packages('{}')")
740-
quit
741-
""".format(package))
742-
if "ImportError" in check_output(
743-
f"./sage -c \"r.library('{package}')\""):
744-
msg = f"R package {package} didn't install"
745-
log.error(msg)
746-
raise RuntimeError(msg)
747738
os.chdir("..")
748739

749740

@@ -844,6 +835,9 @@ def create(self):
844835
self.inside("apt install -y " + " ".join(system_packages))
845836
# Relies on perl, so has to be after package installation
846837
self.inside("/usr/sbin/deluser ubuntu --remove-home")
838+
log.info("installing R packages")
839+
for package in R_packages:
840+
self.inside(f"""Rscript -e 'install.packages("{package}")'""")
847841

848842
def destroy(self):
849843
r"""

0 commit comments

Comments
 (0)