Skip to content

Commit

Permalink
rstan: Check Rtools on Windows if required
Browse files Browse the repository at this point in the history
  • Loading branch information
hsbadr committed Jan 15, 2025
1 parent 33c31a7 commit 6164cdd
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
4 changes: 1 addition & 3 deletions rstan/rstan/R/cxxfunplus.R
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,7 @@ cxxfunctionplus <- function(sig = character(), body = character(),
cxxfunction(sig = sig, body = body, plugin = plugin, includes = includes,
settings = settings, ..., verbose = verbose),
required = rstan_options("required") &&
# workaround for packages with src/install.libs.R
!identical(Sys.getenv("WINDOWS"), "TRUE") &&
!identical(Sys.getenv("R_PACKAGE_SOURCE"), "") )
(WINDOWS || !identical(Sys.getenv("R_PACKAGE_SOURCE"), "")))
if (!isTRUE(verbose)) {
sink(type = "output")
close(zz)
Expand Down
4 changes: 1 addition & 3 deletions rstan/rstan/R/expose_stan_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,7 @@ expose_stan_functions <- function(stanmodel, includes = NULL,
compiled <- pkgbuild::with_build_tools(try(suppressWarnings(
Rcpp::sourceCpp(code = paste(code, collapse = "\n"), ...)), silent = TRUE),
required = rstan_options("required") &&
# workaround for packages with src/install.libs.R
identical(Sys.getenv("WINDOWS"), "TRUE") &&
!identical(Sys.getenv("R_PACKAGE_SOURCE"), "") )
(WINDOWS || !identical(Sys.getenv("R_PACKAGE_SOURCE"), "")))
if (!isTRUE(show_compiler_warnings)) {
sink(type = "output")
close(zz)
Expand Down
4 changes: 2 additions & 2 deletions rstan/rstan/R/stanc.R
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ stanc_process <- function(file, model_code = '', model_name = "anon_model",
"-o", processed, unprocessed, "-Wno-invalid-pp-token")
CPP <- system2(file.path(R.home(component = "bin"), "R"),
args = "CMD config CC", stdout = TRUE)
WINDOWS <- .Platform$OS.type == "windows"
pkgbuild::with_build_tools(system(paste(CPP, ARGS),
ignore.stdout = TRUE, ignore.stderr = TRUE),
required = rstan_options("required") &&
identical(Sys.getenv("WINDOWS"), "TRUE") &&
!identical(Sys.getenv("R_PACKAGE_SOURCE"), "") )
(WINDOWS || !identical(Sys.getenv("R_PACKAGE_SOURCE"), "")))
if (file.exists(processed)) {
on.exit(file.remove(processed), add = TRUE)
model_code <- paste(readLines(processed), collapse = "\n")
Expand Down

0 comments on commit 6164cdd

Please sign in to comment.