Skip to content

Instantly share code, notes, and snippets.

@pat-s

pat-s/install-cluto.R

Last active Oct 21, 2020
Embed
What would you like to do?
# because base::file.rename() is a pain across OS
requireNamespace("fs", quietly = TRUE)
# download cluto zip file
temp = tempfile()
download.file("http://glaros.dtc.umn.edu/gkhome/fetch/sw/cluto/cluto-2.1.2a.zip", temp, quiet = TRUE)
unzip(temp, files = c("cluto-2.1.2/Linux-x86_64/vcluster", "cluto-2.1.2/MSWIN-x86_64/vcluster.exe"))
unlink(temp)
# check if mlr3spatiotempcv is installed
installed_packages = installed.packages()[, "Package"]
if (!"mlr3spatiotempcv" %in% installed_packages) {
stop("Please install mlr3spatiotempcv first.")
}
# install CLUTO
switch(Sys.info()[["sysname"]],
"Windows" = {
message(sprintf("Installing the executable into '%s/mlr3spatiotempcv/'.", .libPaths()[1]))
message("If the package is updated/reinstalled, this process needs to be repeated.")
fs::file_move("cluto-2.1.2/MSWIN-x86_64/vcluster.exe", paste0(.libPaths()[1], "/mlr3spatiotempcv/vcluster.exe"))
},
"Darwin" = stop("macOS is not supported by CLUTO."),
"Linux" = {
message(sprintf("Installing the executable into '%s/mlr3spatiotempcv/'.", .libPaths()[1]))
message("If the package is updated/reinstalled, this process needs to be repeated.")
fs::file_move("cluto-2.1.2/Linux-x86_64/vcluster", paste0(.libPaths()[1], "/mlr3spatiotempcv/vcluster"))
}
)
unlink("cluto-2.1.2", recursive = TRUE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment