Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion r/R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@
# specific language governing permissions and limitations
# under the License.

#' @useDynLib arrow, .registration = TRUE
#' @importFrom Rcpp sourceCpp
NULL

NAMESPACE <- environment()

.onLoad <- function(libname, pkgname) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jimhester @jjallaire I'm doing this, inspired from what RcppParallel does, so that I could load the package library after e.g. the dependent Arrow and Parquet libraries, or perhaps gracefully fail at runtime when these are not available

but it seems that this does not play nicely with load_all() :

Is that a known thing ?

❯ devtools::load_all()
Loading arrow
Error in find.package(package, lib.loc, verbose = verbose) : 
  there is no package called ‘arrow’
❯ traceback()
7: stop(packageNotFoundError(bad, lib.loc, sys.call()))
6: find.package(package, lib.loc, verbose = verbose)
5: library.dynam("arrow", pkgname, libname) at zzz.R#24
4: nsenv[[f_name]](dirname(ns_path), package)
3: run_pkg_hook(package, "load")
2: pkgload::load_all(path = path, reset = reset, recompile = recompile, 
       export_all = export_all, helpers = helpers, quiet = quiet, 
       ...)
1: devtools::load_all()

devtools::document() fails too and leaves a dirty NAMESPACE

dll <- library.dynam("arrow", pkgname, libname)

for(routine in getDLLRegisteredRoutines(dll)$.Call) {
assign(routine$name, routine, envir = NAMESPACE)
}
}

.onUnload <- function(libpath) {
library.dynam.unload("arrow", libpath)
}
15 changes: 6 additions & 9 deletions r/configure
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,9 @@ fi
# Note that cflags may be empty in case of success
if [ "$INCLUDE_DIR" ] || [ "$LIB_DIR" ]; then
echo "Found INCLUDE_DIR and/or LIB_DIR!"
PKG_CFLAGS="-I$INCLUDE_DIR $PKG_CFLAGS"
PKG_LIBS="-L$LIB_DIR $PKG_LIBS"
elif [ "$PKGCONFIG_CFLAGS" ] || [ "$PKGCONFIG_LIBS" ]; then
echo "Found pkg-config cflags and libs!"
PKG_CFLAGS=${PKGCONFIG_CFLAGS}
PKG_LIBS=${PKGCONFIG_LIBS}
elif [[ "$OSTYPE" == "darwin"* ]]; then
if [ "$(command -v brew)" ]; then
Expand All @@ -56,22 +54,21 @@ elif [[ "$OSTYPE" == "darwin"* ]]; then
curl -sfL "https://jeroen.github.io/autobrew/$PKG_BREW_NAME" > autobrew
source autobrew
fi
PKG_CFLAGS="-I$BREWDIR/opt/$PKG_BREW_NAME/include"
PKG_LIBS="-L$BREWDIR/opt/$PKG_BREW_NAME/lib $PKG_LIBS"
fi

PKG_CFLAGS="$PKG_CFLAGS -DARROW_R_WITH_PARQUET"

# For debugging
echo "PKG_CFLAGS=$PKG_CFLAGS"
echo "PKG_LIBS=$PKG_LIBS"

# Find compiler
CXXCPP=$("${R_HOME}"/bin/R CMD config CXXCPP)
CXX11FLAGS=$("${R_HOME}"/bin/R CMD config CXX11FLAGS)
CXX11STD=$("${R_HOME}"/bin/R CMD config CXX11STD)
CPPFLAGS=$("${R_HOME}"/bin/R CMD config CPPFLAGS)

PKG_CFLAGS="-I../inst/include -DARROW_R_WITH_PARQUET"

# For debugging
echo "PKG_CFLAGS=$PKG_CFLAGS"
echo "PKG_LIBS=$PKG_LIBS"

# If libarrow uses the old GLIBCXX ABI, so we have to use it too
if [ "$ARROW_USE_OLD_CXXABI" ]; then
$PKG_CFLAGS="$PKG_CFLAGS -D_GLIBCXX_USE_CXX11_ABI=0"
Expand Down
21 changes: 21 additions & 0 deletions r/data-raw/arrow_headers.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
library(fs)
library(magrittr)
library(glue)

copy_headers <- function(dir) {
origin <- glue("../cpp/src/{dir}")
dest <- glue("r/inst/include/{dir}")

# copy all files
try(dir_delete(dest), silent = TRUE)
dir_copy(origin, dest)

# only keep headers
dir_ls(dest, glob = "*.h", invert = TRUE, all = TRUE, recurse = TRUE, type = "file") %>%
file_delete()

message(glue("{n} header files copied in `{dest}`", n = length(dir_ls(dest, recurse = TRUE))))
invisible()
}
copy_headers("arrow")
copy_headers("parquet")
5 changes: 4 additions & 1 deletion r/man/table.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.