removed external dependenciesin build_r.R (fixes #2122) (#2123)

This commit is contained in:
James Lamb 2019-05-08 03:57:01 -05:00 коммит произвёл Laurae
Родитель 94fbe5bb9f
Коммит 1c27a15e42
1 изменённых файлов: 13 добавлений и 10 удалений

Просмотреть файл

@ -5,10 +5,6 @@
# Sys.setenv("CXX" = "/usr/local/bin/g++-8")
# Sys.setenv("CC" = "/usr/local/bin/gcc-8")
library(testthat)
library(roxygen2)
library(devtools)
# R returns FALSE (not a non-zero exit code) if a file copy operation
# breaks. Let's fix that
.handle_result <- function(res) {
@ -17,6 +13,15 @@ library(devtools)
}
}
# system() will not raise an R exception if the process called
# fails. Wrapping it here to get that behavior
.run_shell_command <- function(cmd, ...){
exit_code <- system(cmd, ...)
if (exit_code != 0){
stop(paste0("Command failed with exit code: ", exit_code))
}
}
# Make a new temporary folder to work in
unlink(x = "lightgbm_r", recursive = TRUE)
dir.create("lightgbm_r")
@ -51,15 +56,12 @@ result <- file.copy(from = "CMakeLists.txt",
overwrite = TRUE)
.handle_result(result)
# rebuild documentation
# devtools::document(pkg = "lightgbm_r")
# Build the package
# NOTE: --keep-empty-dirs is necessary to keep the deep paths expected
# by CMake while also meeting the CRAN req to create object files
# on demand
devtools::build(pkg = "lightgbm_r",
args = c("--keep-empty-dirs"))
cmd <- "R CMD build lightgbm_r --keep_empty-dirs"
.run_shell_command(cmd)
# Install the package
version <- gsub(
@ -73,7 +75,8 @@ version <- gsub(
)
tarball <- file.path(getwd(), sprintf("lightgbm_%s.tar.gz", version))
system(sprintf("R CMD INSTALL %s --no-multiarch", tarball))
cmd <- sprintf("R CMD INSTALL %s --no-multiarch", tarball)
.run_shell_command(cmd)
# Run R CMD CHECK
# R CMD CHECK lightgbm_2.1.2.tar.gz --as-cran | tee check.log | cat