You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by pa...@apache.org on 2022/12/14 19:59:16 UTC

[arrow] branch master updated: ARROW-17662: [R] Facilitate offline installation from binaries (#14086)

This is an automated email from the ASF dual-hosted git repository.

paleolimbot pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new 794aefd640 ARROW-17662: [R] Facilitate offline installation from binaries (#14086)
794aefd640 is described below

commit 794aefd6409a3da339ecc1a3d1ea6466b3d9ddb6
Author: Pierre Gramme <pg...@gmail.com>
AuthorDate: Wed Dec 14 20:59:05 2022 +0100

    ARROW-17662: [R] Facilitate offline installation from binaries (#14086)
    
    Facilitate the offline installation of R package with pre-downloaded libarrow binaries
    
    Authored-by: Pierre Gramme <pi...@infrabel.be>
    Signed-off-by: Dewey Dunnington <de...@fishandwhistle.net>
---
 r/tools/nixlibs.R       | 25 +++++++++++++++++++------
 r/vignettes/install.Rmd | 19 +++++++++++++++++--
 2 files changed, 36 insertions(+), 8 deletions(-)

diff --git a/r/tools/nixlibs.R b/r/tools/nixlibs.R
index f13824b7bf..e8af2386c6 100644
--- a/r/tools/nixlibs.R
+++ b/r/tools/nixlibs.R
@@ -61,10 +61,10 @@ quietly <- !env_is("ARROW_R_DEV", "true")
 # and don't fall back to a full source build
 build_ok <- !env_is("LIBARROW_BUILD", "false")
 
-# Check if we're doing an offline build.
+# Check if we're authorized to download (not asked an offline build).
 # (Note that cmake will still be downloaded if necessary
 #  https://arrow.apache.org/docs/developers/cpp/building.html#offline-builds)
-download_ok <- !test_mode && !env_is("TEST_OFFLINE_BUILD", "true") && try_download("https://raw.githubusercontent.com/apache/arrow/master/r/DESCRIPTION", tempfile(), hush = TRUE)
+download_ok <- !test_mode && !env_is("TEST_OFFLINE_BUILD", "true")
 
 # This "tools/thirdparty_dependencies" path, within the tar file, might exist if
 # create_package_with_all_dependencies() was run, or if someone has created it
@@ -83,7 +83,8 @@ download_binary <- function(lib) {
     }
   } else {
     if (!quietly) {
-      cat(sprintf("*** No libarrow binary found for version %s (%s)\n", VERSION, lib))
+      cat(sprintf("*** Downloading libarrow binary failed for version %s (%s)\n    at %s\n",
+                  VERSION, lib, binary_url))
     }
     libfile <- NULL
   }
@@ -706,13 +707,25 @@ if (!test_mode && !file.exists(paste0(dst_dir, "/include/arrow/api.h"))) {
   # don't need to do anything. Otherwise,
   # (1) Look for a prebuilt binary for this version
   bin_file <- src_dir <- NULL
-  if (download_ok) {
+
+  if (!identical(Sys.getenv("ARROW_DOWNLOADED_BINARIES"), "")) {
+    bin_zip <- Sys.getenv("ARROW_DOWNLOADED_BINARIES")
+    cat(sprintf("*** Using pre-downloaded zip for libarrow binaries: %s\n", bin_zip))
+    if (file.exists(bin_zip)) {
+      bin_file <- tempfile()
+      file.copy(bin_zip, bin_file)
+    } else {
+      cat(sprintf("*** File not found: %s ($ARROW_DOWNLOADED_BINARIES)\n", bin_zip))
+      bin_file <- NULL
+    }
+  } else if (download_ok) {
     binary_flavor <- identify_binary()
     if (!is.null(binary_flavor)) {
       # The env vars say we can, and we've determined a lib that should work
       bin_file <- download_binary(binary_flavor)
     }
   }
+
   if (!is.null(bin_file)) {
     # Extract them
     dir.create(dst_dir, showWarnings = !quietly, recursive = TRUE)
@@ -729,9 +742,9 @@ if (!test_mode && !file.exists(paste0(dst_dir, "/include/arrow/api.h"))) {
       ))
       build_libarrow(src_dir, dst_dir)
     } else {
-      cat("*** Proceeding without libarrow\n")
+      cat("*** Proceeding without libarrow (no local source)\n")
     }
   } else {
-    cat("*** Proceeding without libarrow\n")
+    cat("*** Proceeding without libarrow (build not authorized)\n")
   }
 }
diff --git a/r/vignettes/install.Rmd b/r/vignettes/install.Rmd
index e31451ba5c..106e47884e 100644
--- a/r/vignettes/install.Rmd
+++ b/r/vignettes/install.Rmd
@@ -127,8 +127,22 @@ The libarrow binaries include support for AWS S3 and GCS, so they require the
 libcurl and openssl libraries installed separately, as noted above.
 If you don't have these installed, the libarrow binary won't be used, and you will fall back to the full source build (with S3 and GCS support disabled).
 
-Users on CentOS 7 will also need to install and configure a C++17 compiler.
-See "System dependencies" above.
+If the internet access of your computer doesn't allow downloading the libarrow binaries (e.g. if access is limited to CRAN), you can first identify the right source and version by trying to install on the offline computer:
+
+```{r, eval = FALSE}
+Sys.setenv("NOT_CRAN" = TRUE, "LIBARROW_BUILD" = FALSE, "ARROW_R_DEV" = TRUE)
+install.packages("arrow")
+# This will fail if no internet access, but will print the binaries URL
+```
+
+Then you can obtain the libarrow binaries (using a computer with internet access) and transfer the zip file to the target computer. Now you just have to tell the installer to use that pre-downloaded file:
+
+```{r, eval = FALSE}
+# Watchout: release numbers of the pre-downloaded libarrow must match CRAN!
+Sys.setenv("ARROW_DOWNLOADED_BINARIES" = "/path/to/downloaded/libarrow.zip")
+install.packages("arrow")
+```
+
 
 ## Install release version (less easy)
 
@@ -418,6 +432,7 @@ A second method for offline installation is a little more hands-on. Follow these
 * Create the environment variable `ARROW_THIRDPARTY_DEPENDENCY_DIR` on the offline computer, pointing to the copied directory.
 * Install the arrow package as usual.
 
+For offline installation using libarrow binaries, see Method 1b above.
 
 ## Troubleshooting