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 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..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 3.0.0-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='3.0.0-1' -PACKAGE_STRING='lightgbm 3.0.0-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 3.0.0-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 3.0.0-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 3.0.0-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 3.0.0-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 3.0.0-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 3.0.0-1 +lightgbm config.status 3.0.0 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..12d6e12d2903 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,17 @@ apt-get install \ autoconf=${AUTOCONF_VERSION} cd R-package + +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..bf019200ae43 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")[1L] +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