Skip to content

Commit

Permalink
Merge pull request #531 from stan-dev/install_arm
Browse files Browse the repository at this point in the history
Install Linux ARM tarball automatically
  • Loading branch information
rok-cesnovar authored Jul 20, 2021
2 parents 19056cf + 849915f commit b317b42
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions R/install.R
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ install_cmdstan <- function(dir = NULL,
warning("version and release_url shouldn't both be specified!",
"\nrelease_url will be ignored.", call. = FALSE)
}

release_url <- paste0("https://github.com/stan-dev/cmdstan/releases/download/v",
version, "/cmdstan-", version, ".tar.gz")
version, "/cmdstan-", version, cmdstan_arch_suffix(version), ".tar.gz")
}
if (!is.null(release_url)) {
if (!endsWith(release_url, ".tar.gz")) {
Expand All @@ -118,7 +119,7 @@ install_cmdstan <- function(dir = NULL,
} else {
ver <- latest_released_version()
message("* Latest CmdStan release is v", ver)
cmdstan_ver <- paste0("cmdstan-", ver)
cmdstan_ver <- paste0("cmdstan-", ver, cmdstan_arch_suffix(ver))
tar_gz_file <- paste0(cmdstan_ver, ".tar.gz")
dir_cmdstan <- file.path(dir, cmdstan_ver)
message("* Installing CmdStan v", ver, " in ", dir_cmdstan)
Expand Down Expand Up @@ -300,9 +301,10 @@ github_auth_token <- function() {

# construct url for download from cmdstan version number
github_download_url <- function(version_number) {

base_url <- "https://github.com/stan-dev/cmdstan/releases/download/"
paste0(base_url, "v", version_number,
"/cmdstan-", version_number, ".tar.gz")
"/cmdstan-", version_number, cmdstan_arch_suffix(), ".tar.gz")
}

# get version number of latest release
Expand Down Expand Up @@ -614,3 +616,15 @@ check_unix_cpp_compiler <- function() {
}
}
}

cmdstan_arch_suffix <- function(version = NULL) {
arch <- NULL
if (grepl("linux", R.version$os) && grepl("aarch64", R.version$arch)) {
arch <- "-linux-arm64"
}
if (!is.null(version) && version < "2.26") {
# pre-CmdStan 2.26, only the x85 tarball was provided
arch <- NULL
}
arch
}

0 comments on commit b317b42

Please sign in to comment.