2018-09-23 18:48:49 +03:00
|
|
|
# For macOS users who have decided to use gcc
|
2018-09-02 04:30:30 +03:00
|
|
|
# (replace 8 with version of gcc installed on your machine)
|
2018-08-29 07:31:42 +03:00
|
|
|
# NOTE: your gcc / g++ from Homebrew is probably in /usr/local/bin
|
|
|
|
#export CXX=/usr/local/bin/g++-8 CC=/usr/local/bin/gcc-8
|
|
|
|
# Sys.setenv("CXX" = "/usr/local/bin/g++-8")
|
|
|
|
# Sys.setenv("CC" = "/usr/local/bin/gcc-8")
|
|
|
|
|
2020-03-31 07:01:29 +03:00
|
|
|
args <- commandArgs(trailingOnly = TRUE)
|
|
|
|
INSTALL_AFTER_BUILD <- !("--skip-install" %in% args)
|
2020-05-25 05:23:38 +03:00
|
|
|
TEMP_R_DIR <- file.path(getwd(), "lightgbm_r")
|
|
|
|
TEMP_SOURCE_DIR <- file.path(TEMP_R_DIR, "src")
|
2020-03-31 07:01:29 +03:00
|
|
|
|
2021-01-19 05:08:20 +03:00
|
|
|
# [description]
|
|
|
|
# Parse the content of commandArgs() into a structured
|
|
|
|
# list. This returns a list with two sections.
|
|
|
|
# * "flags" = a character of vector of flags like "--use-gpu"
|
|
|
|
# * "keyword_args" = a named character vector, where names
|
|
|
|
# refer to options and values are the option values. For
|
|
|
|
# example, c("--boost-librarydir" = "/usr/lib/x86_64-linux-gnu")
|
|
|
|
.parse_args <- function(args) {
|
|
|
|
out_list <- list(
|
|
|
|
"flags" = character(0L)
|
|
|
|
, "keyword_args" = character(0L)
|
2021-11-10 04:39:59 +03:00
|
|
|
, "make_args" = character(0L)
|
2021-01-19 05:08:20 +03:00
|
|
|
)
|
|
|
|
for (arg in args) {
|
2022-06-16 18:17:22 +03:00
|
|
|
if (any(grepl("^\\-j[0-9]+", arg))) { # nolint: non_portable_path
|
2021-11-10 04:39:59 +03:00
|
|
|
out_list[["make_args"]] <- arg
|
2023-01-31 08:33:48 +03:00
|
|
|
} else if (any(grepl("=", arg, fixed = TRUE))) {
|
|
|
|
split_arg <- strsplit(arg, "=", fixed = TRUE)[[1L]]
|
2021-01-19 05:08:20 +03:00
|
|
|
arg_name <- split_arg[[1L]]
|
|
|
|
arg_value <- split_arg[[2L]]
|
|
|
|
out_list[["keyword_args"]][[arg_name]] <- arg_value
|
|
|
|
} else {
|
|
|
|
out_list[["flags"]] <- c(out_list[["flags"]], arg)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return(out_list)
|
|
|
|
}
|
|
|
|
parsed_args <- .parse_args(args)
|
|
|
|
|
2021-11-18 07:15:32 +03:00
|
|
|
SKIP_VIGNETTES <- "--no-build-vignettes" %in% parsed_args[["flags"]]
|
2021-01-19 05:08:20 +03:00
|
|
|
USING_GPU <- "--use-gpu" %in% parsed_args[["flags"]]
|
|
|
|
USING_MINGW <- "--use-mingw" %in% parsed_args[["flags"]]
|
|
|
|
USING_MSYS2 <- "--use-msys2" %in% parsed_args[["flags"]]
|
|
|
|
|
|
|
|
# this maps command-line arguments to defines passed into CMake,
|
|
|
|
ARGS_TO_DEFINES <- c(
|
|
|
|
"--boost-root" = "-DBOOST_ROOT"
|
|
|
|
, "--boost-dir" = "-DBoost_DIR"
|
|
|
|
, "--boost-include-dir" = "-DBoost_INCLUDE_DIR"
|
|
|
|
, "--boost-librarydir" = "-DBOOST_LIBRARYDIR"
|
|
|
|
, "--opencl-include-dir" = "-DOpenCL_INCLUDE_DIR"
|
|
|
|
, "--opencl-library" = "-DOpenCL_LIBRARY"
|
|
|
|
)
|
2020-11-29 18:29:20 +03:00
|
|
|
|
|
|
|
recognized_args <- c(
|
2021-11-18 07:15:32 +03:00
|
|
|
"--no-build-vignettes"
|
|
|
|
, "--skip-install"
|
2020-11-29 18:29:20 +03:00
|
|
|
, "--use-gpu"
|
|
|
|
, "--use-mingw"
|
|
|
|
, "--use-msys2"
|
2021-01-19 05:08:20 +03:00
|
|
|
, names(ARGS_TO_DEFINES)
|
2020-11-29 18:29:20 +03:00
|
|
|
)
|
2021-01-19 05:08:20 +03:00
|
|
|
given_args <- c(
|
|
|
|
parsed_args[["flags"]]
|
|
|
|
, names(parsed_args[["keyword_args"]])
|
|
|
|
)
|
|
|
|
unrecognized_args <- setdiff(given_args, recognized_args)
|
2020-11-29 18:29:20 +03:00
|
|
|
if (length(unrecognized_args) > 0L) {
|
|
|
|
msg <- paste0(
|
|
|
|
"Unrecognized arguments: "
|
2022-06-23 00:46:48 +03:00
|
|
|
, toString(unrecognized_args)
|
2020-11-29 18:29:20 +03:00
|
|
|
)
|
|
|
|
stop(msg)
|
|
|
|
}
|
|
|
|
|
|
|
|
# [description] Replace statements in install.libs.R code based on
|
|
|
|
# command-line flags
|
|
|
|
.replace_flag <- function(variable_name, value, content) {
|
|
|
|
out <- gsub(
|
|
|
|
pattern = paste0(variable_name, " <-.*")
|
|
|
|
, replacement = paste0(variable_name, " <- ", as.character(value))
|
|
|
|
, x = content
|
|
|
|
)
|
|
|
|
return(out)
|
|
|
|
}
|
|
|
|
|
2020-08-10 02:44:38 +03:00
|
|
|
install_libs_content <- readLines(
|
|
|
|
file.path("R-package", "src", "install.libs.R")
|
|
|
|
)
|
2020-11-29 18:29:20 +03:00
|
|
|
install_libs_content <- .replace_flag("use_gpu", USING_GPU, install_libs_content)
|
|
|
|
install_libs_content <- .replace_flag("use_mingw", USING_MINGW, install_libs_content)
|
|
|
|
install_libs_content <- .replace_flag("use_msys2", USING_MSYS2, install_libs_content)
|
2020-08-10 02:44:38 +03:00
|
|
|
|
2021-01-19 05:08:20 +03:00
|
|
|
# set up extra flags based on keyword arguments
|
|
|
|
keyword_args <- parsed_args[["keyword_args"]]
|
|
|
|
if (length(keyword_args) > 0L) {
|
|
|
|
cmake_args_to_add <- NULL
|
|
|
|
for (i in seq_len(length(keyword_args))) {
|
|
|
|
arg_name <- names(keyword_args)[[i]]
|
|
|
|
define_name <- ARGS_TO_DEFINES[[arg_name]]
|
2022-11-29 06:26:26 +03:00
|
|
|
arg_value <- shQuote(normalizePath(keyword_args[[arg_name]], winslash = "/"))
|
2021-01-19 05:08:20 +03:00
|
|
|
cmake_args_to_add <- c(cmake_args_to_add, paste0(define_name, "=", arg_value))
|
|
|
|
}
|
|
|
|
install_libs_content <- gsub(
|
|
|
|
pattern = paste0("command_line_args <- NULL")
|
|
|
|
, replacement = paste0(
|
2022-11-29 06:26:26 +03:00
|
|
|
"command_line_args <- c(\'"
|
|
|
|
, paste(cmake_args_to_add, collapse = "', '")
|
|
|
|
, "')"
|
2021-01-19 05:08:20 +03:00
|
|
|
)
|
|
|
|
, x = install_libs_content
|
2022-11-29 06:26:26 +03:00
|
|
|
, fixed = TRUE
|
2021-01-19 05:08:20 +03:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2021-11-10 04:39:59 +03:00
|
|
|
# if provided, set '-j' in 'make' commands in install.libs.R
|
|
|
|
if (length(parsed_args[["make_args"]]) > 0L) {
|
|
|
|
install_libs_content <- gsub(
|
|
|
|
pattern = "make_args_from_build_script <- character(0L)"
|
|
|
|
, replacement = paste0(
|
|
|
|
"make_args_from_build_script <- c(\""
|
|
|
|
, paste0(parsed_args[["make_args"]], collapse = "\", \"")
|
|
|
|
, "\")"
|
|
|
|
)
|
|
|
|
, x = install_libs_content
|
|
|
|
, fixed = TRUE
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2018-08-29 07:31:42 +03:00
|
|
|
# R returns FALSE (not a non-zero exit code) if a file copy operation
|
|
|
|
# breaks. Let's fix that
|
2018-09-23 18:48:49 +03:00
|
|
|
.handle_result <- function(res) {
|
2020-07-29 05:05:59 +03:00
|
|
|
if (!all(res)) {
|
2018-09-23 18:48:49 +03:00
|
|
|
stop("Copying files failed!")
|
|
|
|
}
|
2021-01-05 05:54:52 +03:00
|
|
|
return(invisible(NULL))
|
2018-08-29 07:31:42 +03:00
|
|
|
}
|
|
|
|
|
2019-05-08 11:57:01 +03:00
|
|
|
# system() will not raise an R exception if the process called
|
2020-05-14 19:31:13 +03:00
|
|
|
# fails. Wrapping it here to get that behavior.
|
|
|
|
#
|
|
|
|
# system() introduces a lot of overhead, at least on Windows,
|
|
|
|
# so trying processx if it is available
|
|
|
|
.run_shell_command <- function(cmd, args, strict = TRUE) {
|
|
|
|
on_windows <- .Platform$OS.type == "windows"
|
|
|
|
has_processx <- suppressMessages({
|
|
|
|
suppressWarnings({
|
2022-06-19 05:15:48 +03:00
|
|
|
require("processx") # nolint: undesirable_function
|
2020-05-14 19:31:13 +03:00
|
|
|
})
|
|
|
|
})
|
|
|
|
if (has_processx && on_windows) {
|
|
|
|
result <- processx::run(
|
|
|
|
command = cmd
|
|
|
|
, args = args
|
|
|
|
, windows_verbatim_args = TRUE
|
|
|
|
, error_on_status = FALSE
|
|
|
|
, echo = TRUE
|
|
|
|
)
|
|
|
|
exit_code <- result$status
|
|
|
|
} else {
|
|
|
|
if (on_windows) {
|
|
|
|
message(paste0(
|
|
|
|
"Using system() to run shell commands. Installing "
|
|
|
|
, "'processx' with install.packages('processx') might "
|
|
|
|
, "make this faster."
|
|
|
|
))
|
|
|
|
}
|
|
|
|
cmd <- paste0(cmd, " ", paste0(args, collapse = " "))
|
|
|
|
exit_code <- system(cmd)
|
|
|
|
}
|
|
|
|
|
|
|
|
if (exit_code != 0L && isTRUE(strict)) {
|
2019-05-08 11:57:01 +03:00
|
|
|
stop(paste0("Command failed with exit code: ", exit_code))
|
|
|
|
}
|
2020-05-14 19:31:13 +03:00
|
|
|
return(invisible(exit_code))
|
2019-05-08 11:57:01 +03:00
|
|
|
}
|
|
|
|
|
2018-08-29 07:31:42 +03:00
|
|
|
# Make a new temporary folder to work in
|
2020-05-25 05:23:38 +03:00
|
|
|
unlink(x = TEMP_R_DIR, recursive = TRUE)
|
|
|
|
dir.create(TEMP_R_DIR)
|
2018-08-29 07:31:42 +03:00
|
|
|
|
|
|
|
# copy in the relevant files
|
2019-11-17 00:12:38 +03:00
|
|
|
result <- file.copy(
|
|
|
|
from = "R-package/./"
|
2020-05-25 05:23:38 +03:00
|
|
|
, to = sprintf("%s/", TEMP_R_DIR)
|
2019-11-17 00:12:38 +03:00
|
|
|
, recursive = TRUE
|
|
|
|
, overwrite = TRUE
|
|
|
|
)
|
2018-08-29 07:31:42 +03:00
|
|
|
.handle_result(result)
|
|
|
|
|
2020-11-29 18:29:20 +03:00
|
|
|
# overwrite src/install.libs.R with new content based on command-line flags
|
|
|
|
writeLines(
|
|
|
|
text = install_libs_content
|
|
|
|
, con = file.path(TEMP_SOURCE_DIR, "install.libs.R")
|
|
|
|
)
|
|
|
|
|
2020-07-29 05:05:59 +03:00
|
|
|
# Add blank Makevars files
|
|
|
|
result <- file.copy(
|
|
|
|
from = file.path(TEMP_R_DIR, "inst", "Makevars")
|
|
|
|
, to = file.path(TEMP_SOURCE_DIR, "Makevars")
|
|
|
|
, overwrite = TRUE
|
|
|
|
)
|
|
|
|
.handle_result(result)
|
|
|
|
result <- file.copy(
|
|
|
|
from = file.path(TEMP_R_DIR, "inst", "Makevars.win")
|
|
|
|
, to = file.path(TEMP_SOURCE_DIR, "Makevars.win")
|
|
|
|
, overwrite = TRUE
|
|
|
|
)
|
|
|
|
.handle_result(result)
|
|
|
|
|
2019-11-17 00:12:38 +03:00
|
|
|
result <- file.copy(
|
|
|
|
from = "include/"
|
2020-05-25 05:23:38 +03:00
|
|
|
, to = sprintf("%s/", TEMP_SOURCE_DIR)
|
2019-11-17 00:12:38 +03:00
|
|
|
, recursive = TRUE
|
|
|
|
, overwrite = TRUE
|
|
|
|
)
|
2018-08-29 07:31:42 +03:00
|
|
|
.handle_result(result)
|
|
|
|
|
2019-11-17 00:12:38 +03:00
|
|
|
result <- file.copy(
|
|
|
|
from = "src/"
|
2020-05-25 05:23:38 +03:00
|
|
|
, to = sprintf("%s/", TEMP_SOURCE_DIR)
|
2019-11-17 00:12:38 +03:00
|
|
|
, recursive = TRUE
|
|
|
|
, overwrite = TRUE
|
|
|
|
)
|
2018-12-24 08:05:29 +03:00
|
|
|
.handle_result(result)
|
|
|
|
|
2021-01-18 15:44:38 +03:00
|
|
|
EIGEN_R_DIR <- file.path(TEMP_SOURCE_DIR, "include", "Eigen")
|
|
|
|
dir.create(EIGEN_R_DIR)
|
|
|
|
|
|
|
|
eigen_modules <- c(
|
|
|
|
"Cholesky"
|
|
|
|
, "Core"
|
|
|
|
, "Dense"
|
|
|
|
, "Eigenvalues"
|
|
|
|
, "Geometry"
|
|
|
|
, "Householder"
|
|
|
|
, "Jacobi"
|
|
|
|
, "LU"
|
|
|
|
, "QR"
|
|
|
|
, "SVD"
|
|
|
|
)
|
|
|
|
for (eigen_module in eigen_modules) {
|
|
|
|
result <- file.copy(
|
2021-01-22 17:45:43 +03:00
|
|
|
from = file.path("external_libs", "eigen", "Eigen", eigen_module)
|
2021-01-18 15:44:38 +03:00
|
|
|
, to = EIGEN_R_DIR
|
|
|
|
, recursive = FALSE
|
|
|
|
, overwrite = TRUE
|
|
|
|
)
|
|
|
|
.handle_result(result)
|
|
|
|
}
|
|
|
|
|
|
|
|
dir.create(file.path(EIGEN_R_DIR, "src"))
|
|
|
|
|
|
|
|
for (eigen_module in c(eigen_modules, "misc", "plugins")) {
|
|
|
|
if (eigen_module == "Dense") {
|
|
|
|
next
|
|
|
|
}
|
|
|
|
module_dir <- file.path(EIGEN_R_DIR, "src", eigen_module)
|
|
|
|
dir.create(module_dir, recursive = TRUE)
|
|
|
|
result <- file.copy(
|
2021-01-22 17:45:43 +03:00
|
|
|
from = sprintf("%s/", file.path("external_libs", "eigen", "Eigen", "src", eigen_module))
|
2021-01-18 15:44:38 +03:00
|
|
|
, to = sprintf("%s/", file.path(EIGEN_R_DIR, "src"))
|
|
|
|
, recursive = TRUE
|
|
|
|
, overwrite = TRUE
|
|
|
|
)
|
|
|
|
.handle_result(result)
|
|
|
|
}
|
|
|
|
|
|
|
|
.replace_pragmas <- function(filepath) {
|
|
|
|
pragma_patterns <- c(
|
|
|
|
"^.*#pragma clang diagnostic.*$"
|
|
|
|
, "^.*#pragma diag_suppress.*$"
|
|
|
|
, "^.*#pragma GCC diagnostic.*$"
|
|
|
|
, "^.*#pragma region.*$"
|
|
|
|
, "^.*#pragma endregion.*$"
|
|
|
|
, "^.*#pragma warning.*$"
|
|
|
|
)
|
|
|
|
content <- readLines(filepath)
|
|
|
|
for (pragma_pattern in pragma_patterns) {
|
|
|
|
content <- content[!grepl(pragma_pattern, content)]
|
|
|
|
}
|
|
|
|
writeLines(content, filepath)
|
|
|
|
}
|
|
|
|
|
|
|
|
# remove pragmas that suppress warnings, to appease R CMD check
|
|
|
|
.replace_pragmas(
|
|
|
|
file.path(EIGEN_R_DIR, "src", "Core", "arch", "SSE", "Complex.h")
|
|
|
|
)
|
|
|
|
.replace_pragmas(
|
|
|
|
file.path(EIGEN_R_DIR, "src", "Core", "util", "DisableStupidWarnings.h")
|
|
|
|
)
|
|
|
|
|
2019-11-17 00:12:38 +03:00
|
|
|
result <- file.copy(
|
|
|
|
from = "CMakeLists.txt"
|
2020-05-25 05:23:38 +03:00
|
|
|
, to = file.path(TEMP_R_DIR, "inst", "bin/")
|
2019-11-17 00:12:38 +03:00
|
|
|
, overwrite = TRUE
|
|
|
|
)
|
2018-08-29 07:31:42 +03:00
|
|
|
.handle_result(result)
|
|
|
|
|
2020-07-29 05:05:59 +03:00
|
|
|
# remove CRAN-specific files
|
|
|
|
result <- file.remove(
|
2020-11-10 18:51:46 +03:00
|
|
|
file.path(TEMP_R_DIR, "cleanup")
|
|
|
|
, file.path(TEMP_R_DIR, "configure")
|
2020-07-29 05:05:59 +03:00
|
|
|
, file.path(TEMP_R_DIR, "configure.ac")
|
|
|
|
, file.path(TEMP_R_DIR, "configure.win")
|
|
|
|
, file.path(TEMP_SOURCE_DIR, "Makevars.in")
|
|
|
|
, file.path(TEMP_SOURCE_DIR, "Makevars.win.in")
|
|
|
|
)
|
|
|
|
.handle_result(result)
|
|
|
|
|
2020-12-08 16:36:24 +03:00
|
|
|
#------------#
|
|
|
|
# submodules #
|
|
|
|
#------------#
|
2021-01-22 17:45:43 +03:00
|
|
|
EXTERNAL_LIBS_R_DIR <- file.path(TEMP_SOURCE_DIR, "external_libs")
|
|
|
|
dir.create(EXTERNAL_LIBS_R_DIR)
|
|
|
|
for (submodule in list.dirs(
|
|
|
|
path = "external_libs"
|
|
|
|
, full.names = FALSE
|
|
|
|
, recursive = FALSE
|
|
|
|
)) {
|
|
|
|
# compute/ is a submodule with boost, only needed if
|
2024-10-07 05:49:20 +03:00
|
|
|
# building the R-package with GPU support;
|
2021-01-22 17:45:43 +03:00
|
|
|
# eigen/ has a special treatment due to licensing aspects
|
|
|
|
if ((submodule == "compute" && !USING_GPU) || submodule == "eigen") {
|
|
|
|
next
|
|
|
|
}
|
|
|
|
result <- file.copy(
|
|
|
|
from = sprintf("%s/", file.path("external_libs", submodule))
|
|
|
|
, to = sprintf("%s/", EXTERNAL_LIBS_R_DIR)
|
|
|
|
, recursive = TRUE
|
|
|
|
, overwrite = TRUE
|
|
|
|
)
|
|
|
|
.handle_result(result)
|
|
|
|
}
|
2020-12-08 16:36:24 +03:00
|
|
|
|
2020-05-25 05:23:38 +03:00
|
|
|
# copy files into the place CMake expects
|
2021-03-21 16:36:03 +03:00
|
|
|
CMAKE_MODULES_R_DIR <- file.path(TEMP_SOURCE_DIR, "cmake", "modules")
|
|
|
|
dir.create(CMAKE_MODULES_R_DIR, recursive = TRUE)
|
|
|
|
result <- file.copy(
|
|
|
|
from = file.path("cmake", "modules", "FindLibR.cmake")
|
|
|
|
, to = sprintf("%s/", CMAKE_MODULES_R_DIR)
|
|
|
|
, overwrite = TRUE
|
|
|
|
)
|
|
|
|
.handle_result(result)
|
2021-05-13 00:42:39 +03:00
|
|
|
for (src_file in c("lightgbm_R.cpp", "lightgbm_R.h")) {
|
2020-05-25 05:23:38 +03:00
|
|
|
result <- file.copy(
|
|
|
|
from = file.path(TEMP_SOURCE_DIR, src_file)
|
|
|
|
, to = file.path(TEMP_SOURCE_DIR, "src", src_file)
|
|
|
|
, overwrite = TRUE
|
|
|
|
)
|
|
|
|
.handle_result(result)
|
|
|
|
result <- file.remove(
|
|
|
|
file.path(TEMP_SOURCE_DIR, src_file)
|
|
|
|
)
|
|
|
|
.handle_result(result)
|
|
|
|
}
|
|
|
|
|
2020-06-14 03:56:34 +03:00
|
|
|
result <- file.copy(
|
|
|
|
from = file.path("R-package", "inst", "make-r-def.R")
|
|
|
|
, to = file.path(TEMP_R_DIR, "inst", "bin/")
|
|
|
|
, overwrite = TRUE
|
|
|
|
)
|
|
|
|
.handle_result(result)
|
|
|
|
|
2020-08-25 22:36:37 +03:00
|
|
|
# R packages cannot have versions like 3.0.0rc1, but
|
|
|
|
# 3.0.0-1 is acceptable
|
|
|
|
LGB_VERSION <- readLines("VERSION.txt")[1L]
|
|
|
|
LGB_VERSION <- gsub(
|
|
|
|
pattern = "rc"
|
|
|
|
, replacement = "-"
|
|
|
|
, x = LGB_VERSION
|
2023-01-31 08:33:48 +03:00
|
|
|
, fixed = TRUE
|
2020-08-25 22:36:37 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
# DESCRIPTION has placeholders for version
|
|
|
|
# and date so it doesn't have to be updated manually
|
|
|
|
DESCRIPTION_FILE <- file.path(TEMP_R_DIR, "DESCRIPTION")
|
|
|
|
description_contents <- readLines(DESCRIPTION_FILE)
|
|
|
|
description_contents <- gsub(
|
|
|
|
pattern = "~~VERSION~~"
|
|
|
|
, replacement = LGB_VERSION
|
|
|
|
, x = description_contents
|
2023-01-31 08:33:48 +03:00
|
|
|
, fixed = TRUE
|
2020-08-25 22:36:37 +03:00
|
|
|
)
|
|
|
|
description_contents <- gsub(
|
|
|
|
pattern = "~~DATE~~"
|
|
|
|
, replacement = as.character(Sys.Date())
|
|
|
|
, x = description_contents
|
2023-01-31 08:33:48 +03:00
|
|
|
, fixed = TRUE
|
2020-08-25 22:36:37 +03:00
|
|
|
)
|
2023-03-07 06:57:18 +03:00
|
|
|
description_contents <- gsub(
|
|
|
|
pattern = "~~CXXSTD~~"
|
|
|
|
, replacement = "C++11"
|
|
|
|
, x = description_contents
|
|
|
|
, fixed = TRUE
|
|
|
|
)
|
2020-08-25 22:36:37 +03:00
|
|
|
writeLines(description_contents, DESCRIPTION_FILE)
|
|
|
|
|
2018-08-29 07:31:42 +03:00
|
|
|
# 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
|
2021-11-18 07:15:32 +03:00
|
|
|
r_build_args <- c("CMD", "build", TEMP_R_DIR, "--keep-empty-dirs")
|
|
|
|
if (isTRUE(SKIP_VIGNETTES)) {
|
|
|
|
r_build_args <- c(r_build_args, "--no-build-vignettes")
|
|
|
|
}
|
|
|
|
.run_shell_command("R", r_build_args)
|
2018-08-29 07:31:42 +03:00
|
|
|
|
|
|
|
# Install the package
|
|
|
|
version <- gsub(
|
2023-01-31 08:33:48 +03:00
|
|
|
pattern = "Version: ",
|
|
|
|
replacement = "",
|
|
|
|
x = grep(
|
|
|
|
pattern = "Version: "
|
|
|
|
, x = readLines(con = file.path(TEMP_R_DIR, "DESCRIPTION"))
|
2019-11-17 00:12:38 +03:00
|
|
|
, value = TRUE
|
2023-01-31 08:33:48 +03:00
|
|
|
, fixed = TRUE
|
2018-09-23 18:48:49 +03:00
|
|
|
)
|
2023-01-31 08:33:48 +03:00
|
|
|
, fixed = TRUE
|
2018-08-29 07:31:42 +03:00
|
|
|
)
|
|
|
|
tarball <- file.path(getwd(), sprintf("lightgbm_%s.tar.gz", version))
|
|
|
|
|
2020-05-14 19:31:13 +03:00
|
|
|
install_cmd <- "R"
|
|
|
|
install_args <- c("CMD", "INSTALL", "--no-multiarch", "--with-keep.source", tarball)
|
2020-03-31 07:01:29 +03:00
|
|
|
if (INSTALL_AFTER_BUILD) {
|
2020-05-14 19:31:13 +03:00
|
|
|
.run_shell_command(install_cmd, install_args)
|
2020-03-31 07:01:29 +03:00
|
|
|
} else {
|
2020-05-14 19:31:13 +03:00
|
|
|
cmd <- paste0(install_cmd, " ", paste0(install_args, collapse = " "))
|
2020-03-31 07:01:29 +03:00
|
|
|
print(sprintf("Skipping installation. Install the package with command '%s'", cmd))
|
|
|
|
}
|