From 751fb2e9322043b4cc59540141dee85fc60dc0bc Mon Sep 17 00:00:00 2001 From: Jonathan Keane Date: Thu, 4 Apr 2024 18:31:03 -0500 Subject: [PATCH 1/7] Prefer r-universe, add a startup message --- r/DESCRIPTION | 2 +- r/R/arrow-package.R | 67 ++++++++++++++++----------- r/R/install-arrow.R | 19 ++++---- r/man/arrow-package.Rd | 4 +- r/man/format_schema.Rd | 18 +++++++ r/man/install_arrow.Rd | 4 ++ r/tests/testthat/test-install-arrow.R | 16 ++++--- 7 files changed, 84 insertions(+), 46 deletions(-) create mode 100644 r/man/format_schema.Rd diff --git a/r/DESCRIPTION b/r/DESCRIPTION index 6062a8c4f468..c9f84e2e794c 100644 --- a/r/DESCRIPTION +++ b/r/DESCRIPTION @@ -43,7 +43,7 @@ Imports: utils, vctrs Roxygen: list(markdown = TRUE, r6 = FALSE, load = "source") -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.1 Config/testthat/edition: 3 Config/build/bootstrap: TRUE Suggests: diff --git a/r/R/arrow-package.R b/r/R/arrow-package.R index 54e237192e08..b34eea1f39aa 100644 --- a/r/R/arrow-package.R +++ b/r/R/arrow-package.R @@ -182,37 +182,50 @@ configure_tzdb <- function() { .onAttach <- function(libname, pkgname) { # Just to be extra safe, let's wrap this in a try(); # we don't want a failed startup message to prevent the package from loading - try({ - # On macOS only, Check if we are running in under emulation, and warn this will not work - if (on_rosetta()) { - packageStartupMessage( - paste( - "Warning:", - " It appears that you are running R and Arrow in emulation (i.e. you're", - " running an Intel version of R on a non-Intel mac). This configuration is", - " not supported by arrow, you should install a native (arm64) build of R", - " and use arrow with that. See https://cran.r-project.org/bin/macosx/", - "", - sep = "\n" + try( + { + # On macOS only, Check if we are running in under emulation, and warn this will not work + if (on_rosetta()) { + packageStartupMessage( + paste( + "Warning:", + " It appears that you are running R and Arrow in emulation (i.e. you're", + " running an Intel version of R on a non-Intel mac). This configuration is", + " not supported by arrow, you should install a native (arm64) build of R", + " and use arrow with that. See https://cran.r-project.org/bin/macosx/", + "", + sep = "\n" + ) ) - ) - } + } - features <- arrow_info()$capabilities - # That has all of the #ifdef features, plus the compression libs and the - # string libraries (but not the memory allocators, they're added elsewhere) - # - # Let's print a message if some are off - if (some_features_are_off(features)) { - packageStartupMessage( - paste( - "Some features are not enabled in this build of Arrow.", - "Run `arrow_info()` for more information." + features <- arrow_info()$capabilities + # That has all of the #ifdef features, plus the compression libs and the + # string libraries (but not the memory allocators, they're added elsewhere) + # + # Let's print a message if some are off + if (some_features_are_off(features)) { + packageStartupMessage( + paste( + "Some features are not enabled in this build of Arrow.", + "Run `arrow_info()` for more information." + ) ) - ) - } - }, silent = TRUE) + # On macOS binaries from CRAN can be hobbled. If on macOS, and features + # are disabled, advise that reinstalling might help + if (identical(tolower(Sys.info()[["sysname"]]), "darwin")) { + packageStartupMessage( + paste( + "The repository you retrieved Arrow from did not include all of Arrow's features.", + "You can install a fully-featured version by running `arrow::install_arrow()`." + ) + ) + } + } + }, + silent = TRUE + ) } # Clean up the StopSource that was registered in .onLoad() so that if the diff --git a/r/R/install-arrow.R b/r/R/install-arrow.R index 74d3a9645477..ce7bdf47abe9 100644 --- a/r/R/install-arrow.R +++ b/r/R/install-arrow.R @@ -47,6 +47,8 @@ #' is `FALSE`. This sets the `ARROW_R_DEV` environment variable. #' @param repos character vector of base URLs of the repositories to install #' from (passed to `install.packages()`) +#' @param prefer_runiverse logical: Should the apache.r-universe repo be preferred +#' if it is up to date. Default is `TRUE`. #' @param ... Additional arguments passed to `install.packages()` #' @export #' @importFrom utils install.packages @@ -60,6 +62,7 @@ install_arrow <- function(nightly = FALSE, minimal = Sys.getenv("LIBARROW_MINIMAL", FALSE), verbose = Sys.getenv("ARROW_R_DEV", FALSE), repos = getOption("repos"), + prefer_runiverse = TRUE, ...) { conda <- isTRUE(grepl("conda", R.Version()$platform)) @@ -76,22 +79,15 @@ install_arrow <- function(nightly = FALSE, ARROW_R_DEV = verbose, ARROW_USE_PKG_CONFIG = use_system ) - # On the M1, we can't use the usual autobrew, which pulls Intel dependencies - apple_m1 <- grepl("arm-apple|aarch64.*darwin", R.Version()$platform) # On Rosetta, we have to build without JEMALLOC, so we also can't autobrew rosetta <- on_rosetta() if (rosetta) { Sys.setenv(ARROW_JEMALLOC = "OFF") - } - if (apple_m1 || rosetta) { Sys.setenv(FORCE_BUNDLED_BUILD = "true") } opts <- list() - if (apple_m1 || rosetta) { - # Skip binaries (esp. for rosetta) - opts$pkgType <- "source" - } else if (isTRUE(binary)) { + if (isTRUE(binary)) { # Unless otherwise directed, don't consider newer source packages when # options(pkgType) == "both" (default on win/mac) opts$install.packages.check.source <- "no" @@ -101,7 +97,7 @@ install_arrow <- function(nightly = FALSE, old <- options(opts) on.exit(options(old)) } - install.packages("arrow", repos = arrow_repos(repos, nightly), ...) + install.packages("arrow", repos = arrow_repos(repos, nightly, prefer_runiverse), ...) } if ("arrow" %in% loadedNamespaces()) { # If you've just sourced this file, "arrow" won't be (re)loaded @@ -109,7 +105,7 @@ install_arrow <- function(nightly = FALSE, } } -arrow_repos <- function(repos = getOption("repos"), nightly = FALSE) { +arrow_repos <- function(repos = getOption("repos"), nightly = FALSE, prefer_runiverse = TRUE) { if (length(repos) == 0 || identical(repos, c(CRAN = "@CRAN@"))) { # Set the default/CDN repos <- "https://cloud.r-project.org/" @@ -117,6 +113,9 @@ arrow_repos <- function(repos = getOption("repos"), nightly = FALSE) { dev_repo <- getOption("arrow.dev_repo", "https://nightlies.apache.org/arrow/r") # Remove it if it's there (so nightly=FALSE won't accidentally pull from it) repos <- setdiff(repos, dev_repo) + if (prefer_runiverse) { + repos <- c("https://apache.r-universe.dev", repos) + } if (nightly) { # Add it first repos <- c(dev_repo, repos) diff --git a/r/man/arrow-package.Rd b/r/man/arrow-package.Rd index 15f672a1fe94..41ec7956fe81 100644 --- a/r/man/arrow-package.Rd +++ b/r/man/arrow-package.Rd @@ -18,15 +18,15 @@ Useful links: } \author{ -\strong{Maintainer}: Nic Crane \email{thisisnic@gmail.com} +\strong{Maintainer}: Jonathan Keane \email{jkeane@gmail.com} Authors: \itemize{ \item Neal Richardson \email{neal.p.richardson@gmail.com} \item Ian Cook \email{ianmcook@gmail.com} + \item Nic Crane \email{thisisnic@gmail.com} \item Dewey Dunnington \email{dewey@fishandwhistle.net} (\href{https://orcid.org/0000-0002-9415-4582}{ORCID}) \item Romain François (\href{https://orcid.org/0000-0002-2444-4226}{ORCID}) - \item Jonathan Keane \email{jkeane@gmail.com} \item Dragoș Moldovan-Grünfeld \email{dragos.mold@gmail.com} \item Jeroen Ooms \email{jeroen@berkeley.edu} \item Jacob Wujciak-Jens \email{jacob@wujciak.de} diff --git a/r/man/format_schema.Rd b/r/man/format_schema.Rd new file mode 100644 index 000000000000..d1c81e3fe762 --- /dev/null +++ b/r/man/format_schema.Rd @@ -0,0 +1,18 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/schema.R +\name{format_schema} +\alias{format_schema} +\title{Get a string representing a Dataset or RecordBatchReader object's schema} +\usage{ +format_schema(obj) +} +\arguments{ +\item{obj}{a Dataset or RecordBatchReader} +} +\value{ +A string containing a formatted representation of the schema of \code{obj} +} +\description{ +Get a string representing a Dataset or RecordBatchReader object's schema +} +\keyword{internal} diff --git a/r/man/install_arrow.Rd b/r/man/install_arrow.Rd index 05d73b819d11..25f7a9329ac7 100644 --- a/r/man/install_arrow.Rd +++ b/r/man/install_arrow.Rd @@ -11,6 +11,7 @@ install_arrow( minimal = Sys.getenv("LIBARROW_MINIMAL", FALSE), verbose = Sys.getenv("ARROW_R_DEV", FALSE), repos = getOption("repos"), + prefer_runiverse = TRUE, ... ) } @@ -43,6 +44,9 @@ is \code{FALSE}. This sets the \code{ARROW_R_DEV} environment variable.} \item{repos}{character vector of base URLs of the repositories to install from (passed to \code{install.packages()})} +\item{prefer_runiverse}{logical: Should the apache.r-universe repo be preferred +if it is up to date. Default is \code{TRUE}.} + \item{...}{Additional arguments passed to \code{install.packages()}} } \description{ diff --git a/r/tests/testthat/test-install-arrow.R b/r/tests/testthat/test-install-arrow.R index 5415fc27581c..8682029a682d 100644 --- a/r/tests/testthat/test-install-arrow.R +++ b/r/tests/testthat/test-install-arrow.R @@ -17,6 +17,7 @@ test_that("arrow_repos", { cran <- "https://cloud.r-project.org/" + runiverse <- "https://apache.r-universe.dev" ours <- "https://dl.example.com/ursalabs/fake_repo" other <- "https://cran.fiocruz.br/" @@ -25,12 +26,15 @@ test_that("arrow_repos", { arrow.dev_repo = ours ) withr::with_options(opts, { - expect_identical(arrow_repos(), cran) - expect_identical(arrow_repos(c(cran, ours)), cran) - expect_identical(arrow_repos(c(ours, other)), other) - expect_identical(arrow_repos(nightly = TRUE), c(ours, cran)) - expect_identical(arrow_repos(c(cran, ours), nightly = TRUE), c(ours, cran)) - expect_identical(arrow_repos(c(ours, other), nightly = TRUE), c(ours, other)) + expect_identical(arrow_repos(), c(runiverse, cran)) + expect_identical(arrow_repos(c(cran, ours)), c(runiverse, cran)) + expect_identical(arrow_repos(c(ours, other)), c(runiverse, other)) + expect_identical(arrow_repos(nightly = TRUE), c(ours, runiverse, cran)) + expect_identical(arrow_repos(c(cran, ours), nightly = TRUE), c(ours, runiverse, cran)) + expect_identical(arrow_repos(c(ours, other), nightly = TRUE), c(ours, runivderse, other)) + expect_identical(arrow_repos(nightly = TRUE, prefer_runiverse = FALSE), c(ours, cran)) + expect_identical(arrow_repos(c(cran, ours), nightly = TRUE, prefer_runiverse = FALSE), c(ours, cran)) + expect_identical(arrow_repos(c(ours, other), nightly = TRUE, prefer_runiverse = FALSE), c(ours, other)) }) }) From 46a8f57a8aded29dd2e74e089e8470cdfb6f43b5 Mon Sep 17 00:00:00 2001 From: Jonathan Keane Date: Thu, 4 Apr 2024 22:24:21 -0500 Subject: [PATCH 2/7] PR comments --- r/R/arrow-info.R | 3 ++- r/R/arrow-package.R | 12 ++++++++---- r/R/install-arrow.R | 7 ++----- r/man/install_arrow.Rd | 4 ---- r/tests/testthat/test-install-arrow.R | 16 ++++++---------- 5 files changed, 18 insertions(+), 24 deletions(-) diff --git a/r/R/arrow-info.R b/r/R/arrow-info.R index 54145b2ee120..916b6683fbcc 100644 --- a/r/R/arrow-info.R +++ b/r/R/arrow-info.R @@ -139,7 +139,8 @@ arrow_with_json <- function() { some_features_are_off <- function(features) { # `features` is a named logical vector (as in arrow_info()$capabilities) # Let's exclude some less relevant ones - blocklist <- c("lzo", "bz2", "brotli", "substrait") + # jemalloc is only included because it is sometimes disabled in our build process + blocklist <- c("lzo", "bz2", "brotli", "substrait", "jemalloc") # Return TRUE if any of the other features are FALSE !all(features[setdiff(names(features), blocklist)]) } diff --git a/r/R/arrow-package.R b/r/R/arrow-package.R index b34eea1f39aa..c40f2583f24f 100644 --- a/r/R/arrow-package.R +++ b/r/R/arrow-package.R @@ -212,13 +212,17 @@ configure_tzdb <- function() { "Run `arrow_info()` for more information." ) ) - # On macOS binaries from CRAN can be hobbled. If on macOS, and features - # are disabled, advise that reinstalling might help + # On macOS binaries from CRAN can be hobbled. They sometimes restrict access to our + # dependency source downloading even though we can build from source on their machines. + # They also refuse to allow libarrow binaries to be downloaded, so instead distribute + # hobbled arrow binaries + # If on macOS, and features are disabled, advise that reinstalling might help if (identical(tolower(Sys.info()[["sysname"]]), "darwin")) { packageStartupMessage( paste( - "The repository you retrieved Arrow from did not include all of Arrow's features.", - "You can install a fully-featured version by running `arrow::install_arrow()`." + "The repository you retrieved Arrow from did not include all of Arrow's features.\n", + "You can install a fully-featured version by running:\n", + "`install.packages('arrow', repos = 'https://apache.r-universe.dev')`." ) ) } diff --git a/r/R/install-arrow.R b/r/R/install-arrow.R index ce7bdf47abe9..0a02ab3d6de0 100644 --- a/r/R/install-arrow.R +++ b/r/R/install-arrow.R @@ -47,8 +47,6 @@ #' is `FALSE`. This sets the `ARROW_R_DEV` environment variable. #' @param repos character vector of base URLs of the repositories to install #' from (passed to `install.packages()`) -#' @param prefer_runiverse logical: Should the apache.r-universe repo be preferred -#' if it is up to date. Default is `TRUE`. #' @param ... Additional arguments passed to `install.packages()` #' @export #' @importFrom utils install.packages @@ -62,7 +60,6 @@ install_arrow <- function(nightly = FALSE, minimal = Sys.getenv("LIBARROW_MINIMAL", FALSE), verbose = Sys.getenv("ARROW_R_DEV", FALSE), repos = getOption("repos"), - prefer_runiverse = TRUE, ...) { conda <- isTRUE(grepl("conda", R.Version()$platform)) @@ -97,7 +94,7 @@ install_arrow <- function(nightly = FALSE, old <- options(opts) on.exit(options(old)) } - install.packages("arrow", repos = arrow_repos(repos, nightly, prefer_runiverse), ...) + install.packages("arrow", repos = arrow_repos(repos, nightly), ...) } if ("arrow" %in% loadedNamespaces()) { # If you've just sourced this file, "arrow" won't be (re)loaded @@ -105,7 +102,7 @@ install_arrow <- function(nightly = FALSE, } } -arrow_repos <- function(repos = getOption("repos"), nightly = FALSE, prefer_runiverse = TRUE) { +arrow_repos <- function(repos = getOption("repos"), nightly = FALSE) { if (length(repos) == 0 || identical(repos, c(CRAN = "@CRAN@"))) { # Set the default/CDN repos <- "https://cloud.r-project.org/" diff --git a/r/man/install_arrow.Rd b/r/man/install_arrow.Rd index 25f7a9329ac7..05d73b819d11 100644 --- a/r/man/install_arrow.Rd +++ b/r/man/install_arrow.Rd @@ -11,7 +11,6 @@ install_arrow( minimal = Sys.getenv("LIBARROW_MINIMAL", FALSE), verbose = Sys.getenv("ARROW_R_DEV", FALSE), repos = getOption("repos"), - prefer_runiverse = TRUE, ... ) } @@ -44,9 +43,6 @@ is \code{FALSE}. This sets the \code{ARROW_R_DEV} environment variable.} \item{repos}{character vector of base URLs of the repositories to install from (passed to \code{install.packages()})} -\item{prefer_runiverse}{logical: Should the apache.r-universe repo be preferred -if it is up to date. Default is \code{TRUE}.} - \item{...}{Additional arguments passed to \code{install.packages()}} } \description{ diff --git a/r/tests/testthat/test-install-arrow.R b/r/tests/testthat/test-install-arrow.R index 8682029a682d..5415fc27581c 100644 --- a/r/tests/testthat/test-install-arrow.R +++ b/r/tests/testthat/test-install-arrow.R @@ -17,7 +17,6 @@ test_that("arrow_repos", { cran <- "https://cloud.r-project.org/" - runiverse <- "https://apache.r-universe.dev" ours <- "https://dl.example.com/ursalabs/fake_repo" other <- "https://cran.fiocruz.br/" @@ -26,15 +25,12 @@ test_that("arrow_repos", { arrow.dev_repo = ours ) withr::with_options(opts, { - expect_identical(arrow_repos(), c(runiverse, cran)) - expect_identical(arrow_repos(c(cran, ours)), c(runiverse, cran)) - expect_identical(arrow_repos(c(ours, other)), c(runiverse, other)) - expect_identical(arrow_repos(nightly = TRUE), c(ours, runiverse, cran)) - expect_identical(arrow_repos(c(cran, ours), nightly = TRUE), c(ours, runiverse, cran)) - expect_identical(arrow_repos(c(ours, other), nightly = TRUE), c(ours, runivderse, other)) - expect_identical(arrow_repos(nightly = TRUE, prefer_runiverse = FALSE), c(ours, cran)) - expect_identical(arrow_repos(c(cran, ours), nightly = TRUE, prefer_runiverse = FALSE), c(ours, cran)) - expect_identical(arrow_repos(c(ours, other), nightly = TRUE, prefer_runiverse = FALSE), c(ours, other)) + expect_identical(arrow_repos(), cran) + expect_identical(arrow_repos(c(cran, ours)), cran) + expect_identical(arrow_repos(c(ours, other)), other) + expect_identical(arrow_repos(nightly = TRUE), c(ours, cran)) + expect_identical(arrow_repos(c(cran, ours), nightly = TRUE), c(ours, cran)) + expect_identical(arrow_repos(c(ours, other), nightly = TRUE), c(ours, other)) }) }) From df4d02e22b29fb46163cba4c8ae03b1051f784a3 Mon Sep 17 00:00:00 2001 From: Jonathan Keane Date: Thu, 4 Apr 2024 22:32:41 -0500 Subject: [PATCH 3/7] whitespace --- r/R/arrow-package.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/r/R/arrow-package.R b/r/R/arrow-package.R index c40f2583f24f..f6977e626276 100644 --- a/r/R/arrow-package.R +++ b/r/R/arrow-package.R @@ -219,7 +219,7 @@ configure_tzdb <- function() { # If on macOS, and features are disabled, advise that reinstalling might help if (identical(tolower(Sys.info()[["sysname"]]), "darwin")) { packageStartupMessage( - paste( + paste0( "The repository you retrieved Arrow from did not include all of Arrow's features.\n", "You can install a fully-featured version by running:\n", "`install.packages('arrow', repos = 'https://apache.r-universe.dev')`." From 8e1bc1f0cc40c4ccf7e25daef456ef96a4adc1d9 Mon Sep 17 00:00:00 2001 From: Jonathan Keane Date: Thu, 4 Apr 2024 22:38:53 -0500 Subject: [PATCH 4/7] one last clean up --- r/R/install-arrow.R | 4 ---- 1 file changed, 4 deletions(-) diff --git a/r/R/install-arrow.R b/r/R/install-arrow.R index 0a02ab3d6de0..b5126d86d86c 100644 --- a/r/R/install-arrow.R +++ b/r/R/install-arrow.R @@ -109,10 +109,6 @@ arrow_repos <- function(repos = getOption("repos"), nightly = FALSE) { } dev_repo <- getOption("arrow.dev_repo", "https://nightlies.apache.org/arrow/r") # Remove it if it's there (so nightly=FALSE won't accidentally pull from it) - repos <- setdiff(repos, dev_repo) - if (prefer_runiverse) { - repos <- c("https://apache.r-universe.dev", repos) - } if (nightly) { # Add it first repos <- c(dev_repo, repos) From 2513c31d560e68cc2cb7f4ae3fe1ef20c9d752a4 Mon Sep 17 00:00:00 2001 From: Jonathan Keane Date: Thu, 4 Apr 2024 22:40:30 -0500 Subject: [PATCH 5/7] ack, one more last one --- r/R/install-arrow.R | 1 + 1 file changed, 1 insertion(+) diff --git a/r/R/install-arrow.R b/r/R/install-arrow.R index b5126d86d86c..ba11df0a12f8 100644 --- a/r/R/install-arrow.R +++ b/r/R/install-arrow.R @@ -109,6 +109,7 @@ arrow_repos <- function(repos = getOption("repos"), nightly = FALSE) { } dev_repo <- getOption("arrow.dev_repo", "https://nightlies.apache.org/arrow/r") # Remove it if it's there (so nightly=FALSE won't accidentally pull from it) + repos <- setdiff(repos, dev_repo) if (nightly) { # Add it first repos <- c(dev_repo, repos) From 0361aab1e757d72b6155bfd62f06bc049d4f5fde Mon Sep 17 00:00:00 2001 From: Jonathan Keane Date: Fri, 5 Apr 2024 07:59:57 -0500 Subject: [PATCH 6/7] Update r/R/install-arrow.R Co-authored-by: Neal Richardson --- r/R/install-arrow.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/r/R/install-arrow.R b/r/R/install-arrow.R index ba11df0a12f8..fce4b4f142c0 100644 --- a/r/R/install-arrow.R +++ b/r/R/install-arrow.R @@ -76,7 +76,7 @@ install_arrow <- function(nightly = FALSE, ARROW_R_DEV = verbose, ARROW_USE_PKG_CONFIG = use_system ) - # On Rosetta, we have to build without JEMALLOC, so we also can't autobrew + # On Rosetta, we have to build without JEMALLOC rosetta <- on_rosetta() if (rosetta) { Sys.setenv(ARROW_JEMALLOC = "OFF") From 4cd3b5f9f8110ea3d881e1172bde69f9f6563d2a Mon Sep 17 00:00:00 2001 From: Jonathan Keane Date: Fri, 5 Apr 2024 08:02:49 -0500 Subject: [PATCH 7/7] Update r/R/install-arrow.R Co-authored-by: Neal Richardson --- r/R/install-arrow.R | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/r/R/install-arrow.R b/r/R/install-arrow.R index fce4b4f142c0..44b876537490 100644 --- a/r/R/install-arrow.R +++ b/r/R/install-arrow.R @@ -77,8 +77,7 @@ install_arrow <- function(nightly = FALSE, ARROW_USE_PKG_CONFIG = use_system ) # On Rosetta, we have to build without JEMALLOC - rosetta <- on_rosetta() - if (rosetta) { + if (on_rosetta()) { Sys.setenv(ARROW_JEMALLOC = "OFF") Sys.setenv(FORCE_BUNDLED_BUILD = "true") }