nealrichardson commented on code in PR #35147:
URL: https://github.com/apache/arrow/pull/35147#discussion_r1181982269
##########
r/configure:
##########
@@ -58,191 +100,282 @@ if [ ! "`${R_HOME}/bin/R CMD config CXX17`" ]; then
exit 1
fi
-if [ -f "tools/apache-arrow.rb" ]; then
- # If you want to use a local apache-arrow.rb formula, do
- # $ cp ../dev/tasks/homebrew-formulae/autobrew/apache-arrow.rb
tools/apache-arrow.rb
- # before R CMD build or INSTALL (assuming a local checkout of the
apache/arrow repository)
- cp tools/autobrew .
- if [ "$FORCE_AUTOBREW" != "false" ]; then
- # It is possible to turn off forced autobrew if the formula is included,
- # but most likely you shouldn't because the included formula will reference
- # the C++ library at the version that matches the R package.
- FORCE_AUTOBREW="true"
- fi
+# Test if pkg-config is available to use
+if ${PKG_CONFIG} --version >/dev/null 2>&1; then
+ PKG_CONFIG_AVAILABLE="true"
+else
+ PKG_CONFIG_AVAILABLE="false"
+ ARROW_USE_PKG_CONFIG="false"
fi
-if [ "$FORCE_AUTOBREW" = "true" ] || [ "$FORCE_BUNDLED_BUILD" = "true" ]; then
- ARROW_USE_PKG_CONFIG="false"
+# find openssl on macos. macOS ships with libressl. openssl is installable
+# with brew, but it is generally not linked. We can over-ride this and find
+# openssl but setting OPENSSL_ROOT_DIR (which cmake will pick up later in
+# the installation process). FWIW, arrow's cmake process uses this
+# same process to find openssl, but doing it now allows us to catch it in
+# nixlibs.R and throw a nicer error.
+if [ "$UNAME" = "Darwin" ] && [ "${OPENSSL_ROOT_DIR}" = "" ] && [ "`command -v
brew`" ]; then
+ if brew --prefix openssl >/dev/null 2>&1; then
+ export OPENSSL_ROOT_DIR="`brew --prefix openssl`"
+ export
PKG_CONFIG_PATH="${OPENSSL_ROOT_DIR}/lib/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}}"
+ fi
fi
-S3_LIBS=""
-GCS_LIBS=""
-# Note that cflags may be empty in case of success
-if [ "$ARROW_HOME" ] && [ "$FORCE_BUNDLED_BUILD" != "true" ]; then
- echo "*** Using ARROW_HOME as the source of libarrow"
- PKG_CFLAGS="-I$ARROW_HOME/include $PKG_CFLAGS"
- PKG_LIBS="-larrow"
- LIB_DIR="$ARROW_HOME/lib"
- PKG_DIRS="-L$LIB_DIR"
-elif [ "$INCLUDE_DIR" ] && [ "$LIB_DIR" ]; then
- echo "*** Using INCLUDE_DIR/LIB_DIR as the source of libarrow"
- PKG_CFLAGS="-I$INCLUDE_DIR $PKG_CFLAGS"
- PKG_LIBS="-larrow"
- PKG_DIRS="-L$LIB_DIR"
-else
- # Use pkg-config to find libarrow if available and allowed
- pkg-config --version >/dev/null 2>&1
- if [ $? -eq 0 ]; then
- PKG_CONFIG_AVAILABLE=true
+#############
+# Functions #
+#############
+
+# This function looks in a few places for libarrow on the system already.
+# If the found library version is not compatible with the R package,
+# it won't be used.
+find_arrow () {
+ # Preserve original PKG_CONFIG_PATH. We'll add ${LIB_DIR}/pkgconfig to it if
needed
+ OLD_PKG_CONFIG_PATH="${PKG_CONFIG_PATH}"
+
+ if [ "$ARROW_HOME" ] && [ -d "$ARROW_HOME" ]; then
+ # 1. ARROW_HOME is a directory you've built and installed libarrow into.
+ # If the env var is set, we use it
+ _LIBARROW_FOUND="${ARROW_HOME}"
+ echo "*** Trying Arrow C++ in ARROW_HOME: $_LIBARROW_FOUND"
+ export
PKG_CONFIG_PATH="${_LIBARROW_FOUND}/lib/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}}"
+ elif [ "$ARROW_USE_PKG_CONFIG" != "false" ] && ${PKG_CONFIG}
${PKG_CONFIG_NAME}; then
+ # 2. Use pkg-config to find arrow on the system
+ _LIBARROW_FOUND="`${PKG_CONFIG} --variable=prefix --silence-errors
${PKG_CONFIG_NAME}`"
+ echo "*** Trying Arrow C++ found by pkg-config: $_LIBARROW_FOUND"
+ elif brew --prefix ${PKG_BREW_NAME} > /dev/null 2>&1; then
+ # 3. On macOS, look for Homebrew apache-arrow
+ # (note that if you have pkg-config, homebrew arrow may have already
been found)
+ _LIBARROW_FOUND=`brew --prefix ${PKG_BREW_NAME}`
+ echo "*** Trying Arrow C++ found by Homebrew: ${_LIBARROW_FOUND}"
+ export
PKG_CONFIG_PATH="${_LIBARROW_FOUND}/lib/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}}"
else
- PKG_CONFIG_AVAILABLE=false
- fi
- if [ "$PKG_CONFIG_AVAILABLE" = "true" ] && [ "$ARROW_USE_PKG_CONFIG" !=
"false" ]; then
- # Set the search paths and compile flags
- PKGCONFIG_CFLAGS=`pkg-config --cflags --silence-errors ${PKG_CONFIG_NAME}`
- PKGCONFIG_LIBS=`pkg-config --libs-only-l --libs-only-other
--silence-errors ${PKG_CONFIG_NAME}`
- PKGCONFIG_DIRS=`pkg-config --libs-only-L --silence-errors
${PKG_CONFIG_NAME}`
+ _LIBARROW_FOUND="false"
Review Comment:
If you get here, the next message you'll see is something about building
libarrow, either with autobrew or something that says which directory the C++
source has been found in. I think it will be clear enough where we are in the
flow, but I don't feel strongly about it.
--
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]