Copilot commented on code in PR #55681:
URL: https://github.com/apache/arrow/pull/55681#discussion_r4630411456


##########
r/tools/nixlibs.R:
##########
@@ -871,6 +917,149 @@ set_thirdparty_urls <- function(env_var_list) {
   env_var_list
 }
 
+# The libarrow build uses thirdparty dependencies from the system if they are
+# available and otherwise builds them from source, downloading from 
ARROW_*_URL.
+# Some are required even for a minimal build. To make sure that works without
+# network access, `make sync-cpp` saves (trimmed) source tarballs into
+# vendored_dependency_dir and we point ARROW_*_URL at them here.
+# This does not change whether the system versions are used.
+# `vendored` is the result of `usable_vendored_dependencies()`.
+# With LIBARROW_VENDORED_DEPS=false, the build uses the full upstream sources 
of
+# the thirdparty dependencies instead of the vendored ones, so it needs to be
+# able to download them (or find them in thirdparty_dependency_dir). Some of
+# them are needed even for a minimal build, so error with a clear message
+# rather than failing later in the libarrow build.
+check_vendored_deps_setting <- function(thirdparty_deps_unavailable) {
+  if (use_vendored_deps || !thirdparty_deps_unavailable) {
+    return(invisible(TRUE))
+  }
+  offline_build <- env_is("ARROW_OFFLINE_BUILD", "true")
+  stop(

Review Comment:
   Opting out of vendored sources does not necessarily require downloads: users 
can supply local archives through `ARROW_*_URL`. With those overrides, 
`LIBARROW_VENDORED_DEPS=false` and `ARROW_OFFLINE_BUILD=true`, this check still 
stops before CMake can use the local archives because no thirdparty directory 
exists. Please allow explicitly supplied local dependency sources, or defer the 
failure until dependency resolution actually finds a missing source.



##########
r/tools/nixlibs.R:
##########
@@ -871,6 +917,149 @@ set_thirdparty_urls <- function(env_var_list) {
   env_var_list
 }
 
+# The libarrow build uses thirdparty dependencies from the system if they are
+# available and otherwise builds them from source, downloading from 
ARROW_*_URL.
+# Some are required even for a minimal build. To make sure that works without
+# network access, `make sync-cpp` saves (trimmed) source tarballs into
+# vendored_dependency_dir and we point ARROW_*_URL at them here.
+# This does not change whether the system versions are used.
+# `vendored` is the result of `usable_vendored_dependencies()`.
+# With LIBARROW_VENDORED_DEPS=false, the build uses the full upstream sources 
of
+# the thirdparty dependencies instead of the vendored ones, so it needs to be
+# able to download them (or find them in thirdparty_dependency_dir). Some of
+# them are needed even for a minimal build, so error with a clear message
+# rather than failing later in the libarrow build.
+check_vendored_deps_setting <- function(thirdparty_deps_unavailable) {
+  if (use_vendored_deps || !thirdparty_deps_unavailable) {
+    return(invisible(TRUE))
+  }
+  offline_build <- env_is("ARROW_OFFLINE_BUILD", "true")
+  stop(
+    "LIBARROW_VENDORED_DEPS=false, so the thirdparty sources included in 
the\n",
+    "package won't be used, but they can't be downloaded either (",
+    if (offline_build) "ARROW_OFFLINE_BUILD=true" else "no network connection 
was found",
+    ").\n",
+    "libarrow needs some of them even for a minimal build. Either:\n",
+    "  * unset LIBARROW_VENDORED_DEPS to use the sources included in the 
package,\n",
+    "  * build with network access",
+    if (offline_build) " (and unset ARROW_OFFLINE_BUILD)",
+    ", or\n",
+    "  * set ARROW_THIRDPARTY_DEPENDENCY_DIR to a directory with the 
downloaded\n",
+    "    sources (currently '",
+    thirdparty_dependency_dir,
+    "', which doesn't exist).\n",
+    "See https://arrow.apache.org/docs/r/articles/install.html";,
+    call. = FALSE
+  )
+}
+
+with_vendored_dependencies <- function(env_var_list, vendored) {
+  for (env_varname in names(vendored)) {
+    if (!is.null(env_var_list[[env_varname]]) || !env_is(env_varname, "")) {
+      # Respect the user's (or set_thirdparty_urls()'s) choice
+      next
+    }
+    env_var_list <- replace(env_var_list, env_varname, vendored[[env_varname]])
+  }
+  env_var_list
+}
+
+# Returns the paths of the vendored tarballs that the libarrow source in
+# `src_dir` (tools/cpp, or e.g. ../cpp of a git checkout) can use, named by
+# their ARROW_*_URL.
+# The tarballs are trimmed, so the libarrow build only accepts them with the
+# checksums that `with_vendored_checksums()` sets. We only use the tarballs
+# that were trimmed from the version that `src_dir`'s versions.txt pins
+# (according to the checksums.txt file that tools/vendor_dependencies.sh
+# writes).
+usable_vendored_dependencies <- function(src_dir) {
+  if (!use_vendored_deps) {
+    lg("LIBARROW_VENDORED_DEPS=false, so not using vendored dependencies", 
.indent = "****")
+    return(character())
+  }
+  manifest <- read_vendored_checksums()
+  if (is.null(manifest)) {
+    # e.g. building from a git checkout without `make sync-cpp`
+    if (!quietly) {
+      lg("No vendored dependencies found, they will be built with CMake if 
needed", .indent = "****")
+    }
+    return(character())
+  }
+  if (is.null(src_dir)) {
+    return(character())
+  }
+  expected <- read_thirdparty_checksums(file.path(src_dir, "thirdparty", 
"versions.txt"))
+  deps_df <- get_component_names()

Review Comment:
   After `make sync-cpp` followed by `make clean`, the vendored manifest 
remains but `tools/cpp` is removed. A source installation using `../cpp` then 
aborts here because `get_component_names()` runs a shell helper that reads only 
`tools/cpp/thirdparty/versions.txt`. Pass the selected `src_dir` through 
`get_component_names()` to `tools/download_dependencies_R.sh` so dependency 
filenames come from the source being built.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to