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

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


The following commit(s) were added to refs/heads/main by this push:
     new 7b7bbdc492 GH-37907: [R] Setting rosetta variable is missing (#37961)
7b7bbdc492 is described below

commit 7b7bbdc49250a1a91df079995a38208d55d45d42
Author: Fernando Mayer <[email protected]>
AuthorDate: Fri Oct 13 00:23:42 2023 +0100

    GH-37907: [R] Setting rosetta variable is missing (#37961)
    
    
    
    ### Rationale for this change
    
    The latest version of `r/R/install-arrow.R`  was not working properly, 
since it was relying on the `on_rosetta()` function, which is not defined 
elsewhere. I just fixed the identification of rosetta in the script.
    
    With the current code, the following gives an error
    
    ````r
    > 
source("https://raw.githubusercontent.com/apache/arrow/master/r/R/install-arrow.R";)
    > install_arrow()
    Error in on_rosetta() : could not find function "on_rosetta"
    ````
    
    ### What changes are included in this PR?
    
    It only removed the `on_rosetta()` function, which was not defined 
elsewhere, and reverted back to the `rosetta` object to identify if rosetta is 
present or not on a user's system.
    
    ### Are these changes tested?
    
    Yes. It was tested with the current code and the proposed PR. The proposed 
PR works as expected.
    
    ### Are there any user-facing changes?
    
    No.
    
    * Closes: #37907
    
    Lead-authored-by: Fernando Mayer <[email protected]>
    Co-authored-by: Jonathan Keane <[email protected]>
    Signed-off-by: Nic Crane <[email protected]>
---
 r/R/arrow-package.R                   |  6 ------
 r/R/install-arrow.R                   |  9 ++++++++-
 r/tests/testthat/test-arrow-pacakge.R | 21 ---------------------
 r/tests/testthat/test-install-arrow.R |  5 +++++
 4 files changed, 13 insertions(+), 28 deletions(-)

diff --git a/r/R/arrow-package.R b/r/R/arrow-package.R
index 8655bf5a1c..eec95b8282 100644
--- a/r/R/arrow-package.R
+++ b/r/R/arrow-package.R
@@ -241,12 +241,6 @@ on_macos_10_13_or_lower <- function() {
     package_version(unname(Sys.info()["release"])) < "18.0.0"
 }
 
-on_rosetta <- function() {
-  # make sure to suppress warnings and ignore the stdout + stderr so that this 
is silent
-  identical(tolower(Sys.info()[["sysname"]]), "darwin") &&
-    identical(suppressWarnings(system("sysctl -n sysctl.proc_translated", 
intern = TRUE, ignore.stderr = TRUE)), "1")
-}
-
 option_use_threads <- function() {
   !is_false(getOption("arrow.use_threads"))
 }
diff --git a/r/R/install-arrow.R b/r/R/install-arrow.R
index 715478f6d0..6db6f2b0ad 100644
--- a/r/R/install-arrow.R
+++ b/r/R/install-arrow.R
@@ -79,7 +79,8 @@ install_arrow <- function(nightly = FALSE,
     # 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
-    if (on_rosetta()) {
+    rosetta <- on_rosetta()
+    if (rosetta) {
       Sys.setenv(ARROW_JEMALLOC = "OFF")
     }
     if (apple_m1 || rosetta) {
@@ -267,3 +268,9 @@ wslify_path <- function(path) {
   end_path <- strsplit(path, drive_expr)[[1]][-1]
   file.path(wslified_drive, end_path)
 }
+
+on_rosetta <- function() {
+  # make sure to suppress warnings and ignore the stderr so that this is 
silent where proc_translated doesn't exist
+  identical(tolower(Sys.info()[["sysname"]]), "darwin") &&
+    identical(suppressWarnings(system("sysctl -n sysctl.proc_translated", 
intern = TRUE, ignore.stderr = TRUE)), "1")
+}
diff --git a/r/tests/testthat/test-arrow-pacakge.R 
b/r/tests/testthat/test-arrow-pacakge.R
deleted file mode 100644
index 2d79467fa3..0000000000
--- a/r/tests/testthat/test-arrow-pacakge.R
+++ /dev/null
@@ -1,21 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-test_that("on_rosetta() does not warn", {
-  # There is no warning
-  expect_warning(on_rosetta(), NA)
-})
diff --git a/r/tests/testthat/test-install-arrow.R 
b/r/tests/testthat/test-install-arrow.R
index 787c8ea2c0..5415fc2758 100644
--- a/r/tests/testthat/test-install-arrow.R
+++ b/r/tests/testthat/test-install-arrow.R
@@ -33,3 +33,8 @@ test_that("arrow_repos", {
     expect_identical(arrow_repos(c(ours, other), nightly = TRUE), c(ours, 
other))
   })
 })
+
+test_that("on_rosetta() does not warn", {
+  # There is no warning
+  expect_warning(on_rosetta(), NA)
+})

Reply via email to