Skip to content

Commit a5529c9

Browse files
authored
Add gfortran 14.2 for R 4.5.z (#24)
* Add gfortran 14.2 for R 4.5.z * Update version
1 parent 54e0ca5 commit a5529c9

File tree

5 files changed

+75
-14
lines changed

5 files changed

+75
-14
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: macrtools
22
Title: macOS Rtools package
3-
Version: 0.0.4.1
3+
Version: 0.0.6
44
Authors@R: c(
55
person(given = "James Joseph",
66
family = "Balamuta",

NEWS.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# macrtools 0.0.6
2+
3+
## Features
4+
5+
- Updated to support R 4.5.0 on macOS.
6+
- Downloads and sets up the latest version of gfortran 14.2
7+
18
# macrtools 0.0.5
29

310
## Features

R/assertions.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ assert_x86_64 <- function(call = caller_env()) {
8080
#' @export
8181
assert_r_version_supported <- function(call = caller_env()) {
8282
if (!(is_r_version("4.0") || is_r_version("4.1") || is_r_version("4.2") ||
83-
is_r_version("4.3") || is_r_version("4.4"))) {
83+
is_r_version("4.3") || is_r_version("4.4") || is_r_version("4.5"))) {
8484
version_number <- base::paste(base::R.version$major, base::R.version$minor, sep = ".")
8585
cli::cli_abort(c(
8686
"{.pkg macrtools}: The installed R version {.val {version_number}} is not supported.",
87-
"{.pkg macrtools}: Supported versions: R 4.0.x through R 4.4.x."
87+
"{.pkg macrtools}: Supported versions: R 4.0.x through R 4.5.x."
8888
),
8989
call = call,
9090
advice = "Please upgrade or downgrade your R installation to a supported version.")

R/gfortran.R

Lines changed: 59 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,34 @@ gfortran_version <- function() {
5252
#' appropriate location for **Intel** (`x86_64`) or **M-series** (`arm64`/`aarch64`)
5353
#' depending on the R version used.
5454
#'
55-
#' ### gfortran Installation for R 4.3
55+
#' ### gfortran Installation for R 4.5
5656
#'
57-
#' The `gfortran` installer for R 4.3 is a universal installer that places
57+
#' The `gfortran` installer for R 4.5 is a universal installer that places
58+
#' `gfortran` into the `/opt/gfortran` for both **Intel** (`x86_64`) and
59+
#' **M-series** (`arm64`/`aarch64`) macs.
60+
#'
61+
#' ```sh
62+
#' # Install the downloaded package into root
63+
#' sudo installer \
64+
#' -pkg /path/to/gfortran-14.2-universal.pkg \
65+
#' -target /
66+
#' ```
67+
#'
68+
#' Once installed, we modify the `PATH` environment variable to recognize the newly
69+
#' installed software by adding into the `~/.Renviron` file the following:
70+
#'
71+
#' ```sh
72+
#' touch ~/.Renviron
73+
#' cat << "EOF" > ~./Renviron
74+
#' ## macrtools - gfortran: start
75+
#' PATH=${PATH}:/opt/gfortran/bin
76+
#' ## macrtools - gfortran: end
77+
#' EOF
78+
#' ```
79+
#'
80+
#' ### gfortran Installation for R 4.3-4.4
81+
#'
82+
#' The `gfortran` installer for R 4.3-4.4 is a universal installer that places
5883
#' `gfortran` into the `/opt/gfortran` for both **Intel** (`x86_64`) and
5984
#' **M-series** (`arm64`/`aarch64`) macs.
6085
#'
@@ -205,7 +230,11 @@ gfortran_install <- function(password = base::getOption("macrtools.password"), v
205230

206231
gfortran_status <- FALSE
207232

208-
if(is_r_version("4.3") || is_r_version("4.4")) {
233+
if(is_r_version("4.5")) {
234+
gfortran_status <- install_gfortran_14_2_universal(
235+
password = entered_password_gfortran,
236+
verbose = verbose)
237+
} else if(is_r_version("4.3") || is_r_version("4.4")) {
209238
gfortran_status <- install_gfortran_12_2_universal(
210239
password = entered_password_gfortran,
211240
verbose = verbose)
@@ -390,7 +419,7 @@ gfortran_update <- function(password = base::getOption("macrtools.password"), ve
390419
assert_mac()
391420
assert_aarch64()
392421
assert(is_gfortran_installed(), "gfortran must be installed")
393-
assert(is_r_version("4.2") || is_r_version("4.3") || is_r_version("4.4"),
422+
assert(is_r_version("4.2") || is_r_version("4.3") || is_r_version("4.4") || is_r_version("4.5"),
394423
"R 4.2 or above is required for gfortran update")
395424

396425
# Figure out installation directory
@@ -541,10 +570,35 @@ install_gfortran_11_arm <- function(password = base::getOption("macrtools.passwo
541570
}
542571

543572

573+
#' Install gfortran v14.2 universal binaries
574+
#'
575+
#' @details
576+
#' Installs the `gfortran` v14.2 binaries for R version 4.5 for both
577+
#' Intel and ARM-based macs.
578+
#'
579+
#' @noRd
580+
install_gfortran_14_2_universal <- function(
581+
password = base::getOption("macrtools.password"),
582+
verbose = TRUE) {
583+
584+
# URL for gfortran 14.2 universal installer for R 4.5
585+
gfortran_14_universal <- "https://github.com/R-macos/gcc-14-branch/releases/download/gcc-14.2-darwin-r2.1/gfortran-14.2-universal.pkg"
586+
587+
# Download pkg
588+
path_to_pkg <- binary_download(gfortran_14_universal, verbose = verbose)
589+
590+
# Install pkg into the appropriate location
591+
pkg_install(path_to_pkg,
592+
"/",
593+
password = password,
594+
verbose = verbose)
595+
}
596+
597+
544598
#' Install gfortran v12.2 universal binaries
545599
#'
546600
#' @details
547-
#' Installs the `gfortran` v12.2 binaries for R version 4.3 for both
601+
#' Installs the `gfortran` v12.2 binaries for R version 4.3-4.4 for both
548602
#' Intel and ARM-based macs.
549603
#'
550604
#' @noRd

R/installers.R

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ install_strip_level <- function(arch = system_arch()) {
1111
}
1212

1313
recipe_binary_install_strip_level <- function(arch = system_arch()) {
14-
if (is_r_version("4.3") || is_r_version("4.4")) {
14+
if (is_r_version("4.3") || is_r_version("4.4") || is_r_version("4.5")) {
1515
base::switch(
1616
arch,
1717
"arm64" = 3,
@@ -22,7 +22,7 @@ recipe_binary_install_strip_level <- function(arch = system_arch()) {
2222
} else if (is_r_version("4.0") || is_r_version("4.1") || is_r_version("4.2")) {
2323
install_strip_level()
2424
} else {
25-
cli::cli_abort("{.pkg macrtools}: Unsupported R version. We only support recipe binary installation for R 4.0.x through 4.4.x.")
25+
cli::cli_abort("{.pkg macrtools}: Unsupported R version. We only support recipe binary installation for R 4.0.x through 4.5.x.")
2626
}
2727
}
2828

@@ -37,7 +37,7 @@ install_location <- function(arch = system_arch()) {
3737
}
3838

3939
recipe_binary_install_location <- function(arch = system_arch()) {
40-
if (is_r_version("4.3") || is_r_version("4.4")) {
40+
if (is_r_version("4.3") || is_r_version("4.4") || is_r_version("4.5")) {
4141
base::switch(
4242
arch,
4343
"arm64" = install_directory_arm64(),
@@ -48,17 +48,17 @@ recipe_binary_install_location <- function(arch = system_arch()) {
4848
} else if (is_r_version("4.0") || is_r_version("4.1") || is_r_version("4.2")) {
4949
install_location()
5050
} else {
51-
cli::cli_abort("{.pkg macrtools}: Unsupported R version. We only support recipe binary installation for R 4.0.x through 4.4.x.")
51+
cli::cli_abort("{.pkg macrtools}: Unsupported R version. We only support recipe binary installation for R 4.0.x through 4.5.x.")
5252
}
5353
}
5454

5555
gfortran_install_location <- function(arch = system_arch()) {
56-
if (is_r_version("4.3") || is_r_version("4.4")) {
56+
if (is_r_version("4.3") || is_r_version("4.4") || is_r_version("4.5")) {
5757
"/opt"
5858
} else if (is_r_version("4.0") || is_r_version("4.1") || is_r_version("4.2")) {
5959
install_location()
6060
} else {
61-
cli::cli_abort("{.pkg macrtools}: Unsupported R version. We only support gfortran installation for R 4.0.x through 4.4.x.")
61+
cli::cli_abort("{.pkg macrtools}: Unsupported R version. We only support gfortran installation for R 4.0.x through 4.5.x.")
6262
}
6363
}
6464

0 commit comments

Comments
 (0)