You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by we...@apache.org on 2019/06/22 00:34:51 UTC

[arrow] branch master updated: ARROW-3758: [R] Build R library and dependencies on Windows in Appveyor CI

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 1d588ab  ARROW-3758: [R] Build R library and dependencies on Windows in Appveyor CI
1d588ab is described below

commit 1d588ab35241792f2e702e90ba331e9dc659354a
Author: Neal Richardson <ne...@gmail.com>
AuthorDate: Fri Jun 21 19:34:43 2019 -0500

    ARROW-3758: [R] Build R library and dependencies on Windows in Appveyor CI
    
    After much trial and error, I have successfully built the C++ library using the R toolchain on our Appveyor, and then used that in installing and checking the R package. Here is a passing build: https://ci.appveyor.com/project/nealrichardson/arrow/builds/25406324
    
    Importantly, this patch puts the Windows Rtools/mingw pkgbuild script under our source control and continuous integration, as well as the additional complex procedure for assembling the "rwinlib" build described [on the wiki](https://cwiki.apache.org/confluence/display/ARROW/Release+Management+Guide#ReleaseManagementGuide-UpdatingRpackages). In the process, this patch also updates the `r/configure.win` script to work with the latest version of Arrow and it addresses some test failures [...]
    
    One side effect of this CI setup is that the binary build artifacts (e.g. https://ci.appveyor.com/api/buildjobs/rkp1pu42dr2d5yev/artifacts/build%2Farrow-0.13.0.9000.zip) are now available for download and use on every commit. It is a small step from here to publishing those dev artifacts on each commit (as Jeroen's rtools-packages/backports repos to) or doing so nightly. This would enable R users/developers on Windows to install the development version of `arrow` without requiring the [...]
    
    Items resolved since the initial PR:
    
    - [x] Need to work out the right Windows incantations to find and pass in the path to the built C++ library to the R build script. The way I'm doing it now isn't totally kosher, but it's good enough for CI purposes and wouldn't affect the CRAN procedure. This is possibly deferable.
    - [x] Cleanup: need to uncomment the other appveyor jobs, obviously
    - [x] Add Windows dev installation instructions to the R README, currently nonexistent. (Doing on https://issues.apache.org/jira/browse/ARROW-5555)
    - [x] I need to confirm (with Jeroen) that it's ok to put the Apache license on the PKGBUILD script (copied with some modifications from [rtools-backports](https://github.com/r-windows/rtools-backports/blob/master/mingw-w64-arrow/PKGBUILD)) and appveyor-build-r.sh, which [is inspired by rtools-backports](https://github.com/r-windows/rtools-backports/blob/master/ci-build.sh) too. Seems uncontroversial to me but IANAL.
    
    Followup items:
    
    * The C++ library was built without Snappy support, which means that Parquet support will be limited in practice. I had to skip the one test that used a fixture .parquet file (which happened to use snappy compression). https://issues.apache.org/jira/browse/ARROW-5683 to address that.
    * I'd like to review this with Jeroen, the RTools maintainer. This works in the Appveyor job, and I've installed the R package on my local VM using the build that the Appveyor job creates, but there are a lot of subtleties in the R Windows toolchain and I am not confident that I've gotten them all right. https://issues.apache.org/jira/browse/ARROW-5686
    
    Author: Neal Richardson <ne...@gmail.com>
    
    Closes #4622 from nealrichardson/r-appveyor-part2 and squashes the following commits:
    
    294a9797f <Neal Richardson> Review feedback
    9009969d9 <Neal Richardson> Merge remote-tracking branch 'upstream/master' into r-appveyor-part2
    234dc93fb <Neal Richardson> Merge remote-tracking branch 'upstream/master' into r-appveyor-part2
    c39d7e9c7 <Neal Richardson> Some cleanup
    9f560f1d2 <Neal Richardson> Try absolute path; add more debug messages
    f5f6da2f9 <Neal Richardson> Try this to pass in the local rwinlib
    14520fdfc <Neal Richardson> Read version from DESCRIPTION in build script; look elsewhere to set env var
    51a6069b1 <Neal Richardson> Merge upstream/master
    976bdb291 <Neal Richardson> Skip tests that fail on windows. Attempt to pass in local built rwinlib via env var
    cce770092 <Neal Richardson> Oops
    1ba73c2c4 <Neal Richardson> Fix wonky URLs
    b302acfa3 <Neal Richardson> Fix path, store .zip artifact
    e4e127bff <Neal Richardson> Assemble built libraries for rwinlib. Adjust configure.win flags. Temporary hack to test out the R package with the built libs
    21304b9c5 <Neal Richardson> quote
    c7cdfd580 <Neal Richardson> Try to collect the built packages as artifacts
    46cf050a5 <Neal Richardson> Try installing Antoine's patch
    a2800109c <Neal Richardson> Now that that passes, update PKGBUILD to build from master
    9c44946c4 <Neal Richardson> Reset PKGBUILD to backports version
    994c394cf <Neal Richardson> this is the dir
    3f0d2441e <Neal Richardson> prints
    46181a0fd <Neal Richardson> more sigh
    27aaf7fef <Neal Richardson> try to find dir again
    5de658bdf <Neal Richardson> Sigh
    72372a658 <Neal Richardson> See if building 0.13 works
    541d4555b <Neal Richardson> ?
    c2eacc759 <Neal Richardson> ''
    ed554f487 <Neal Richardson> Try adding PATH
    983345023 <Neal Richardson> Recomment these
    ca826c34e <Neal Richardson> Try pacman.conf
    d86c66cdd <Neal Richardson> Merge upstream/master
    306661463 <Neal Richardson> Path to cpp
    f33a094ff <Neal Richardson> fix dir
    cc3d9a4df <Neal Richardson> echo
    d89edfea3 <Neal Richardson> Touch to trigger build
    50dbbec19 <Neal Richardson> Debug PKGBUILD
    5a10965c2 <Neal Richardson> More verbosity
    7ab79fa93 <Neal Richardson> This was important
    0d3ffeddd <Neal Richardson> Slightly larger cargo
    4755f8797 <Neal Richardson> Try this in a bash script
    dad5f2d7c <Neal Richardson> More paths'
    e621b3455 <Neal Richardson> Add paths
    5837c243c <Neal Richardson> this is redundant
    29ea6af63 <Neal Richardson> Install more stuff
    6add01f79 <Neal Richardson> Let's see how badly this fails
    6d6a74e31 <Neal Richardson> PR feedback
    84eef1b2d <Neal Richardson> Merge upstream/master
    328bc376f <Neal Richardson> Merge remote-tracking branch 'upstream/master' into r-appveyor
    53c3a2084 <Neal Richardson> Makevars.win is dynamically generated now, no need to tweak it in the release script
    567f04142 <Neal Richardson> Cleanups
    f4cf5c3dd <Neal Richardson> Some appveyor.yml cleanup
    19b60df07 <Neal Richardson> Enable R package to install on windows even if rwinlib isn't found
    fb199110a <Neal Richardson> Try this name hack
    15c0342d1 <Neal Richardson> Try building first, see where that goes
    18803c353 <Neal Richardson> cd this way
    b6f6c8de7 <Neal Richardson> No popd?
    1ba4839e2 <Neal Richardson> let the debugging begin
    d5e8f4ed4 <Neal Richardson> Bootstrap within the package dir
    f7327ed23 <Neal Richardson> Find shell script up a level
    8c3e898f8 <Neal Richardson> nm we already fast finish
    39236f3f7 <Neal Richardson> Put mine first and fast-finish
    94c9a42df <Neal Richardson> Debug with fewer jobs in the matrix
    af1852e79 <Neal Richardson> Throw this at appveyor and see how far off we are
---
 appveyor.yml                    |  18 +++++--
 ci/PKGBUILD                     | 114 ++++++++++++++++++++++++++++++++++++++++
 ci/appveyor-build-r.sh          |  47 +++++++++++++++++
 ci/windows-pkg-arrow-for-r.sh   |  65 +++++++++++++++++++++++
 r/.gitignore                    |   1 +
 r/configure.win                 |   7 +--
 r/tests/testthat/test-json.R    |  12 ++---
 r/tests/testthat/test-parquet.R |   1 +
 r/tools/winlibs.R               |  19 +++++--
 9 files changed, 265 insertions(+), 19 deletions(-)

diff --git a/appveyor.yml b/appveyor.yml
index a4995a8..c5eadf6 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -103,8 +103,10 @@ environment:
       GO111MODULE: on
       GOTOOLDIR: '%GOROOT%\pkg\tool\windows_amd64'
       PATH: '%GOPATH%\bin;%GOROOT%\bin;%PATH%'
-    - JOB: "R without libarrow"
+    - JOB: "R with libarrow"
       USE_CLCACHE: false
+      TEST_R_WITH_ARROW: "TRUE"
+      RWINLIB_LOCAL: '%APPVEYOR_BUILD_FOLDER%\libarrow.zip'
 
   MSVC_DEFAULT_OPTIONS: ON
   APPVEYOR_SAVE_CACHE_ON_ERROR: true
@@ -126,7 +128,7 @@ for:
 -
   matrix:
     only:
-      - JOB: "R without libarrow"
+      - JOB: "R with libarrow"
   init:
     ps: |
           $ErrorActionPreference = "Stop"
@@ -139,9 +141,9 @@ for:
     - cd %APPVEYOR_BUILD_FOLDER%
 
   build_script:
-    # TODO: for the version of the R tests that builds, probably can't use this
-    # ci script because we need to build with the Rtools toolchain
-    # - call ci\appveyor-build.bat
+    - rmdir /s /Q C:\OpenSSL-Win32 C:\OpenSSL-Win64
+    - C:\msys64\usr\bin\pacman --noconfirm --ask 20 --sync --refresh --refresh --sysupgrade --sysupgrade
+    - C:\msys64\usr\bin\bash --login -c "$(cygpath ${APPVEYOR_BUILD_FOLDER})/ci/appveyor-build-r.sh"
     - pushd r
     - travis-tool.sh install_deps
 
@@ -155,6 +157,12 @@ for:
     NOT_CRAN: true
 
   artifacts:
+    - path: '*.pkg.tar.xz'
+      name: binaries
+
+    - path: 'build\*.zip'
+      name: binaries
+
     - path: 'r\*.Rcheck\**\*.log'
       name: Logs
 
diff --git a/ci/PKGBUILD b/ci/PKGBUILD
new file mode 100644
index 0000000..b760838
--- /dev/null
+++ b/ci/PKGBUILD
@@ -0,0 +1,114 @@
+# 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.
+
+_realname=arrow
+pkgbase=mingw-w64-${_realname}
+pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
+pkgver=0.13.0.9000
+pkgrel=8000
+pkgdesc="Apache Arrow is a cross-language development platform for in-memory data (mingw-w64)"
+arch=("any")
+url="https://arrow.apache.org/"
+license=("Apache-2.0")
+depends=("${MINGW_PACKAGE_PREFIX}-boost"
+         "${MINGW_PACKAGE_PREFIX}-double-conversion"
+         "${MINGW_PACKAGE_PREFIX}-thrift"
+         "${MINGW_PACKAGE_PREFIX}-zlib")
+makedepends=("${MINGW_PACKAGE_PREFIX}-cmake"
+             "${MINGW_PACKAGE_PREFIX}-gcc")
+options=("staticlibs" "strip" "!buildflags")
+source_dir=apache-${_realname}-${pkgver}
+source=("${source_dir}"::"git+https://github.com/apache/arrow")
+sha256sums=("SKIP")
+
+cmake_build_type=release
+cpp_build_dir=build-${CARCH}-cpp
+
+pkgver() {
+  cd "$source_dir"
+  grep Version r/DESCRIPTION | cut -d " " -f 2
+}
+
+prepare() {
+  pushd ${source_dir}
+  #patch -p1 -N -i ${srcdir}/3923.patch
+  popd
+}
+
+build() {
+  ARROW_CPP_DIR="$(pwd)/${source_dir}/cpp"
+  [[ -d ${cpp_build_dir} ]] && rm -rf ${cpp_build_dir}
+  mkdir -p ${cpp_build_dir}
+  pushd ${cpp_build_dir}
+
+  # Workaround to fix static libparquet
+  export CXXFLAGS="-DARROW_STATIC"
+
+  export CC="/C/Rtools${MINGW_PREFIX/mingw/mingw_}/bin/gcc"
+  export CXX="/C/Rtools${MINGW_PREFIX/mingw/mingw_}/bin/g++"
+  export PATH="/C/Rtools${MINGW_PREFIX/mingw/mingw_}/bin:$PATH"
+  export CPPFLAGS="-I${MINGW_PREFIX}/include"
+  export LIBS="-L${MINGW_PREFIX}/libs"
+
+  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
+    ${MINGW_PREFIX}/bin/cmake.exe \
+    ${ARROW_CPP_DIR} \
+    -G "MSYS Makefiles" \
+    -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
+    -DCMAKE_BUILD_TYPE=${cmake_build_type} \
+    -DARROW_BUILD_STATIC=ON \
+    -DARROW_BUILD_SHARED=OFF \
+    -DARROW_BUILD_TESTS=OFF \
+    -DARROW_PARQUET=ON \
+    -DARROW_PLASMA=OFF \
+    -DARROW_HDFS=OFF \
+    -DARROW_PYTHON=OFF \
+    -DARROW_BOOST_USE_SHARED=OFF \
+    -DARROW_WITH_SNAPPY=OFF \
+    -DARROW_WITH_ZSTD=OFF \
+    -DARROW_WITH_LZ4=OFF \
+    -DARROW_JEMALLOC=OFF \
+    -DARROW_WITH_ZLIB=ON \
+    -DARROW_WITH_BROTLI=OFF \
+    -DARROW_USE_GLOG=OFF \
+    -DARROW_BUILD_UTILITIES=ON \
+    -DARROW_TEST_LINKAGE="static" \
+    -Ddouble-conversion_ROOT="${MINGW_PREFIX}" \
+    -DThrift_ROOT="${MINGW_PREFIX}"
+
+  sed -i 's/-fPIC/ /g' flatbuffers_ep-prefix/src/flatbuffers_ep-stamp/flatbuffers_ep-configure-RELEASE.cmake
+
+  make
+  popd
+}
+
+check() {
+  # TODO
+  # make -C ${cpp_build_dir} test
+  :
+}
+
+package() {
+  make -C ${cpp_build_dir} DESTDIR="${pkgdir}" install
+
+  local PREFIX_DEPS=$(cygpath -am ${MINGW_PREFIX})
+  pushd "${pkgdir}${MINGW_PREFIX}/lib/pkgconfig"
+  for pc in *.pc; do
+    sed -s "s|${PREFIX_DEPS}|${MINGW_PREFIX}|g" -i $pc
+  done
+  popd
+}
diff --git a/ci/appveyor-build-r.sh b/ci/appveyor-build-r.sh
new file mode 100644
index 0000000..85e532e
--- /dev/null
+++ b/ci/appveyor-build-r.sh
@@ -0,0 +1,47 @@
+#!/bin/bash
+
+# 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.
+
+set -x
+
+pacman --noconfirm -Rcsu mingw-w64-{i686,x86_64}-toolchain gcc pkg-config
+
+wget https://raw.githubusercontent.com/r-windows/rtools-backports/master/pacman.conf
+cp -f pacman.conf /etc/pacman.conf
+
+pacman --noconfirm -Scc
+pacman --noconfirm -Syyu
+pacman --noconfirm --needed -S git base-devel binutils
+
+# Install core build stuff
+pacman --noconfirm --needed -S mingw-w64-{i686,x86_64}-{crt,winpthreads,gcc,libtre,pkg-config,xz}
+
+# Force static linking
+rm -f /mingw32/lib/*.dll.a
+rm -f /mingw64/lib/*.dll.a
+export PKG_CONFIG="/${MINGW_INSTALLS}/bin/pkg-config --static"
+
+cd $APPVEYOR_BUILD_FOLDER
+cp ci/PKGBUILD .
+makepkg-mingw --noconfirm --noprogressbar --skippgpcheck --nocheck --syncdeps --rmdeps --cleanbuild
+
+# Collect the build artifacts and make the shape of zip file that rwinlib expects
+mkdir build
+cp *.xz build
+cd build
+source ../ci/windows-pkg-arrow-for-r.sh
diff --git a/ci/windows-pkg-arrow-for-r.sh b/ci/windows-pkg-arrow-for-r.sh
new file mode 100644
index 0000000..fdcf712
--- /dev/null
+++ b/ci/windows-pkg-arrow-for-r.sh
@@ -0,0 +1,65 @@
+#!/bin/bash
+
+# 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.
+
+set -eu
+
+VERSION=$(grep Version ../r/DESCRIPTION | cut -d " " -f 2)
+DST_DIR="arrow-$VERSION"
+
+# Untar the two builds we made
+ls | xargs -n 1 tar -xJf
+mkdir $DST_DIR
+# Grab the headers from one, either one is fine
+mv mingw64/include $DST_DIR
+
+# Move the 64-bit versions into the expected location
+mkdir -p $DST_DIR/lib-4.9.3/x64
+mv mingw64/lib/*.a $DST_DIR/lib-4.9.3/x64
+# Same for the 32-bit versions
+mkdir -p $DST_DIR/lib-4.9.3/i686
+mv mingw32/lib/*.a $DST_DIR/lib-4.9.3/i686
+
+mkdir deps && cd deps
+# Get these from "backports" so they were compiled with gcc 4.9
+wget https://dl.bintray.com/rtools/backports/mingw-w64-i686-boost-1.67.0-8000-any.pkg.tar.xz
+wget https://dl.bintray.com/rtools/backports/mingw-w64-x86_64-boost-1.67.0-8000-any.pkg.tar.xz
+# wget https://dl.bintray.com/rtools/mingw32/mingw-w64-i686-boost-1.67.0-9002-any.pkg.tar.xz
+# wget https://dl.bintray.com/rtools/mingw64/mingw-w64-x86_64-boost-1.67.0-9002-any.pkg.tar.xz
+wget https://dl.bintray.com/rtools/backports/mingw-w64-i686-thrift-0.12.0-8000-any.pkg.tar.xz
+wget https://dl.bintray.com/rtools/backports/mingw-w64-x86_64-thrift-0.12.0-8000-any.pkg.tar.xz
+# wget https://dl.bintray.com/rtools/mingw32/mingw-w64-i686-thrift-0.12.0-1-any.pkg.tar.xz
+# wget https://dl.bintray.com/rtools/mingw64/mingw-w64-x86_64-thrift-0.12.0-1-any.pkg.tar.xz
+
+# double-conversion is only available in the Rtools4.0 builds, but apparently that's ok
+wget https://dl.bintray.com/rtools/mingw64/mingw-w64-x86_64-double-conversion-3.1.2-1-any.pkg.tar.xz
+wget https://dl.bintray.com/rtools/mingw32/mingw-w64-i686-double-conversion-3.1.2-1-any.pkg.tar.xz
+ls | xargs -n 1 tar -xJf
+cd ..
+
+mkdir -p $DST_DIR/lib/x64
+mkdir -p $DST_DIR/lib/i686
+mv deps/mingw64/lib/*.a $DST_DIR/lib/x64
+mv deps/mingw32/lib/*.a $DST_DIR/lib/i686
+
+# Create build artifact
+zip -r ${DST_DIR}.zip $DST_DIR
+
+# Copy that to a file name/path that does not vary by version number so we
+# can easily find it in the R package tests on Appveyor
+cp ${DST_DIR}.zip ../libarrow.zip
diff --git a/r/.gitignore b/r/.gitignore
index 0a6fbd9..07c69f8 100644
--- a/r/.gitignore
+++ b/r/.gitignore
@@ -10,5 +10,6 @@ inst/doc
 .Rproj.user
 .Rhistory
 src/Makevars
+src/Makevars.win
 windows/
 arrow_*.tar.gz
diff --git a/r/configure.win b/r/configure.win
index 75702e6..b7b08a4 100644
--- a/r/configure.win
+++ b/r/configure.win
@@ -25,8 +25,9 @@ if [ "$ARROW_R_DEV" == "TRUE" ]; then
 fi
 
 VERSION=$(grep ^Version DESCRIPTION | sed s/Version:\ //)
-# Try to find/download a C++ Arrow binary
-"${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" "tools/winlibs.R" $VERSION
+# Try to find/download a C++ Arrow binary,
+# including possibly a local .zip file if RWINLIB_LOCAL is set
+"${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" "tools/winlibs.R" $VERSION $RWINLIB_LOCAL
 # If binary not found, script exits nonzero
 if [ $? -ne 0 ]; then
   # We'll have to install without libarrow. Note to the user how to rectify.
@@ -38,7 +39,7 @@ else
   # Set the right flags to point to and enable arrow/parquet
   RWINLIB="../windows/arrow-${VERSION}"
   PKG_CFLAGS="-I${RWINLIB}/include -DARROW_STATIC -DPARQUET_STATIC -DARROW_R_WITH_PARQUET -DARROW_R_WITH_ARROW"
-  PKG_LIBS="-L${RWINLIB}/lib"'$(subst gcc,,$(COMPILED_BY))$(R_ARCH) '"-L${RWINLIB}/lib"'$(R_ARCH) '"-lparquet -larrow -lthrift -lboost_regex-mt-s -ldouble-conversion -lz -lws2_32"
+  PKG_LIBS="-L${RWINLIB}/lib"'$(subst gcc,,$(COMPILED_BY))$(R_ARCH) '"-L${RWINLIB}/lib"'$(R_ARCH) '"-lparquet -larrow -lthrift -lboost_regex-mt-s -lboost_filesystem-mt-s -lboost_system-mt-s -ldouble-conversion -lz -lws2_32"
 fi
 
 echo "*** Writing Makevars.win"
diff --git a/r/tests/testthat/test-json.R b/r/tests/testthat/test-json.R
index 45daf33..26d79ca 100644
--- a/r/tests/testthat/test-json.R
+++ b/r/tests/testthat/test-json.R
@@ -19,6 +19,7 @@ context("arrow::json::TableReader")
 
 test_that("Can read json file with scalars columns (ARROW-5503)", {
   tf <- tempfile()
+  on.exit(unlink(tf))
   writeLines('
     { "hello": 3.5, "world": false, "yo": "thing" }
     { "hello": 3.25, "world": null }
@@ -40,13 +41,13 @@ test_that("Can read json file with scalars columns (ARROW-5503)", {
   tib <- as.data.frame(tab1)
   expect_equal(tib$hello, c(3.5, 3.25, 3.125, 0))
   expect_equal(tib$world, c(FALSE, NA, NA, TRUE))
+  skip_on_os("windows") # TODO: debug UTF-8 test
   expect_equal(tib$yo, c("thing", NA, "\u5fcd", NA))
-
-  unlink(tf)
 })
 
 test_that("read_json_arrow() converts to tibble", {
   tf <- tempfile()
+  on.exit(unlink(tf))
   writeLines('
     { "hello": 3.5, "world": false, "yo": "thing" }
     { "hello": 3.25, "world": null }
@@ -67,13 +68,13 @@ test_that("read_json_arrow() converts to tibble", {
 
   expect_equal(tab1$hello, c(3.5, 3.25, 3.125, 0))
   expect_equal(tab1$world, c(FALSE, NA, NA, TRUE))
+  skip_on_os("windows") # TODO: debug UTF-8 test
   expect_equal(tab1$yo, c("thing", NA, "\u5fcd", NA))
-
-  unlink(tf)
 })
 
 test_that("Can read json file with nested columns (ARROW-5503)", {
   tf <- tempfile()
+  on.exit(unlink(tf))
   writeLines('
     { "arr": [1.0, 2.0, 3.0], "nuf": {} }
     { "arr": [2.0], "nuf": null }
@@ -131,7 +132,4 @@ test_that("Can read json file with nested columns (ARROW-5503)", {
       nuf = data.frame(ps = ps$as_vector(), hello = hello$as_vector(), stringsAsFactors = FALSE)
     )
   )
-
-  unlink(tf)
 })
-
diff --git a/r/tests/testthat/test-parquet.R b/r/tests/testthat/test-parquet.R
index 554744e..64b2109 100644
--- a/r/tests/testthat/test-parquet.R
+++ b/r/tests/testthat/test-parquet.R
@@ -20,6 +20,7 @@ context("Parquet file reading/writing")
 pq_file <- system.file("v0.7.1.parquet", package="arrow")
 
 test_that("reading a known Parquet file to tibble", {
+  skip_on_os("windows") # TODO: enable snappy in windows build
   df <- read_parquet(pq_file)
   expect_true(tibble::is_tibble(df))
   expect_identical(dim(df), c(10L, 11L))
diff --git a/r/tools/winlibs.R b/r/tools/winlibs.R
index 4f6b4fa..b54e63c 100644
--- a/r/tools/winlibs.R
+++ b/r/tools/winlibs.R
@@ -15,11 +15,22 @@
 # specific language governing permissions and limitations
 # under the License.
 
-# Download static arrow from rwinlib
-VERSION <- commandArgs(TRUE)
+args <- commandArgs(TRUE)
+VERSION <- args[1]
 if(!file.exists(sprintf("windows/arrow-%s/include/arrow/api.h", VERSION))){
-  if(getRversion() < "3.3.0") setInternet2()
-  download.file(sprintf("https://github.com/rwinlib/arrow/archive/v%s.zip", VERSION), "lib.zip", quiet = TRUE)
+  if(length(args) > 1){
+    # Arg 2 would be the path/to/lib.zip
+    localfile <- args[2]
+    cat(sprintf("*** Using RWINLIB_LOCAL %s\n", localfile))
+    if(!file.exists(localfile)){
+      cat(sprintf("*** %s does not exist; build will fail\n", localfile))
+    }
+    file.copy(localfile, "lib.zip")
+  } else {
+    # Download static arrow from rwinlib
+    if(getRversion() < "3.3.0") setInternet2()
+    download.file(sprintf("https://github.com/rwinlib/arrow/archive/v%s.zip", VERSION), "lib.zip", quiet = TRUE)
+  }
   dir.create("windows", showWarnings = FALSE)
   unzip("lib.zip", exdir = "windows")
   unlink("lib.zip")