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

brycemecum 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 409a016e5f GH-45716: [R][CI] Refactor skip_on_python_older_than to not 
initialize reticulate (#46079)
409a016e5f is described below

commit 409a016e5fdfa28cabd580b7ec81c42991c0748e
Author: Bryce Mecum <[email protected]>
AuthorDate: Thu Apr 10 07:58:25 2025 -0700

    GH-45716: [R][CI] Refactor skip_on_python_older_than to not initialize 
reticulate (#46079)
    
    ### Rationale for this change
    
    This fixes our `test-r-offline-maximal` job which started failing because 
of a change in reticulate 1.41.0.
    
    ### What changes are included in this PR?
    
    Changed internals of our skip_on_python_older_than helper.
    
    ### Are these changes tested?
    
    Locally, need to test in CI before merging.
    
    ### Are there any user-facing changes?
    
    No.
    * GitHub Issue: #45716
    
    Authored-by: Bryce Mecum <[email protected]>
    Signed-off-by: Bryce Mecum <[email protected]>
---
 r/tests/testthat/helper-skip.R | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/r/tests/testthat/helper-skip.R b/r/tests/testthat/helper-skip.R
index ce2ad34e9f..eb69fb55dc 100644
--- a/r/tests/testthat/helper-skip.R
+++ b/r/tests/testthat/helper-skip.R
@@ -116,11 +116,16 @@ skip_on_python_older_than <- function(python_version) {
     return()
   }
 
-  if (!reticulate::py_available(initialize = TRUE)) {
+  # We want to be careful not to initialize reticulate in this helper function
+  config <- reticulate::py_discover_config()
+
+  # It isn't documented, but config should be NULL when py_discovery_config()
+  # fails to find a valid Python installation
+  if (is.null(config)) {
     skip("Python isn't available")
   }
 
-  if (reticulate::py_version() < python_version) {
+  if (config$version < python_version) {
     skip(paste("Python version:", reticulate::py_version()))
   }
 }

Reply via email to