From 99f06fe171a26755cc0f4d3ab1b578b83c507d54 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Mon, 24 Aug 2020 19:00:47 -0500 Subject: [PATCH 1/5] [R-package] [ci] Reduce manual effort for version updates --- R-package/DESCRIPTION | 4 ++-- R-package/README.md | 2 +- R-package/configure | 18 +++++++++--------- R-package/configure.ac | 2 +- R-package/recreate-configure.sh | 17 ++++++++++++++++- build-cran-package.sh | 12 ++++++++++++ build_r.R | 25 +++++++++++++++++++++++++ 7 files changed, 66 insertions(+), 14 deletions(-) diff --git a/R-package/DESCRIPTION b/R-package/DESCRIPTION index 0bad45f43d59..d0c5a429198c 100755 --- a/R-package/DESCRIPTION +++ b/R-package/DESCRIPTION @@ -1,8 +1,8 @@ Package: lightgbm Type: Package Title: Light Gradient Boosting Machine -Version: 3.0.0-1 -Date: 2020-08-06 +Version: ~~VERSION~~ +Date: ~~DATE~~ Authors@R: c( person("Guolin", "Ke", email = "guolin.ke@microsoft.com", role = c("aut", "cre")), person("Damien", "Soukhavong", email = "damien.soukhavong@skema.edu", role = c("aut")), diff --git a/R-package/README.md b/R-package/README.md index 689a77ebc9de..cf3468967232 100644 --- a/R-package/README.md +++ b/R-package/README.md @@ -250,7 +250,7 @@ At build time, `configure` will be run and used to create a file `Makevars`, usi ./R-package/recreate-configure.sh ``` - If you do not have easy access to an Ubuntu 18.04 environment, the `configure` script can be generated using Docker. + If you do not have easy access to an Ubuntu 18.04 environment, the `configure` script can be generated using Docker by running the code below from the root of this repo. ```shell docker run \ diff --git a/R-package/configure b/R-package/configure index 8734bd0ef536..0858fec80bad 100755 --- a/R-package/configure +++ b/R-package/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for lightgbm 3.0.0-1. +# Generated by GNU Autoconf 2.69 for lightgbm 5.2.1. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -576,8 +576,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='lightgbm' PACKAGE_TARNAME='lightgbm' -PACKAGE_VERSION='3.0.0-1' -PACKAGE_STRING='lightgbm 3.0.0-1' +PACKAGE_VERSION='5.2.1' +PACKAGE_STRING='lightgbm 5.2.1' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -1182,7 +1182,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures lightgbm 3.0.0-1 to adapt to many kinds of systems. +\`configure' configures lightgbm 5.2.1 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1244,7 +1244,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of lightgbm 3.0.0-1:";; + short | recursive ) echo "Configuration of lightgbm 5.2.1:";; esac cat <<\_ACEOF @@ -1311,7 +1311,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -lightgbm configure 3.0.0-1 +lightgbm configure 5.2.1 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1328,7 +1328,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by lightgbm $as_me 3.0.0-1, which was +It was created by lightgbm $as_me 5.2.1, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2377,7 +2377,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by lightgbm $as_me 3.0.0-1, which was +This file was extended by lightgbm $as_me 5.2.1, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -2430,7 +2430,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -lightgbm config.status 3.0.0-1 +lightgbm config.status 5.2.1 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/R-package/configure.ac b/R-package/configure.ac index cafc4b50b177..20182666b502 100644 --- a/R-package/configure.ac +++ b/R-package/configure.ac @@ -4,7 +4,7 @@ # * https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Configure-and-cleanup AC_PREREQ(2.69) -AC_INIT([lightgbm], [3.0.0-1], [], [lightgbm], []) +AC_INIT([lightgbm], [~~VERSION~~], [], [lightgbm], []) ########################### # find compiler and flags # diff --git a/R-package/recreate-configure.sh b/R-package/recreate-configure.sh index 9263174a7dad..e561d151b4f2 100755 --- a/R-package/recreate-configure.sh +++ b/R-package/recreate-configure.sh @@ -4,6 +4,14 @@ # this script should run on Ubuntu 18.04 AUTOCONF_VERSION=$(cat R-package/AUTOCONF_UBUNTU_VERSION) +# R packages cannot have versions like 3.0.0rc1, but +# 3.0.0-1 is acceptable +LGB_VERSION=$(cat VERSION.txt | sed "s/rc/-/g") + +# this script changes configure.ac. Copying to a temporary file +# so changes to configure.ac don't get committed in git +TMP_CONFIGURE_AC=".configure.ac" + echo "Creating 'configure' script with Autoconf ${AUTOCONF_VERSION}" apt update @@ -13,11 +21,18 @@ apt-get install \ autoconf=${AUTOCONF_VERSION} cd R-package + +# configure.ac has a placeholder for version +cp configure.ac ${TMP_CONFIGURE_AC} +sed -i.bak -e "s/~~VERSION~~/${LGB_VERSION}/" ${TMP_CONFIGURE_AC} + autoconf \ --output configure \ - configure.ac \ + ${TMP_CONFIGURE_AC} \ || exit -1 +rm ${TMP_CONFIGURE_AC} + rm -r autom4te.cache || echo "no autoconf cache found" echo "done creating 'configure' script" diff --git a/build-cran-package.sh b/build-cran-package.sh index 564ecb91fe1d..eb48bde1e563 100755 --- a/build-cran-package.sh +++ b/build-cran-package.sh @@ -17,6 +17,12 @@ if test -d ${TEMP_R_DIR}; then fi mkdir -p ${TEMP_R_DIR} +CURRENT_DATE=$(date +'%Y-%m-%d') + +# R packages cannot have versions like 3.0.0rc1, but +# 3.0.0-1 is acceptable +LGB_VERSION=$(cat VERSION.txt | sed "s/rc/-/g") + # move relevant files cp -R R-package/* ${TEMP_R_DIR} cp -R include ${TEMP_R_DIR}/src/ @@ -38,6 +44,12 @@ cd ${TEMP_R_DIR} # for the R package rm src/main.cpp + # configure.ac and DESCRIPTION have placeholders for version + # and date so they don't have to be updated manually + sed -i.bak -e "s/~~VERSION~~/${LGB_VERSION}/" configure.ac + sed -i.bak -e "s/~~VERSION~~/${LGB_VERSION}/" DESCRIPTION + sed -i.bak -e "s/~~DATE~~/${CURRENT_DATE}/" DESCRIPTION + # Remove 'region' and 'endregion' pragmas. This won't change # the correctness of the code. CRAN does not allow you # to use compiler flag '-Wno-unknown-pragmas' or diff --git a/build_r.R b/build_r.R index 4b3a854c07bd..e2f58ceb0c48 100644 --- a/build_r.R +++ b/build_r.R @@ -155,6 +155,31 @@ result <- file.copy( ) .handle_result(result) +# R packages cannot have versions like 3.0.0rc1, but +# 3.0.0-1 is acceptable +LGB_VERSION <- readLines("VERSION.txt")[1] +LGB_VERSION <- gsub( + pattern = "rc" + , replacement = "-" + , x = LGB_VERSION +) + +# 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 +) +description_contents <- gsub( + pattern = "~~DATE~~" + , replacement = as.character(Sys.Date()) + , x = description_contents +) +writeLines(description_contents, DESCRIPTION_FILE) + # 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 From 8821cf6f145765b8f5fbd4c840497e05ccbb60cb Mon Sep 17 00:00:00 2001 From: James Lamb Date: Mon, 24 Aug 2020 19:07:35 -0500 Subject: [PATCH 2/5] fix configure --- R-package/configure | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/R-package/configure b/R-package/configure index 0858fec80bad..c5ed06752af3 100755 --- a/R-package/configure +++ b/R-package/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for lightgbm 5.2.1. +# Generated by GNU Autoconf 2.69 for lightgbm 3.0.0. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -576,8 +576,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='lightgbm' PACKAGE_TARNAME='lightgbm' -PACKAGE_VERSION='5.2.1' -PACKAGE_STRING='lightgbm 5.2.1' +PACKAGE_VERSION='3.0.0' +PACKAGE_STRING='lightgbm 3.0.0' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -1182,7 +1182,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures lightgbm 5.2.1 to adapt to many kinds of systems. +\`configure' configures lightgbm 3.0.0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1244,7 +1244,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of lightgbm 5.2.1:";; + short | recursive ) echo "Configuration of lightgbm 3.0.0:";; esac cat <<\_ACEOF @@ -1311,7 +1311,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -lightgbm configure 5.2.1 +lightgbm configure 3.0.0 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1328,7 +1328,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by lightgbm $as_me 5.2.1, which was +It was created by lightgbm $as_me 3.0.0, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2377,7 +2377,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by lightgbm $as_me 5.2.1, which was +This file was extended by lightgbm $as_me 3.0.0, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -2430,7 +2430,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -lightgbm config.status 5.2.1 +lightgbm config.status 3.0.0 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" From b48a81d75cb1b2793429294a18bb2c99d68d8c60 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Mon, 24 Aug 2020 19:08:20 -0500 Subject: [PATCH 3/5] remove useless comment --- R-package/recreate-configure.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/R-package/recreate-configure.sh b/R-package/recreate-configure.sh index e561d151b4f2..12d6e12d2903 100755 --- a/R-package/recreate-configure.sh +++ b/R-package/recreate-configure.sh @@ -22,7 +22,6 @@ apt-get install \ cd R-package -# configure.ac has a placeholder for version cp configure.ac ${TMP_CONFIGURE_AC} sed -i.bak -e "s/~~VERSION~~/${LGB_VERSION}/" ${TMP_CONFIGURE_AC} From 987c9d63e47813c77c5f47e959daedfbffa4b8aa Mon Sep 17 00:00:00 2001 From: James Lamb Date: Tue, 25 Aug 2020 03:03:37 +0100 Subject: [PATCH 4/5] Update build_r.R Co-authored-by: Guolin Ke --- build_r.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_r.R b/build_r.R index e2f58ceb0c48..bf019200ae43 100644 --- a/build_r.R +++ b/build_r.R @@ -157,7 +157,7 @@ result <- file.copy( # R packages cannot have versions like 3.0.0rc1, but # 3.0.0-1 is acceptable -LGB_VERSION <- readLines("VERSION.txt")[1] +LGB_VERSION <- readLines("VERSION.txt")[1L] LGB_VERSION <- gsub( pattern = "rc" , replacement = "-" From f706f8722fc07c3e34f2aed2e33209a94e079f1b Mon Sep 17 00:00:00 2001 From: James Lamb Date: Mon, 24 Aug 2020 21:36:11 -0500 Subject: [PATCH 5/5] fix recreate-configure check in CI --- .ci/test_r_package.sh | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.ci/test_r_package.sh b/.ci/test_r_package.sh index 9bbc35b5672f..0d65a5dcec8a 100755 --- a/.ci/test_r_package.sh +++ b/.ci/test_r_package.sh @@ -134,12 +134,7 @@ elif [[ $R_BUILD_TYPE == "cran" ]]; then # on Linux, we recreate configure in CI to test if # a change in a PR has changed configure.ac if [[ $OS_NAME == "linux" ]]; then - cd ${BUILD_DIRECTORY}/R-package - autoconf \ - --output configure \ - configure.ac \ - || exit -1 - cd ${BUILD_DIRECTORY} + ${BUILD_DIRECTORY}/R-package/recreate-configure.sh num_files_changed=$( git diff --name-only | wc -l