diff --git a/.appveyor.yml b/.appveyor.yml index 7d1c970cdae0..e51feb918675 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,4 +1,4 @@ -version: 3.3.2.99.{build} +version: 3.3.3.{build} image: Visual Studio 2015 platform: x64 diff --git a/.ci/test_r_package_windows.ps1 b/.ci/test_r_package_windows.ps1 index c8f63b9c8b06..891c7cbd36e1 100644 --- a/.ci/test_r_package_windows.ps1 +++ b/.ci/test_r_package_windows.ps1 @@ -54,11 +54,13 @@ Remove-From-Path ".*PostgreSQL.*" Remove-From-Path ".*\\R\\.*" Remove-From-Path ".*R Client.*" Remove-From-Path ".*rtools40.*" +Remove-From-Path ".*rtools42.*" Remove-From-Path ".*shells.*" Remove-From-Path ".*Strawberry.*" Remove-From-Path ".*tools.*" Remove-Item C:\rtools40 -Force -Recurse -ErrorAction Ignore +Remove-Item C:\rtools42 -Force -Recurse -ErrorAction Ignore # Get details needed for installing R components # @@ -74,11 +76,11 @@ if ($env:R_MAJOR_VERSION -eq "3") { $env:RTOOLS_EXE_FILE = "rtools35-x86_64.exe" $env:R_WINDOWS_VERSION = "3.6.3" } elseif ($env:R_MAJOR_VERSION -eq "4") { - $RTOOLS_INSTALL_PATH = "C:\rtools40" + $RTOOLS_INSTALL_PATH = "C:\rtools42" $env:RTOOLS_BIN = "$RTOOLS_INSTALL_PATH\usr\bin" - $env:RTOOLS_MINGW_BIN = "$RTOOLS_INSTALL_PATH\mingw64\bin" - $env:RTOOLS_EXE_FILE = "rtools40v2-x86_64.exe" - $env:R_WINDOWS_VERSION = "4.1.3" + $env:RTOOLS_MINGW_BIN = "$RTOOLS_INSTALL_PATH\x86_64-w64-mingw32.static.posix\bin" + $env:RTOOLS_EXE_FILE = "rtools42-5253-5107.exe" + $env:R_WINDOWS_VERSION = "4.2.1" } else { Write-Output "[ERROR] Unrecognized R version: $env:R_VERSION" Check-Output $false @@ -147,7 +149,7 @@ Write-Output "Building R package" # R CMD check is not used for MSVC builds if ($env:COMPILER -ne "MSVC") { - $PKG_FILE_NAME = "lightgbm_*.tar.gz" + $PKG_FILE_NAME = "lightgbm_$env:LGB_VER.tar.gz" $LOG_FILE_NAME = "lightgbm.Rcheck/00check.log" if ($env:R_BUILD_TYPE -eq "cmake") { diff --git a/.github/workflows/cuda.yml b/.github/workflows/cuda.yml index a8d69ddcaa33..b8ae029079db 100644 --- a/.github/workflows/cuda.yml +++ b/.github/workflows/cuda.yml @@ -37,17 +37,17 @@ jobs: compiler: gcc python_version: "3.10" cuda_version: "9.0" - task: cuda - - method: source - compiler: gcc - python_version: "3.8" - cuda_version: "11.7.1" - task: cuda_exp - - method: pip - compiler: clang - python_version: "3.9" - cuda_version: "10.0" - task: cuda_exp + # task: cuda + # - method: source + # compiler: gcc + # python_version: "3.8" + # cuda_version: "11.7.1" + # task: cuda_exp + # - method: pip + # compiler: clang + # python_version: "3.9" + # cuda_version: "10.0" + # task: cuda_exp steps: - name: Setup or update software on host machine run: | diff --git a/.github/workflows/r_package.yml b/.github/workflows/r_package.yml index 346a26315797..c6afad807ae2 100644 --- a/.github/workflows/r_package.yml +++ b/.github/workflows/r_package.yml @@ -83,7 +83,7 @@ jobs: task: r-package compiler: MINGW toolchain: MSYS - r_version: 4.1 + r_version: 4.2 build_type: cmake # Visual Studio 2019 - os: windows-2019 @@ -97,7 +97,7 @@ jobs: task: r-package compiler: MSVC toolchain: MSVC - r_version: 4.1 + r_version: 4.2 build_type: cmake ############### # CRAN builds # @@ -112,7 +112,7 @@ jobs: task: r-package compiler: MINGW toolchain: MSYS - r_version: 4.1 + r_version: 4.2 build_type: cran - os: ubuntu-latest task: r-package @@ -166,6 +166,7 @@ jobs: shell: pwsh -command ". {0}" run: | $env:BUILD_SOURCESDIRECTORY = $env:GITHUB_WORKSPACE + $env:LGB_VER = (Get-Content -TotalCount 1 $env:BUILD_SOURCESDIRECTORY\VERSION.txt).trim().replace('rc', '-') $env:TOOLCHAIN = "${{ matrix.toolchain }}" $env:R_VERSION = "${{ matrix.r_version }}" $env:R_BUILD_TYPE = "${{ matrix.build_type }}" diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 4f85742c7f74..7d63476a0f79 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -1,10 +1,12 @@ version: 2 +build: + os: "ubuntu-20.04" + tools: + python: "miniconda3-4.7" +conda: + environment: docs/env.yml formats: - pdf -python: - version: 3 - install: - - requirements: docs/requirements.txt sphinx: builder: html configuration: docs/conf.py diff --git a/CMakeLists.txt b/CMakeLists.txt index 109a252dfa6f..e313f58dd347 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -299,6 +299,18 @@ if(WIN32 AND MINGW) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libstdc++") endif() +# Check if inet_pton is already available, to avoid conflicts with the implementation in LightGBM. +# As of 2022, MinGW started including a definition of inet_pton. +if(WIN32) + include(CheckSymbolExists) + list(APPEND CMAKE_REQUIRED_LIBRARIES "ws2_32") + check_symbol_exists(inet_pton "ws2tcpip.h" WIN_INET_PTON_FOUND) + if(WIN_INET_PTON_FOUND) + add_definitions(-DWIN_HAS_INET_PTON) + endif() + list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES "ws2_32") +endif() + if(MSVC) SET(variables CMAKE_C_FLAGS_DEBUG diff --git a/R-package/README.md b/R-package/README.md index 918db731c48a..555d21c20c2f 100644 --- a/R-package/README.md +++ b/R-package/README.md @@ -94,6 +94,9 @@ After installing `Rtools` and `CMake`, be sure the following paths are added to - If you have `Rtools` 4.0, example: - `C:\rtools40\mingw64\bin` - `C:\rtools40\usr\bin` + - If you have `Rtools` 4.2, example: + - `C:\rtools42\x86_64-w64-mingw32.static.posix\bin` + - `C:\rtools42\usr\bin` * `CMake` - example: `C:\Program Files\CMake\bin` * `R` @@ -101,6 +104,8 @@ After installing `Rtools` and `CMake`, be sure the following paths are added to NOTE: Two `Rtools` paths are required from `Rtools` 4.0 onwards because paths and the list of included software was changed in `Rtools` 4.0. +NOTE: `Rtools42` takes a very different approach to the compiler toolchain than previous releases, and how you install it changes what is required to build packages. See ["Howto: Building R 4.2 and packages on Windows"](https://cran.r-project.org/bin/windows/base/howto-R-4.2.html). + #### Windows Toolchain Options A "toolchain" refers to the collection of software used to build the library. The R package can be built with three different toolchains. diff --git a/R-package/configure b/R-package/configure index 79470dc515aa..f94bf5831774 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.3.2. +# Generated by GNU Autoconf 2.69 for lightgbm 3.3.3. # # # 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.3.2' -PACKAGE_STRING='lightgbm 3.3.2' +PACKAGE_VERSION='3.3.3' +PACKAGE_STRING='lightgbm 3.3.3' 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.3.2 to adapt to many kinds of systems. +\`configure' configures lightgbm 3.3.3 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.3.2:";; + short | recursive ) echo "Configuration of lightgbm 3.3.3:";; 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.3.2 +lightgbm configure 3.3.3 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.3.2, which was +It was created by lightgbm $as_me 3.3.3, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2398,7 +2398,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.3.2, which was +This file was extended by lightgbm $as_me 3.3.3, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -2451,7 +2451,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.3.2 +lightgbm config.status 3.3.3 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/R-package/configure.win b/R-package/configure.win index dfbaa3fc0377..40886ec7b5dd 100755 --- a/R-package/configure.win +++ b/R-package/configure.win @@ -66,6 +66,31 @@ then LGB_CPPFLAGS="${LGB_CPPFLAGS} -DMM_MALLOC=1" fi +############# +# INET_PTON # +############# + +ac_inet_pton="no" + +cat > conftest.cpp < +int main() { + int (*fptr)(int, const char*, void*); + fptr = &inet_pton; + return 0; +} +EOL + +${CXX} ${CXXFLAGS} ${CPPFLAGS} -o conftest conftest.cpp 2>/dev/null && ./conftest && ac_inet_pton="yes" +rm -f ./conftest +rm -f ./conftest.cpp +echo "checking whether INET_PTON works...${ac_inet_pton}" + +if test "${ac_inet_pton}" = "yes"; +then + LGB_CPPFLAGS="${LGB_CPPFLAGS} -DWIN_HAS_INET_PTON=1" +fi + # Generate Makevars.win from Makevars.win.in sed -e \ "s/@LGB_CPPFLAGS@/$LGB_CPPFLAGS/" \ diff --git a/R-package/src/install.libs.R b/R-package/src/install.libs.R index 9f839e2c1d73..bc6ed37a7f17 100644 --- a/R-package/src/install.libs.R +++ b/R-package/src/install.libs.R @@ -1,5 +1,6 @@ # User options use_gpu <- FALSE +make_args_from_build_script <- character(0L) # For Windows, the package will be built with Visual Studio # unless you set one of these to TRUE @@ -22,6 +23,11 @@ if (!(R_int_UUID == "0310d4b8-ccb1-4bb8-ba94-d36a55f60262" warning("Warning: unmatched R_INTERNALS_UUID, may not run normally.") } +# Get some paths +source_dir <- file.path(R_PACKAGE_SOURCE, "src", fsep = "/") +build_dir <- file.path(source_dir, "build", fsep = "/") +inst_dir <- file.path(R_PACKAGE_SOURCE, "inst", fsep = "/") + # system() will not raise an R exception if the process called # fails. Wrapping it here to get that behavior. # @@ -31,7 +37,7 @@ if (!(R_int_UUID == "0310d4b8-ccb1-4bb8-ba94-d36a55f60262" on_windows <- .Platform$OS.type == "windows" has_processx <- suppressMessages({ suppressWarnings({ - require("processx") # nolint + require("processx") # nolint: undesirable_function }) }) if (has_processx && on_windows) { @@ -64,7 +70,8 @@ if (!(R_int_UUID == "0310d4b8-ccb1-4bb8-ba94-d36a55f60262" # try to generate Visual Studio build files .generate_vs_makefiles <- function(cmake_args) { vs_versions <- c( - "Visual Studio 16 2019" + "Visual Studio 17 2022" + , "Visual Studio 16 2019" , "Visual Studio 15 2017" , "Visual Studio 14 2015" ) @@ -94,7 +101,7 @@ if (!(R_int_UUID == "0310d4b8-ccb1-4bb8-ba94-d36a55f60262" # Move in CMakeLists.txt write_succeeded <- file.copy( - "../inst/bin/CMakeLists.txt" + file.path(inst_dir, "bin", "CMakeLists.txt") , "CMakeLists.txt" , overwrite = TRUE ) @@ -102,10 +109,6 @@ if (!write_succeeded) { stop("Copying CMakeLists.txt failed") } -# Get some paths -source_dir <- file.path(R_PACKAGE_SOURCE, "src", fsep = "/") -build_dir <- file.path(source_dir, "build", fsep = "/") - # Prepare building package dir.create( build_dir @@ -120,7 +123,7 @@ use_visual_studio <- !(use_mingw || use_msys2) # to create R.def from R.dll if (WINDOWS && use_visual_studio) { write_succeeded <- file.copy( - "../../inst/make-r-def.R" + file.path(inst_dir, "make-r-def.R") , file.path(build_dir, "make-r-def.R") , overwrite = TRUE ) @@ -132,7 +135,7 @@ if (WINDOWS && use_visual_studio) { # Prepare installation steps cmake_args <- NULL build_cmd <- "make" -build_args <- "_lightgbm" +build_args <- c("_lightgbm", make_args_from_build_script) lib_folder <- file.path(source_dir, fsep = "/") # add in command-line arguments @@ -194,7 +197,7 @@ if (WINDOWS) { cmake_args <- c(cmake_args, "-G", shQuote(windows_makefile_generator)) .run_shell_command("cmake", c(cmake_args, ".."), strict = FALSE) build_cmd <- windows_build_tool - build_args <- "_lightgbm" + build_args <- c("_lightgbm", make_args_from_build_script) } else { visual_studio_succeeded <- .generate_vs_makefiles(cmake_args) if (!isTRUE(visual_studio_succeeded)) { @@ -203,7 +206,7 @@ if (WINDOWS) { cmake_args <- c(cmake_args, "-G", shQuote(windows_makefile_generator)) .run_shell_command("cmake", c(cmake_args, ".."), strict = FALSE) build_cmd <- windows_build_tool - build_args <- "_lightgbm" + build_args <- c("_lightgbm", make_args_from_build_script) } else { build_cmd <- "cmake" build_args <- c("--build", ".", "--target", "_lightgbm", "--config", "Release") diff --git a/R-package/tests/testthat/test_basic.R b/R-package/tests/testthat/test_basic.R index 5aff8e2c2d2c..49260024f30f 100644 --- a/R-package/tests/testthat/test_basic.R +++ b/R-package/tests/testthat/test_basic.R @@ -1251,7 +1251,18 @@ test_that("lgb.train() supports non-ASCII feature names", { data = matrix(rnorm(400L), ncol = 4L) , label = rnorm(100L) ) - feature_names <- c("F_零", "F_一", "F_二", "F_三") + # content below is equivalent to + # + # feature_names <- c("F_零", "F_一", "F_二", "F_三") + # + # but using rawToChar() to avoid weird issues when {testthat} + # sources files and converts their encodings prior to evaluating the code + feature_names <- c( + rawToChar(as.raw(c(0x46, 0x5f, 0xe9, 0x9b, 0xb6))) + , rawToChar(as.raw(c(0x46, 0x5f, 0xe4, 0xb8, 0x80))) + , rawToChar(as.raw(c(0x46, 0x5f, 0xe4, 0xba, 0x8c))) + , rawToChar(as.raw(c(0x46, 0x5f, 0xe4, 0xb8, 0x89))) + ) bst <- lgb.train( data = dtrain , nrounds = 5L diff --git a/R-package/tests/testthat/test_dataset.R b/R-package/tests/testthat/test_dataset.R index 4207e4f241ca..145a57d77dc6 100644 --- a/R-package/tests/testthat/test_dataset.R +++ b/R-package/tests/testthat/test_dataset.R @@ -247,6 +247,10 @@ test_that("lgb.Dataset: Dataset should be able to construct from matrix and retu }) test_that("cpp errors should be raised as proper R errors", { + testthat::skip_if( + Sys.getenv("COMPILER", "") == "MSVC" + , message = "Skipping on Visual Studio" + ) data(agaricus.train, package = "lightgbm") train <- agaricus.train dtrain <- lgb.Dataset( diff --git a/VERSION.txt b/VERSION.txt index 477254331794..619b53766848 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -3.3.2 +3.3.3 diff --git a/build-cran-package.sh b/build-cran-package.sh index 02342daf3895..f49b71555639 100755 --- a/build-cran-package.sh +++ b/build-cran-package.sh @@ -30,7 +30,7 @@ set -e # Default values of arguments -BUILD_VIGNETTES=true +BUILD_VIGNETTES=false LGB_R_EXECUTABLE=R while [ $# -gt 0 ]; do diff --git a/build_r.R b/build_r.R index 64ca29989db9..6d197cb091ee 100644 --- a/build_r.R +++ b/build_r.R @@ -39,7 +39,7 @@ TEMP_SOURCE_DIR <- file.path(TEMP_R_DIR, "src") } parsed_args <- .parse_args(args) -SKIP_VIGNETTES <- "--no-build-vignettes" %in% parsed_args[["flags"]] +SKIP_VIGNETTES <- TRUE USING_GPU <- "--use-gpu" %in% parsed_args[["flags"]] USING_MINGW <- "--use-mingw" %in% parsed_args[["flags"]] USING_MSYS2 <- "--use-msys2" %in% parsed_args[["flags"]] diff --git a/docs/conf.py b/docs/conf.py index f52ac278cc8f..c97bf7c7fd62 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -25,7 +25,6 @@ from shutil import copytree from subprocess import PIPE, Popen from typing import Any, List -from unittest.mock import Mock import sphinx from docutils.nodes import reference @@ -40,12 +39,6 @@ INTERNAL_REF_REGEX = compile(r"(?P\.\/.+)(?P\.rst)(?P$|#)") -# -- mock out modules -MOCK_MODULES = ['numpy', 'scipy', 'scipy.sparse', - 'sklearn', 'matplotlib', 'pandas', 'graphviz', 'dask', 'dask.distributed'] -for mod_name in MOCK_MODULES: - sys.modules[mod_name] = Mock() - class InternalRefTransform(Transform): """Replaces '.rst' with '.html' in all internal links like './[Something].rst[#anchor]'.""" @@ -99,7 +92,22 @@ def run(self) -> List: "inherited-members": True, "show-inheritance": True, } - +# mock out modules +autodoc_mock_imports = [ + 'dask', + 'dask.distributed', + 'datatable', + 'graphviz', + 'matplotlib', + 'numpy', + 'pandas', + 'scipy', + 'scipy.sparse', +] +try: + import sklearn +except ImportError: + autodoc_mock_imports.append('sklearn') # hide type hints in API docs autodoc_typehints = "none" @@ -142,7 +150,7 @@ def run(self) -> List: # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. -language = None +language = 'en' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. @@ -254,18 +262,6 @@ def generate_r_docs(app: Sphinx) -> None: The application object representing the Sphinx process. """ commands = f""" - /home/docs/.conda/bin/conda create \ - -q \ - -y \ - -c conda-forge \ - -n r_env \ - r-base=4.1.0=hb67fd72_2 \ - r-data.table=1.14.0=r41hcfec24a_0 \ - r-jsonlite=1.7.2=r41hcfec24a_0 \ - r-matrix=1.3_4=r41he454529_0 \ - r-pkgdown=1.6.1=r41hc72bb7e_0 \ - r-roxygen2=7.1.1=r41h03ef668_0 - source /home/docs/.conda/bin/activate r_env export TAR=/bin/tar cd {CURR_PATH.parent} export R_LIBS="$CONDA_PREFIX/lib/R/library" @@ -290,6 +286,7 @@ def generate_r_docs(app: Sphinx) -> None: cd {CURR_PATH.parent} """ try: + print("Building R-package documentation") # Warning! The following code can cause buffer overflows on RTD. # Consider suppressing output completely if RTD project silently fails. # Refer to https://github.com/svenevs/exhale @@ -303,6 +300,7 @@ def generate_r_docs(app: Sphinx) -> None: raise RuntimeError(output) else: print(output) + print("Done building R-package documentation") except BaseException as e: raise Exception(f"An error has occurred while generating documentation for R-package\n{e}") diff --git a/docs/env.yml b/docs/env.yml new file mode 100644 index 000000000000..69bcd92fbdc3 --- /dev/null +++ b/docs/env.yml @@ -0,0 +1,18 @@ +name: docs-env +channels: + - nodefaults + - conda-forge +dependencies: + - breathe + - python=3.9 + - r-base=4.1.3 + - r-data.table=1.14.2 + - r-jsonlite=1.7.2 + - r-knitr=1.37 + - r-matrix=1.4_0 + - r-pkgdown=1.6.1 + - r-rmarkdown=2.11 + - r-roxygen2=7.2.1 + - scikit-learn + - sphinx + - "sphinx_rtd_theme>=0.5" diff --git a/src/network/socket_wrapper.hpp b/src/network/socket_wrapper.hpp index e4d63c434fc4..ba5d7de95817 100644 --- a/src/network/socket_wrapper.hpp +++ b/src/network/socket_wrapper.hpp @@ -60,11 +60,8 @@ const int INVALID_SOCKET = -1; #endif #ifdef _WIN32 -#ifndef _UCRT -// Recent MinGW has inet_pton, which then causes compiler error in -// combination with this replacement. -#ifndef _MSC_VER -// not using visual studio in windows +// existence of inet_pton is checked in CMakeLists.txt and configure.win, then stored in WIN_HAS_INET_PTON +#ifndef WIN_HAS_INET_PTON inline int inet_pton(int af, const char *src, void *dst) { struct sockaddr_storage ss; int size = sizeof(ss); @@ -89,7 +86,6 @@ inline int inet_pton(int af, const char *src, void *dst) { } #endif #endif -#endif #define MALLOC(x) HeapAlloc(GetProcessHeap(), 0, (x)) #define FREE(x) HeapFree(GetProcessHeap(), 0, (x))