paleolimbot commented on code in PR #38236:
URL: https://github.com/apache/arrow/pull/38236#discussion_r1364120494
##########
r/tools/nixlibs.R:
##########
@@ -15,35 +15,55 @@
# specific language governing permissions and limitations
# under the License.
-args <- commandArgs(TRUE)
-VERSION <- args[1]
-dst_dir <- paste0("libarrow/arrow-", VERSION)
-
-# TESTING is set in test-nixlibs.R; it won't be set when called from configure
-test_mode <- exists("TESTING")
+#### Fuctions #### check end of file for main logic
+env_is <- function(var, value) identical(tolower(Sys.getenv(var)), value)
-# Prevent error with binary selection during testing.
-if (test_mode && is.na(VERSION)) {
- VERSION <- "8.0.0.9000"
+# Log messages in the style of the configure script
+lg <- function(..., .indent = "***") {
+ cat(.indent, " ", sprintf(...), "\n", sep = "")
}
-dev_version <- package_version(VERSION)[1, 4]
-is_release <- is.na(dev_version) || dev_version < "100"
-on_macos <- tolower(Sys.info()[["sysname"]]) == "darwin"
-checksum_path <- Sys.getenv("ARROW_R_CHECKSUM_PATH", "tools/checksums")
+del <- function(path) {
+ options(.arrow.cleanup = c(getOption(".arrow.cleanup"), path))
+}
-# Small dev versions are added for R-only changes during CRAN submission.
-if (is_release) {
- VERSION <- package_version(VERSION)[1, 1:3]
- arrow_repo <- paste0(getOption("arrow.repo",
sprintf("https://apache.jfrog.io/artifactory/arrow/r/%s", VERSION)),
"/libarrow/")
-} else {
- arrow_repo <- paste0(getOption("arrow.dev_repo",
"https://nightlies.apache.org/arrow/r"), "/libarrow/")
+# Exit the script after logging with .status=1 instead of throwing an error
+exit <- function(..., .status = 1) {
+ lg(...)
+ q(save = "no", status = .status)
}
-options(.arrow.cleanup = character()) # To collect dirs to rm on exit
-on.exit(unlink(getOption(".arrow.cleanup")))
-env_is <- function(var, value) identical(tolower(Sys.getenv(var)), value)
+# checks the nightly repo for the latest nightly version X.Y.Z.100<dev>
+find_latest_nightly <- function(description_version) {
Review Comment:
```suggestion
find_latest_nightly <- function(description_version, contrib_file_or_url =
"https://nightlies.apache.org/arrow/r/src/contrib") {
```
##########
r/tools/nixlibs.R:
##########
@@ -15,35 +15,55 @@
# specific language governing permissions and limitations
# under the License.
-args <- commandArgs(TRUE)
-VERSION <- args[1]
-dst_dir <- paste0("libarrow/arrow-", VERSION)
-
-# TESTING is set in test-nixlibs.R; it won't be set when called from configure
-test_mode <- exists("TESTING")
+#### Fuctions #### check end of file for main logic
+env_is <- function(var, value) identical(tolower(Sys.getenv(var)), value)
-# Prevent error with binary selection during testing.
-if (test_mode && is.na(VERSION)) {
- VERSION <- "8.0.0.9000"
+# Log messages in the style of the configure script
+lg <- function(..., .indent = "***") {
+ cat(.indent, " ", sprintf(...), "\n", sep = "")
}
-dev_version <- package_version(VERSION)[1, 4]
-is_release <- is.na(dev_version) || dev_version < "100"
-on_macos <- tolower(Sys.info()[["sysname"]]) == "darwin"
-checksum_path <- Sys.getenv("ARROW_R_CHECKSUM_PATH", "tools/checksums")
+del <- function(path) {
+ options(.arrow.cleanup = c(getOption(".arrow.cleanup"), path))
+}
-# Small dev versions are added for R-only changes during CRAN submission.
-if (is_release) {
- VERSION <- package_version(VERSION)[1, 1:3]
- arrow_repo <- paste0(getOption("arrow.repo",
sprintf("https://apache.jfrog.io/artifactory/arrow/r/%s", VERSION)),
"/libarrow/")
-} else {
- arrow_repo <- paste0(getOption("arrow.dev_repo",
"https://nightlies.apache.org/arrow/r"), "/libarrow/")
+# Exit the script after logging with .status=1 instead of throwing an error
+exit <- function(..., .status = 1) {
+ lg(...)
+ q(save = "no", status = .status)
}
-options(.arrow.cleanup = character()) # To collect dirs to rm on exit
-on.exit(unlink(getOption(".arrow.cleanup")))
-env_is <- function(var, value) identical(tolower(Sys.getenv(var)), value)
+# checks the nightly repo for the latest nightly version X.Y.Z.100<dev>
+find_latest_nightly <- function(description_version) {
+ if (!startsWith(arrow_repo, "https://nightlies.apache.org/arrow/r")) {
+ lg("Detected non standard dev repo: %s, not checking latest nightly
version.", arrow_repo)
+ return(description_version)
+ }
+
+ res <- try(
+ {
+ # Binaries are only uploaded if all jobs pass so can just look at the
source versions.
+ urls <- readLines("https://nightlies.apache.org/arrow/r/src/contrib")
Review Comment:
```suggestion
urls <- readLines(contrib_file_or_url)
```
##########
r/tools/nixlibs.R:
##########
@@ -15,35 +15,54 @@
# specific language governing permissions and limitations
# under the License.
-args <- commandArgs(TRUE)
-VERSION <- args[1]
-dst_dir <- paste0("libarrow/arrow-", VERSION)
-
-# TESTING is set in test-nixlibs.R; it won't be set when called from configure
-test_mode <- exists("TESTING")
+#### Fuctions #### check end of file for main logic
+env_is <- function(var, value) identical(tolower(Sys.getenv(var)), value)
-# Prevent error with binary selection during testing.
-if (test_mode && is.na(VERSION)) {
- VERSION <- "8.0.0.9000"
+# Log messages in the style of the configure script
+lg <- function(..., .indent = "***") {
+ cat(.indent, " ", sprintf(...), "\n", sep = "")
}
-dev_version <- package_version(VERSION)[1, 4]
-is_release <- is.na(dev_version) || dev_version < "100"
-on_macos <- tolower(Sys.info()[["sysname"]]) == "darwin"
-checksum_path <- Sys.getenv("ARROW_R_CHECKSUM_PATH", "tools/checksums")
-
-# Small dev versions are added for R-only changes during CRAN submission.
-if (is_release) {
- VERSION <- package_version(VERSION)[1, 1:3]
- arrow_repo <- paste0(getOption("arrow.repo",
sprintf("https://apache.jfrog.io/artifactory/arrow/r/%s", VERSION)),
"/libarrow/")
-} else {
- arrow_repo <- paste0(getOption("arrow.dev_repo",
"https://nightlies.apache.org/arrow/r"), "/libarrow/")
+# Exit the script after logging with .status=1 instead of throwing an error
+exit <- function(..., .status = 1) {
+ lg(...)
+ q(save = "no", status = .status)
}
-options(.arrow.cleanup = character()) # To collect dirs to rm on exit
-on.exit(unlink(getOption(".arrow.cleanup")))
-env_is <- function(var, value) identical(tolower(Sys.getenv(var)), value)
+# checks the nightly repo for the latest nightly version X.Y.Z.100<dev>
+find_latest_nightly <- function(description_version) {
+ if (!startsWith(arrow_repo, "https://nightlies.apache.org/arrow/r")) {
+ lg("Detected non standard dev repo: %s, not checking latest nightly
version.", arrow_repo)
+ return(description_version)
+ }
+
+ res <- try(
+ {
+ url_file <- tempfile()
+ on.exit(unlink(url_file))
+ # Binaries are only uploaded if all jobs pass so can just look at the
source versions.
+ download.file("https://nightlies.apache.org/arrow/r/src/contrib",
url_file, quiet = TRUE)
+ urls <- readLines(url_file)
+ versions <- grep("arrow_.*\\.tar\\.gz", urls, value = TRUE)
+ versions <- sub(".*arrow_(.*)\\.tar\\.gz.*", "\\1", x = versions)
+ versions <- sapply(versions, package_version)
+ versions <- data.frame(do.call(rbind, versions))
+ matching_major <- versions[versions$X1 == description_version[1, 1], ]
+ latest <- matching_major[which.max(matching_major$X4), ]
+ package_version(paste0(latest, collapse = "."))
Review Comment:
It's worth adding a test for this to make sure it doesn't fail in a strange
or cryptic way. Then you can `lg("No nightlies found for major version XXX")`
and it's clear that when a contributor unexpectedly gets a lengthy source build
when they weren't expecting one. I added two suggestsions above that will let
you write a test after writing a local file with some content that has 0, 1, or
>1 major versions.
You can workshop this how you'd like, but it is dangerous to use `sapply()`
or to subset a `data.frame` without `, drop = FALSE` (or `TRUE`, depending on
what you want) because they do not guarantee type stability.
--
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]