jonkeane commented on code in PR #49216:
URL: https://github.com/apache/arrow/pull/49216#discussion_r2790695424


##########
dev/tasks/r/github.macos.cran.yml:
##########
@@ -80,3 +80,161 @@ jobs:
           name: test-output
           path: arrow-tests/testthat.Rout*
         if: always()
+
+  
+  # R-universe style build and check (macOS only)
+  # Adapted from 
https://github.com/r-universe-org/workflows/blob/v3/.github/workflows/build.yml
+  r-universe-source:
+    name: "R-universe: Build source package"
+    runs-on: ubuntu-latest
+    timeout-minutes: 90
+    outputs:
+      sourcepkg: {{ "${{ steps.build.outputs.sourcepkg }}" }}
+      package: {{ "${{ steps.build.outputs.package }}" }}
+      version: {{ "${{ steps.build.outputs.version }}" }}
+    steps:
+      {{ macros.github_checkout_arrow()|indent }}
+
+      - name: Setup R
+        uses: r-lib/actions/setup-r@v2
+        with:
+          use-public-rspm: true
+
+      - name: Build source package
+        id: build
+        run: |
+          cd arrow/r
+          PACKAGE=$(grep '^Package:' DESCRIPTION | cut -d' ' -f2)
+          VERSION=$(grep '^Version:' DESCRIPTION | cut -d' ' -f2)
+          echo "package=${PACKAGE}" >> $GITHUB_OUTPUT
+          echo "version=${VERSION}" >> $GITHUB_OUTPUT
+          # sync-cpp copies C++ source, NOTICE.txt, LICENSE.txt, .env into 
tools/
+          make clean
+          make sync-cpp
+          R CMD build .
+          SOURCEPKG="${PACKAGE}_${VERSION}.tar.gz"
+          echo "sourcepkg=${SOURCEPKG}" >> $GITHUB_OUTPUT
+
+      - name: Upload source package
+        uses: actions/upload-artifact@v4
+        with:
+          name: package-source
+          path: arrow/r/{{ "${{ steps.build.outputs.sourcepkg }}" }}
+
+  r-universe-macos:
+    needs: [r-universe-source]
+    if: {{ "${{ !cancelled() && needs.r-universe-source.outputs.sourcepkg }}" 
}}
+    runs-on: macos-{{ "${{ matrix.arch == 'x86_64' && '15-intel' || '15' }}" }}
+    timeout-minutes: 120
+    name: "R-universe: R-${{ "${{ matrix.r }}" }} macOS ${{ "${{ matrix.arch 
}}" }}"
+    strategy:
+      fail-fast: false
+      matrix:
+        r: [ 'devel', 'release' ]
+        arch: [ 'x86_64', 'arm64' ]
+    steps:
+      # r-universe actions internally download 'package-source' artifact
+
+      - name: "Prepare macOS system"
+        timeout-minutes: 10
+        uses: r-universe-org/actions/macos-prep@v11
+        with:
+          version: {{ "${{ matrix.r }}" }}
+          fortran: 'true'
+
+      - name: Install R-${{ "${{ matrix.r }}" }} for macOS
+        timeout-minutes: 10
+        uses: r-universe-org/actions/setup-r@v11
+        id: install-r
+        with:
+          r-version: {{ "${{ matrix.r }}" }}
+
+      - name: Install ICU for boost_locale
+        run: |
+          # Download and install ICU from R macOS recipes
+          # ICU is needed for bundled Boost's locale component
+          ARCH=$(uname -m)
+          if [ "$ARCH" = "arm64" ]; then
+            # Try darwin23 first (macOS 14+), then darwin20 (macOS 11+)
+            
ICU_URL="https://mac.r-project.org/bin/darwin23/arm64/icu-71.1-darwin.23-arm64.tar.xz";
+            
FALLBACK_URL="https://mac.r-project.org/bin/darwin20/arm64/icu-71.1-darwin.20-arm64.tar.xz";
+          else
+            # x86_64 only available on darwin20
+            
ICU_URL="https://mac.r-project.org/bin/darwin20/x86_64/icu-71.1-darwin.20-x86_64.tar.xz";
+            FALLBACK_URL=""
+          fi
+          echo "Downloading ICU from: $ICU_URL"
+          curl -fsSL "$ICU_URL" -o /tmp/icu.tar.xz || {
+            if [ -n "$FALLBACK_URL" ]; then
+              echo "Failed, trying fallback: $FALLBACK_URL"
+              curl -fsSL "$FALLBACK_URL" -o /tmp/icu.tar.xz
+            else
+              echo "ICU download failed and no fallback available"
+              exit 1
+            fi
+          }
+          sudo tar -xf /tmp/icu.tar.xz -C /
+          echo "ICU installed. Checking for headers:"
+          ls -la /opt/R/${ARCH}/include/unicode/ | head -10 || echo "Headers 
not in /opt/R/${ARCH}/include/unicode/"
+          # Verify ucnv.h specifically exists
+          if [ -f "/opt/R/${ARCH}/include/unicode/ucnv.h" ]; then
+            echo "✓ Found ucnv.h at /opt/R/${ARCH}/include/unicode/ucnv.h"
+          else
+            echo "✗ ucnv.h NOT found - listing what we have:"
+            find /opt/R/${ARCH} -name "*.h" -path "*unicode*" 2>/dev/null | 
head -20
+          fi
+
+      - name: "Get dependencies"
+        id: deps
+        uses: r-universe-org/actions/macos-deps@v11
+        timeout-minutes: 60
+        env:
+          GITHUB_PAT: {{ "${{ secrets.GITHUB_TOKEN }}" }}
+        with:
+          sourcepkg: {{ "${{ needs.r-universe-source.outputs.sourcepkg }}" }}
+
+      - name: Patch r-universe check.Renviron to build from source
+        run: |
+          # Build Arrow C++ from source instead of downloading binaries
+          # Find the check.Renviron file in the downloaded actions
+          RENVIRON_FILE=$(find /Users/runner/work -name "check.Renviron" -path 
"*r-universe-org*" 2>/dev/null | head -1)
+          echo "Found check.Renviron at: $RENVIRON_FILE"
+          sed -i '' 's/LIBARROW_BINARY=true/LIBARROW_BINARY=false/g' 
"$RENVIRON_FILE"
+          # Add ICU_ROOT to cmake flags so Boost finds our ICU instead of 
Xcode's incomplete SDK ICU
+          ARCH=$(uname -m)
+          echo "EXTRA_CMAKE_FLAGS=-DICU_ROOT=/opt/R/${ARCH}" >> 
"$RENVIRON_FILE"

Review Comment:
   This is necessary to get over boost not finding `unicode/ucnv.h`



-- 
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