From 95bd7e703ee837b7dfca8f1e40eb54de9ac51073 Mon Sep 17 00:00:00 2001 From: vandenman Date: Wed, 27 Sep 2023 11:31:39 +0200 Subject: [PATCH] call setupRenv in setup_renv_rcpp_rinside_jaspModuleInstaller.R.in --- Engine/jaspModuleInstaller | 2 +- ...renv_rcpp_rinside_jaspModuleInstaller.R.in | 59 +++---------------- 2 files changed, 8 insertions(+), 53 deletions(-) diff --git a/Engine/jaspModuleInstaller b/Engine/jaspModuleInstaller index 33a1ecb6b25..89ee61df92b 160000 --- a/Engine/jaspModuleInstaller +++ b/Engine/jaspModuleInstaller @@ -1 +1 @@ -Subproject commit 33a1ecb6b253e138f8ea3f18a0954edd90d0b781 +Subproject commit 89ee61df92b76a85b5d5f237674b185cee63e0b7 diff --git a/Modules/setup_renv_rcpp_rinside_jaspModuleInstaller.R.in b/Modules/setup_renv_rcpp_rinside_jaspModuleInstaller.R.in index 356ce83bf6c..8d87ed79b5f 100644 --- a/Modules/setup_renv_rcpp_rinside_jaspModuleInstaller.R.in +++ b/Modules/setup_renv_rcpp_rinside_jaspModuleInstaller.R.in @@ -16,44 +16,8 @@ ENGINE <- file.path("@PROJECT_SOURCE_DIR@", "Engine") MODULES <- file.path("@PROJECT_SOURCE_DIR@", "Modules") TOOLS <- file.path("@PROJECT_SOURCE_DIR@", "Tools") -assignFunctionInPackage <- function(fun, name, package) { - ns <- getNamespace(package) - unlockBinding(name, ns) - assign(name, fun, ns) - lockBinding(name, ns) -} - -assignFunctionInRenv <- function(fun, name) { - assignFunctionInPackage(fun, name, "renv") -} - -getOS <- function() { - - os <- NULL - - if (!is.null(Sys.info())) { - - os <- Sys.info()["sysname"] - - if (os == "Darwin") - os <- "osx" - - } else { - - if (grepl("^darwin", R.version$os)) - os <- "osx" - - if (grepl("linux-gnu", R.version$os)) - os <- "linux" - - } - - if (is.null(os)) - stop("Unable to determine the operating system because `Sys.info()` returned NULL.", domain = NA) - - return(tolower(os)) - -} +# defines assignFunctionInRenv, getOS, and setupRenv +source(file.path(ENGINE, "jaspModuleInstaller", "R", "renvOverrides.R")) mkdir <- function(paths) { for (path in paths) @@ -61,7 +25,6 @@ mkdir <- function(paths) { dir.create(path, recursive = TRUE) } - mkdir(c(RENV_LIBRARY, R_CPP_INCLUDES_LIBRARY, JASPMODULEINSTALLER_LIBRARY)) repos <- "https://packagemanager.posit.co/cran/latest" @@ -73,7 +36,7 @@ if (!dir.exists(file.path(RENV_LIBRARY, "renv"))) { pkgs = "renv", lib = RENV_LIBRARY, repos ='http://cloud.r-project.org', - INSTALL_opts ='--no-multiarch --no-docs --no-test-load') + INSTALL_opts ='--no-multiarch --no-docs --no-test-load') # --no-test-load is dubious here } else { cat("renv already installed, not reinstalling\n") } @@ -81,6 +44,7 @@ if (!dir.exists(file.path(RENV_LIBRARY, "renv"))) { # used by renv options( install.opts = "--no-multiarch --no-docs --no-test-load", + # these two could be added to setupRenv renv.config.install.verbose = TRUE, renv.config.ppm.default = TRUE ) @@ -88,23 +52,12 @@ options( .libPaths(RENV_LIBRARY) sandboxPaths <- renv:::renv_sandbox_activate() -# renv adds e.g,. "R-3.6/x86_64-pc-linux-gnu" to all paths (R-version/os) and we don't need that -assignFunctionInRenv(function() return(""), "renv_bootstrap_platform_prefix") - cat("Using sandbox paths:\n") for (path in sandboxPaths) cat(" ", path, "\n", sep = "") -# same as in jaspModuleInstaller:::setupRenv -options( - "renv.config.install.verbose" = TRUE, # not necessary but saves headaches - "renv.config.cache.enabled" = TRUE, # enable using a cache - "renv.cache.linkable" = TRUE, # undocumented, see renv:::renv_cache_linkable. required for linking to a custom folder - "renv.config.auto.snapshot" = FALSE, # new option, we don't want this - "renv.snapshot.ignore.self" = FALSE # currently unused, but can be useful. -) - cat("Restoring Rcpp & RInside\n") +setupRenv(R_CPP_INCLUDES_LIBRARY) renv::restore( library = R_CPP_INCLUDES_LIBRARY, lockfile = file.path(MODULES, "Rcpp_RInside.lock"), @@ -112,6 +65,7 @@ renv::restore( ) cat("Restoring pkgdepends\n") +setupRenv(PKGDEPENDS_LIBRARY) renv::restore( library = PKGDEPENDS_LIBRARY, lockfile = file.path(MODULES, "pkgdepends.lock"), @@ -119,6 +73,7 @@ renv::restore( ) cat("Restoring jaspModuleInstaller\n") +setupRenv(JASPMODULEINSTALLER_LIBRARY) renv::restore( library = JASPMODULEINSTALLER_LIBRARY, lockfile = file.path(ENGINE, "jaspModuleInstaller", "renv.lock"),