Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[R-package] [ci] Add option to skip installation in build_r.R #2957

Merged
merged 6 commits into from
Mar 31, 2020
Merged
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
4 changes: 2 additions & 2 deletions .ci/test_r_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ packages="c('data.table', 'jsonlite', 'Matrix', 'R6', 'testthat')"
if [[ $OS_NAME == "macos" ]]; then
packages+=", type = 'binary'"
fi
Rscript --vanilla -e "install.packages(${packages}, repos = '${CRAN_MIRROR}', lib = '${R_LIB_PATH}')" || exit -1
Rscript --vanilla -e "install.packages(${packages}, repos = '${CRAN_MIRROR}', lib = '${R_LIB_PATH}', dependencies = c('Depends', 'Imports', 'LinkingTo'))" || exit -1
Copy link
Collaborator

Choose a reason for hiding this comment

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

@jameslamb
Just curious: what is the default set of options?

Copy link
Collaborator Author

@jameslamb jameslamb Mar 31, 2020

Choose a reason for hiding this comment

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

This set is the default set. From ?install.packages

The default, NA, means c("Depends", "Imports", "LinkingTo").

Those are the minimum ones needed to load a package. In case you're not familiar with them:

  • Depends: Has to be present to install your package. Will be loaded whenever your package is loaded.
  • Imports: Has to be present to install your package. Will only be loaded when your package calls code from them.
  • LinkingTo: Has to be present to install your package. These are usually header-only packages that your code links to, e.g. the BH package for Boost.

This commit just makes that explicit.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Got it, thanks a lot for the detailed explanation!


cd ${BUILD_DIRECTORY}
Rscript build_r.R || exit -1
Rscript build_r.R --skip-install || exit -1

PKG_TARBALL="lightgbm_${LGB_VER}.tar.gz"
LOG_FILE_NAME="lightgbm.Rcheck/00check.log"
Expand Down
9 changes: 8 additions & 1 deletion build_r.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
# Sys.setenv("CXX" = "/usr/local/bin/g++-8")
# Sys.setenv("CC" = "/usr/local/bin/gcc-8")

args <- commandArgs(trailingOnly = TRUE)
INSTALL_AFTER_BUILD <- !("--skip-install" %in% args)

# R returns FALSE (not a non-zero exit code) if a file copy operation
# breaks. Let's fix that
.handle_result <- function(res) {
Expand Down Expand Up @@ -86,4 +89,8 @@ version <- gsub(
tarball <- file.path(getwd(), sprintf("lightgbm_%s.tar.gz", version))

cmd <- sprintf("R CMD INSTALL %s --no-multiarch --with-keep.source", tarball)
.run_shell_command(cmd)
if (INSTALL_AFTER_BUILD) {
.run_shell_command(cmd)
} else {
print(sprintf("Skipping installation. Install the package with command '%s'", cmd))
}