|
51 | 51 | #' The URL should point to the tarball (`.tar.gz.` file) itself, e.g., |
52 | 52 | #' `release_url="https://github.com/stan-dev/cmdstan/releases/download/v2.25.0/cmdstan-2.25.0.tar.gz"`. |
53 | 53 | #' If both `version` and `release_url` are specified then `version` will be used. |
| 54 | +#' @param release_file (string) A file path to a CmdStan release tar.gz file |
| 55 | +#' downloaded from the releases page: <https://github.com/stan-dev/cmdstan/releases>. |
| 56 | +#' For example: `release_file=""./cmdstan-2.33.1.tar.gz"`. If `release_file` is |
| 57 | +#' specified then both `release_url` and `version` will be ignored. |
54 | 58 | #' @param cpp_options (list) Any makefile flags/variables to be written to |
55 | 59 | #' the `make/local` file. For example, `list("CXX" = "clang++")` will force |
56 | 60 | #' the use of clang for compilation. |
@@ -82,6 +86,7 @@ install_cmdstan <- function(dir = NULL, |
82 | 86 | timeout = 1200, |
83 | 87 | version = NULL, |
84 | 88 | release_url = NULL, |
| 89 | + release_file = NULL, |
85 | 90 | cpp_options = list(), |
86 | 91 | check_toolchain = TRUE, |
87 | 92 | wsl = FALSE) { |
@@ -118,7 +123,15 @@ install_cmdstan <- function(dir = NULL, |
118 | 123 | dir <- repair_path(dir) |
119 | 124 | assert_dir_exists(dir, access = "rwx") |
120 | 125 | } |
121 | | - if (!is.null(version)) { |
| 126 | + if (!is.null(release_file)) { |
| 127 | + if (!is.null(release_url) || !is.null(version)) { |
| 128 | + warning("release_file and release_url/version shouldn't both be specified!", |
| 129 | + "\nrelease_url/version will be ignored.", call. = FALSE) |
| 130 | + } |
| 131 | + |
| 132 | + release_url <- release_file |
| 133 | + } |
| 134 | + if (!is.null(version) && is.null(release_file)) { |
122 | 135 | if (!is.null(release_url)) { |
123 | 136 | warning("version and release_url shouldn't both be specified!", |
124 | 137 | "\nrelease_url will be ignored.", call. = FALSE) |
@@ -155,18 +168,22 @@ install_cmdstan <- function(dir = NULL, |
155 | 168 | if (!check_install_dir(dir_cmdstan, overwrite)) { |
156 | 169 | return(invisible(NULL)) |
157 | 170 | } |
158 | | - tar_downloaded <- download_with_retries(download_url, dest_file, quiet = quiet) |
159 | | - if (inherits(tar_downloaded, "try-error")) { |
160 | | - error_msg <- paste("Download of CmdStan failed with error:", |
161 | | - attr(tar_downloaded, "condition")$message) |
162 | | - if (!is.null(version)) { |
163 | | - error_msg <- paste0(error_msg, "\nPlease check if the supplied version number is valid.") |
164 | | - } else if (!is.null(release_url)) { |
165 | | - error_msg <- paste0(error_msg, "\nPlease check if the supplied release URL is valid.") |
| 171 | + if (is.null(release_file)) { |
| 172 | + tar_downloaded <- download_with_retries(download_url, dest_file, quiet = quiet) |
| 173 | + if (inherits(tar_downloaded, "try-error")) { |
| 174 | + error_msg <- paste("Download of CmdStan failed with error:", |
| 175 | + attr(tar_downloaded, "condition")$message) |
| 176 | + if (!is.null(version)) { |
| 177 | + error_msg <- paste0(error_msg, "\nPlease check if the supplied version number is valid.") |
| 178 | + } else if (!is.null(release_url)) { |
| 179 | + error_msg <- paste0(error_msg, "\nPlease check if the supplied release URL is valid.") |
| 180 | + } |
| 181 | + stop(error_msg, call. = FALSE) |
166 | 182 | } |
167 | | - stop(error_msg, call. = FALSE) |
| 183 | + message("* Download complete") |
| 184 | + } else { |
| 185 | + file.copy(release_file, dest_file) |
168 | 186 | } |
169 | | - message("* Download complete") |
170 | 187 | message("* Unpacking archive...") |
171 | 188 | if (wsl) { |
172 | 189 | # Significantly faster to use WSL to untar the downloaded archive, as there are |
@@ -762,7 +779,7 @@ cmdstan_arch_suffix <- function(version = NULL) { |
762 | 779 | } else { |
763 | 780 | arch <- R.version$arch |
764 | 781 | } |
765 | | - |
| 782 | + |
766 | 783 | if (any(grepl(arch, c("x86_64", "i686")))) { |
767 | 784 | return(NULL) |
768 | 785 | } |
|
0 commit comments