Unverified Commit 8d2ec69f authored by Nikita Titov's avatar Nikita Titov Committed by GitHub
Browse files

[python][R][docs][ci] better compatibility with Visual Studio 2019 (#2083)

* set platform via A option

* style hotfix

* updated R installation script

* updated Python installation script

* updated CI test script

* provide VS version-ingependent link for redistributables download

* added link to VS 2019 redistributables

* added VS 2019 match for Boost binaries
parent de82ed58
...@@ -10,7 +10,7 @@ $env:PATH += ";$env:CONDA_PREFIX\Library\bin\graphviz" # temp graphviz hotfix ...@@ -10,7 +10,7 @@ $env:PATH += ";$env:CONDA_PREFIX\Library\bin\graphviz" # temp graphviz hotfix
if ($env:TASK -eq "regular") { if ($env:TASK -eq "regular") {
mkdir $env:BUILD_SOURCESDIRECTORY/build; cd $env:BUILD_SOURCESDIRECTORY/build mkdir $env:BUILD_SOURCESDIRECTORY/build; cd $env:BUILD_SOURCESDIRECTORY/build
cmake -DCMAKE_GENERATOR_PLATFORM=x64 .. ; cmake --build . --target ALL_BUILD --config Release ; Check-Output $? cmake -A x64 .. ; cmake --build . --target ALL_BUILD --config Release ; Check-Output $?
cd $env:BUILD_SOURCESDIRECTORY/python-package cd $env:BUILD_SOURCESDIRECTORY/python-package
python setup.py install --precompile ; Check-Output $? python setup.py install --precompile ; Check-Output $?
cp $env:BUILD_SOURCESDIRECTORY/Release/lib_lightgbm.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY cp $env:BUILD_SOURCESDIRECTORY/Release/lib_lightgbm.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY
......
...@@ -80,7 +80,7 @@ You will need: ...@@ -80,7 +80,7 @@ You will need:
In addition, if you are using a Visual Studio precompiled DLL, assuming you do not have Visual Studio installed (if you have it installed, ignore the warnings below): In addition, if you are using a Visual Studio precompiled DLL, assuming you do not have Visual Studio installed (if you have it installed, ignore the warnings below):
* Visual Studio 2015/2017 precompiled DLL: download and install Visual Studio Runtime for [2015](https://www.microsoft.com/en-us/download/details.aspx?id=52685)/[2017](https://go.microsoft.com/fwlink/?LinkId=746572) (you will get an error about MSVCP140.dll missing otherwise) * Visual Studio 2015/2017/2019 precompiled DLL: download and install Visual Studio Runtime for [2015](https://www.microsoft.com/en-us/download/details.aspx?id=52685)/[2017](https://aka.ms/vs/15/release/vc_redist.x64.exe)/[2019](https://aka.ms/vs/16/release/vc_redist.x64.exe) (you will get an error about MSVCP140.dll missing otherwise)
Once you have all this setup, you can use `lgb.dl` from `lgbdl` package to install LightGBM from repository. Once you have all this setup, you can use `lgb.dl` from `lgbdl` package to install LightGBM from repository.
......
...@@ -53,9 +53,9 @@ if (!use_precompile) { ...@@ -53,9 +53,9 @@ if (!use_precompile) {
} else { } else {
try_vs <- 0 try_vs <- 0
local_vs_def <- "" local_vs_def <- ""
vs_versions <- c("Visual Studio 15 2017 Win64", "Visual Studio 14 2015 Win64", "Visual Studio 16 2019") vs_versions <- c("Visual Studio 16 2019", "Visual Studio 15 2017", "Visual Studio 14 2015")
for(vs in vs_versions){ for(vs in vs_versions){
vs_def <- paste0(" -G \"", vs, "\"") vs_def <- paste0(" -G \"", vs, "\" -A x64")
tmp_cmake_cmd <- paste0(cmake_cmd, vs_def) tmp_cmake_cmd <- paste0(cmake_cmd, vs_def)
try_vs <- system(paste0(tmp_cmake_cmd, " ..")) try_vs <- system(paste0(tmp_cmake_cmd, " .."))
if (try_vs == 0) { if (try_vs == 0) {
......
...@@ -69,7 +69,7 @@ From Command Line ...@@ -69,7 +69,7 @@ From Command Line
cd LightGBM cd LightGBM
mkdir build mkdir build
cd build cd build
cmake -DCMAKE_GENERATOR_PLATFORM=x64 .. cmake -A x64 ..
cmake --build . --target ALL_BUILD --config Release cmake --build . --target ALL_BUILD --config Release
The ``.exe`` and ``.dll`` files will be in ``LightGBM/Release`` folder. The ``.exe`` and ``.dll`` files will be in ``LightGBM/Release`` folder.
...@@ -230,7 +230,7 @@ With GUI ...@@ -230,7 +230,7 @@ With GUI
If you have errors about **Platform Toolset**, go to ``PROJECT`` -> ``Properties`` -> ``Configuration Properties`` -> ``General`` and select the toolset installed on your machine. If you have errors about **Platform Toolset**, go to ``PROJECT`` -> ``Properties`` -> ``Configuration Properties`` -> ``General`` and select the toolset installed on your machine.
The exe file will be in ``LightGBM-master/windows/x64/Release`` folder. The ``.exe`` file will be in ``LightGBM-master/windows/x64/Release`` folder.
From Command Line From Command Line
----------------- -----------------
...@@ -245,10 +245,10 @@ From Command Line ...@@ -245,10 +245,10 @@ From Command Line
cd LightGBM cd LightGBM
mkdir build mkdir build
cd build cd build
cmake -DCMAKE_GENERATOR_PLATFORM=x64 -DUSE_OPENMP=OFF .. cmake -A x64 -DUSE_OPENMP=OFF ..
cmake --build . --target ALL_BUILD --config Release cmake --build . --target ALL_BUILD --config Release
The exe and dll files will be in ``LightGBM/Release`` folder. The ``.exe`` and ``.dll`` files will be in ``LightGBM/Release`` folder.
MinGW-w64 MinGW-w64
********* *********
...@@ -266,7 +266,7 @@ MinGW-w64 ...@@ -266,7 +266,7 @@ MinGW-w64
cmake -G "MinGW Makefiles" -DUSE_OPENMP=OFF .. cmake -G "MinGW Makefiles" -DUSE_OPENMP=OFF ..
mingw32-make.exe -j4 mingw32-make.exe -j4
The exe and dll files will be in ``LightGBM/`` folder. The ``.exe`` and ``.dll`` files will be in ``LightGBM/`` folder.
**Note**: You may need to run the ``cmake -G "MinGW Makefiles" -DUSE_OPENMP=OFF ..`` one more time if you encounter the ``sh.exe was found in your PATH`` error. **Note**: You may need to run the ``cmake -G "MinGW Makefiles" -DUSE_OPENMP=OFF ..`` one more time if you encounter the ``sh.exe was found in your PATH`` error.
...@@ -370,7 +370,7 @@ With GUI ...@@ -370,7 +370,7 @@ With GUI
If you have errors about **Platform Toolset**, go to ``PROJECT`` -> ``Properties`` -> ``Configuration Properties`` -> ``General`` and select the toolset installed on your machine. If you have errors about **Platform Toolset**, go to ``PROJECT`` -> ``Properties`` -> ``Configuration Properties`` -> ``General`` and select the toolset installed on your machine.
The exe file will be in ``LightGBM-master/windows/x64/Release_mpi`` folder. The ``.exe`` file will be in ``LightGBM-master/windows/x64/Release_mpi`` folder.
From Command Line From Command Line
***************** *****************
...@@ -387,10 +387,10 @@ From Command Line ...@@ -387,10 +387,10 @@ From Command Line
cd LightGBM cd LightGBM
mkdir build mkdir build
cd build cd build
cmake -DCMAKE_GENERATOR_PLATFORM=x64 -DUSE_MPI=ON .. cmake -A x64 -DUSE_MPI=ON ..
cmake --build . --target ALL_BUILD --config Release cmake --build . --target ALL_BUILD --config Release
The exe and dll files will be in ``LightGBM/Release`` folder. The ``.exe`` and ``.dll`` files will be in ``LightGBM/Release`` folder.
**Note**: Building MPI version by **MinGW** is not supported due to the miss of MPI library in it. **Note**: Building MPI version by **MinGW** is not supported due to the miss of MPI library in it.
...@@ -555,7 +555,9 @@ Following procedure is for the **MSVC** (Microsoft Visual C++) build. ...@@ -555,7 +555,9 @@ Following procedure is for the **MSVC** (Microsoft Visual C++) build.
Visual Studio 2015 -> ``msvc-14.0-64.exe``, Visual Studio 2015 -> ``msvc-14.0-64.exe``,
Visual Studio 2017 -> ``msvc-14.1-64.exe``. Visual Studio 2017 -> ``msvc-14.1-64.exe``,
Visual Studio 2019 -> ``msvc-14.2-64.exe``.
4. Run the following commands: 4. Run the following commands:
...@@ -567,7 +569,7 @@ Following procedure is for the **MSVC** (Microsoft Visual C++) build. ...@@ -567,7 +569,7 @@ Following procedure is for the **MSVC** (Microsoft Visual C++) build.
cd LightGBM cd LightGBM
mkdir build mkdir build
cd build cd build
cmake -DCMAKE_GENERATOR_PLATFORM=x64 -DUSE_GPU=1 .. cmake -A x64 -DUSE_GPU=1 ..
cmake --build . --target ALL_BUILD --config Release cmake --build . --target ALL_BUILD --config Release
**Note**: ``C:\local\boost_1_63_0\`` and ``C:\local\boost_1_63_0\lib64-msvc-14.0`` are locations of your **Boost** binaries (assuming you've downloaded 1.63.0 version). You also can set them to the environment variable to avoid ``Set ...`` commands when build. **Note**: ``C:\local\boost_1_63_0\`` and ``C:\local\boost_1_63_0\lib64-msvc-14.0`` are locations of your **Boost** binaries (assuming you've downloaded 1.63.0 version). You also can set them to the environment variable to avoid ``Set ...`` commands when build.
...@@ -629,10 +631,10 @@ VS Build Tools ...@@ -629,10 +631,10 @@ VS Build Tools
cd LightGBM cd LightGBM
mkdir build mkdir build
cd build cd build
cmake -DCMAKE_GENERATOR_PLATFORM=x64 -DUSE_SWIG=ON .. cmake -A x64 -DUSE_SWIG=ON ..
cmake --build . --target ALL_BUILD --config Release cmake --build . --target ALL_BUILD --config Release
The jar file will be in ``LightGBM/build`` folder and the dll files will be in ``LightGBM/Release`` folder. The ``.jar`` file will be in ``LightGBM/build`` folder and the ``.dll`` files will be in ``LightGBM/Release`` folder.
MinGW-w64 MinGW-w64
********* *********
...@@ -652,7 +654,7 @@ MinGW-w64 ...@@ -652,7 +654,7 @@ MinGW-w64
cmake -G "MinGW Makefiles" -DUSE_SWIG=ON .. cmake -G "MinGW Makefiles" -DUSE_SWIG=ON ..
mingw32-make.exe -j4 mingw32-make.exe -j4
The jar file will be in ``LightGBM/build`` folder and the dll files will be in ``LightGBM/`` folder. The ``.jar`` file will be in ``LightGBM/build`` folder and the ``.dll`` files will be in ``LightGBM/`` folder.
**Note**: You may need to run the ``cmake -G "MinGW Makefiles" -DUSE_SWIG=ON ..`` one more time if you encounter the ``sh.exe was found in your PATH`` error. **Note**: You may need to run the ``cmake -G "MinGW Makefiles" -DUSE_SWIG=ON ..`` one more time if you encounter the ``sh.exe was found in your PATH`` error.
......
...@@ -16,7 +16,7 @@ Preparation ...@@ -16,7 +16,7 @@ Preparation
Install from `PyPI <https://pypi.org/project/lightgbm>`_ Using ``pip`` Install from `PyPI <https://pypi.org/project/lightgbm>`_ Using ``pip``
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
For **Windows** users, `VC runtime <https://go.microsoft.com/fwlink/?LinkId=746572>`_ is needed if **Visual Studio** (2015 or newer) is not installed. For **Windows** users, `VC runtime <https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads>`_ is needed if **Visual Studio** (2015 or newer) is not installed.
For **Linux** users, **glibc** >= 2.14 is required. For **Linux** users, **glibc** >= 2.14 is required.
...@@ -28,7 +28,7 @@ For **macOS** users: ...@@ -28,7 +28,7 @@ For **macOS** users:
- For version smaller than 2.1.2, **gcc-7** with **OpenMP** is required. - For version smaller than 2.1.2, **gcc-7** with **OpenMP** is required.
Install `wheel <http://pythonwheels.com>`_ via ``pip install wheel`` first. After that download the wheel file and install from it: Install `wheel <https://pythonwheels.com>`_ via ``pip install wheel`` first. After that download the wheel file and install from it:
.. code:: sh .. code:: sh
......
...@@ -136,7 +136,7 @@ def compile_cpp(use_mingw=False, use_gpu=False, use_mpi=False, nomp=False, ...@@ -136,7 +136,7 @@ def compile_cpp(use_mingw=False, use_gpu=False, use_mpi=False, nomp=False,
lib_path = os.path.join(CURRENT_DIR, "compile", "windows", "x64", "DLL", "lib_lightgbm.dll") lib_path = os.path.join(CURRENT_DIR, "compile", "windows", "x64", "DLL", "lib_lightgbm.dll")
if not any((use_gpu, use_mpi, use_hdfs)): if not any((use_gpu, use_mpi, use_hdfs)):
logger.info("Starting to compile with MSBuild from existing solution file.") logger.info("Starting to compile with MSBuild from existing solution file.")
platform_toolsets = ("v141", "v140", "v142") platform_toolsets = ("v142", "v141", "v140")
for pt in platform_toolsets: for pt in platform_toolsets:
status = silent_call(["MSBuild", status = silent_call(["MSBuild",
os.path.join(CURRENT_DIR, "compile", "windows", "LightGBM.sln"), os.path.join(CURRENT_DIR, "compile", "windows", "LightGBM.sln"),
...@@ -150,10 +150,10 @@ def compile_cpp(use_mingw=False, use_gpu=False, use_mpi=False, nomp=False, ...@@ -150,10 +150,10 @@ def compile_cpp(use_mingw=False, use_gpu=False, use_mpi=False, nomp=False,
if status != 0 or not os.path.exists(lib_path): if status != 0 or not os.path.exists(lib_path):
logger.warning("Compilation with MSBuild from existing solution file failed.") logger.warning("Compilation with MSBuild from existing solution file failed.")
if status != 0 or not os.path.exists(lib_path): if status != 0 or not os.path.exists(lib_path):
vs_versions = ("Visual Studio 15 2017 Win64", "Visual Studio 14 2015 Win64", "Visual Studio 16 2019") vs_versions = ("Visual Studio 16 2019", "Visual Studio 15 2017", "Visual Studio 14 2015")
for vs in vs_versions: for vs in vs_versions:
logger.info("Starting to compile with %s." % vs) logger.info("Starting to compile with %s." % vs)
status = silent_call(cmake_cmd + ["-G", vs]) status = silent_call(cmake_cmd + ["-G", vs, "-A", "x64"])
if status == 0: if status == 0:
break break
else: else:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment