Skip to content

Commit

Permalink
[python][R][docs][ci] better compatibility with Visual Studio 2019 (#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
StrikerRUS committed Apr 29, 2019
1 parent de82ed5 commit 8d2ec69
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .ci/test_windows.ps1
Expand Up @@ -10,7 +10,7 @@ $env:PATH += ";$env:CONDA_PREFIX\Library\bin\graphviz" # temp graphviz hotfix

if ($env:TASK -eq "regular") {
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
python setup.py install --precompile ; Check-Output $?
cp $env:BUILD_SOURCESDIRECTORY/Release/lib_lightgbm.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY
Expand Down
2 changes: 1 addition & 1 deletion R-package/README.md
Expand Up @@ -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):

* 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.

Expand Down
4 changes: 2 additions & 2 deletions R-package/src/install.libs.R
Expand Up @@ -53,9 +53,9 @@ if (!use_precompile) {
} else {
try_vs <- 0
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){
vs_def <- paste0(" -G \"", vs, "\"")
vs_def <- paste0(" -G \"", vs, "\" -A x64")
tmp_cmake_cmd <- paste0(cmake_cmd, vs_def)
try_vs <- system(paste0(tmp_cmake_cmd, " .."))
if (try_vs == 0) {
Expand Down
28 changes: 15 additions & 13 deletions docs/Installation-Guide.rst
Expand Up @@ -69,7 +69,7 @@ From Command Line
cd LightGBM
mkdir build
cd build
cmake -DCMAKE_GENERATOR_PLATFORM=x64 ..
cmake -A x64 ..
cmake --build . --target ALL_BUILD --config Release
The ``.exe`` and ``.dll`` files will be in ``LightGBM/Release`` folder.
Expand Down Expand Up @@ -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.

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
-----------------
Expand All @@ -245,10 +245,10 @@ From Command Line
cd LightGBM
mkdir build
cd build
cmake -DCMAKE_GENERATOR_PLATFORM=x64 -DUSE_OPENMP=OFF ..
cmake -A x64 -DUSE_OPENMP=OFF ..
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
*********
Expand All @@ -266,7 +266,7 @@ MinGW-w64
cmake -G "MinGW Makefiles" -DUSE_OPENMP=OFF ..
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.

Expand Down Expand Up @@ -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.

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
*****************
Expand All @@ -387,10 +387,10 @@ From Command Line
cd LightGBM
mkdir build
cd build
cmake -DCMAKE_GENERATOR_PLATFORM=x64 -DUSE_MPI=ON ..
cmake -A x64 -DUSE_MPI=ON ..
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.

Expand Down Expand Up @@ -555,7 +555,9 @@ Following procedure is for the **MSVC** (Microsoft Visual C++) build.

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:

Expand All @@ -567,7 +569,7 @@ Following procedure is for the **MSVC** (Microsoft Visual C++) build.
cd LightGBM
mkdir build
cd build
cmake -DCMAKE_GENERATOR_PLATFORM=x64 -DUSE_GPU=1 ..
cmake -A x64 -DUSE_GPU=1 ..
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.
Expand Down Expand Up @@ -629,10 +631,10 @@ VS Build Tools
cd LightGBM
mkdir build
cd build
cmake -DCMAKE_GENERATOR_PLATFORM=x64 -DUSE_SWIG=ON ..
cmake -A x64 -DUSE_SWIG=ON ..
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
*********
Expand All @@ -652,7 +654,7 @@ MinGW-w64
cmake -G "MinGW Makefiles" -DUSE_SWIG=ON ..
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.

Expand Down
4 changes: 2 additions & 2 deletions python-package/README.rst
Expand Up @@ -16,7 +16,7 @@ Preparation
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.

Expand All @@ -28,7 +28,7 @@ For **macOS** users:

- 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
Expand Down
6 changes: 3 additions & 3 deletions python-package/setup.py
Expand Up @@ -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")
if not any((use_gpu, use_mpi, use_hdfs)):
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:
status = silent_call(["MSBuild",
os.path.join(CURRENT_DIR, "compile", "windows", "LightGBM.sln"),
Expand All @@ -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):
logger.warning("Compilation with MSBuild from existing solution file failed.")
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:
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:
break
else:
Expand Down

0 comments on commit 8d2ec69

Please sign in to comment.