Move MinGW-w64 + Python section to the end, since it's 'advanced' (#3863)

This commit is contained in:
Philip Hyunsu Cho 2018-11-04 05:12:27 -08:00 committed by GitHub
parent a650131fc3
commit 6da462234e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -161,23 +161,7 @@ To build with MinGW, type:
cp make/mingw64.mk config.mk; make -j4 cp make/mingw64.mk config.mk; make -j4
Building XGBoost library for python for Windows with MinGW-w64 See :ref:`_mingw_python` for buildilng XGBoost for Python.
--------------------------------------------------------------
Windows versions of python are built with Microsoft Visual Studio. Usually python binary modules are built with the same compiler the interpreter is built with, raising several potential concerns.
1. VS is proprietary and commercial software. Microsoft provides a freeware "Community" edition, but its licensing terms are unsuitable for many organizations.
2. Visual Studio contains telemetry, as documented in `Microsoft Visual Studio Licensing Terms <https://visualstudio.microsoft.com/license-terms/mt736442/>`_. It `has been inserting telemetry <https://old.reddit.com/r/cpp/comments/4ibauu/visual_studio_adding_telemetry_function_calls_to/>`_ into apps for some time. In order to download VS distribution from MS servers one has to run the application containing telemetry. These facts have raised privacy and security concerns among some users and system administrators. Running software with telemetry may be against the policy of your organization.
3. g++ usually generates faster code on ``-O3``.
So you may want to build XGBoost with g++ own your own risk. This opens a can of worms, because MSVC uses Microsoft runtime and MinGW-w64 uses own runtime, and the runtimes have different incompatible memory allocators. But in fact this setup is usable if you know how to deal with it. Here is some experience.
1. The python interpreter will crash on exit if XGBoost was used. This is usually not a big issue.
2. ``-O3`` is OK.
3. ``-mtune=native`` is also OK.
4. Don't use ``-march=native`` gcc flag. Using it causes the python interpreter to crash if the dll was actually used.
5. You may need to provide the lib with the runtime libs. If ``mingw32/bin`` is not in ``PATH``, build a wheel (``python setup.py bdist_wheel``), open it with an archiver and put the needed dlls to the directory where ``xgboost.dll`` is situated. Then you can install the wheel with ``pip``.
Compile XGBoost with Microsoft Visual Studio Compile XGBoost with Microsoft Visual Studio
-------------------------------------------- --------------------------------------------
@ -269,7 +253,7 @@ Alternatively, use CMake.
Python Package Installation Python Package Installation
=========================== ===========================
The python package is located at ``python-package/``. The Python package is located at ``python-package/``.
There are several ways to install the package: There are several ways to install the package:
1. Install system-wide, which requires root permission: 1. Install system-wide, which requires root permission:
@ -279,7 +263,7 @@ There are several ways to install the package:
cd python-package; sudo python setup.py install cd python-package; sudo python setup.py install
You will however need Python ``distutils`` module for this to You will however need Python ``distutils`` module for this to
work. It is often part of the core python package or it can be installed using your work. It is often part of the core Python package or it can be installed using your
package manager, e.g. in Debian use package manager, e.g. in Debian use
.. code-block:: bash .. code-block:: bash
@ -290,7 +274,7 @@ package manager, e.g. in Debian use
If you recompiled XGBoost, then you need to reinstall it again to make the new library take effect. If you recompiled XGBoost, then you need to reinstall it again to make the new library take effect.
2. Only set the environment variable ``PYTHONPATH`` to tell python where to find 2. Only set the environment variable ``PYTHONPATH`` to tell Python where to find
the library. For example, assume we cloned `xgboost` on the home directory the library. For example, assume we cloned `xgboost` on the home directory
`~`. then we can added the following line in `~/.bashrc`. `~`. then we can added the following line in `~/.bashrc`.
This option is **recommended for developers** who change the code frequently. The changes will be immediately reflected once you pulled the code and rebuild the project (no need to call ``setup`` again) This option is **recommended for developers** who change the code frequently. The changes will be immediately reflected once you pulled the code and rebuild the project (no need to call ``setup`` again)
@ -312,6 +296,25 @@ package manager, e.g. in Debian use
import os import os
os.environ['PATH'] = os.environ['PATH'] + ';C:\\Program Files\\mingw-w64\\x86_64-5.3.0-posix-seh-rt_v4-rev0\\mingw64\\bin' os.environ['PATH'] = os.environ['PATH'] + ';C:\\Program Files\\mingw-w64\\x86_64-5.3.0-posix-seh-rt_v4-rev0\\mingw64\\bin'
.. _mingw_python:
Building XGBoost library for Python for Windows with MinGW-w64
--------------------------------------------------------------
Windows versions of Python are built with Microsoft Visual Studio. Usually Python binary modules are built with the same compiler the interpreter is built with, raising several potential concerns.
1. VS is proprietary and commercial software. Microsoft provides a freeware "Community" edition, but its licensing terms are unsuitable for many organizations.
2. Visual Studio contains telemetry, as documented in `Microsoft Visual Studio Licensing Terms <https://visualstudio.microsoft.com/license-terms/mt736442/>`_. It `has been inserting telemetry <https://old.reddit.com/r/cpp/comments/4ibauu/visual_studio_adding_telemetry_function_calls_to/>`_ into apps for some time. In order to download VS distribution from MS servers one has to run the application containing telemetry. These facts have raised privacy and security concerns among some users and system administrators. Running software with telemetry may be against the policy of your organization.
3. g++ usually generates faster code on ``-O3``.
So you may want to build XGBoost with g++ own your own risk. This opens a can of worms, because MSVC uses Microsoft runtime and MinGW-w64 uses own runtime, and the runtimes have different incompatible memory allocators. But in fact this setup is usable if you know how to deal with it. Here is some experience.
1. The Python interpreter will crash on exit if XGBoost was used. This is usually not a big issue.
2. ``-O3`` is OK.
3. ``-mtune=native`` is also OK.
4. Don't use ``-march=native`` gcc flag. Using it causes the Python interpreter to crash if the dll was actually used.
5. You may need to provide the lib with the runtime libs. If ``mingw32/bin`` is not in ``PATH``, build a wheel (``python setup.py bdist_wheel``), open it with an archiver and put the needed dlls to the directory where ``xgboost.dll`` is situated. Then you can install the wheel with ``pip``.
R Package Installation R Package Installation
====================== ======================