You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Create pyproject.toml
* Implement a custom build backend (see below) in packager directory. Build logic from setup.py has been refactored and migrated into the new backend.
* Tested: pip wheel . (build wheel), python -m build --sdist . (source distribution)
Copy file name to clipboardExpand all lines: doc/build.rst
+65-71Lines changed: 65 additions & 71 deletions
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,7 @@ systems. If the instructions do not work for you, please feel free to ask quest
12
12
Consider installing XGBoost from a pre-built binary, to avoid the trouble of building XGBoost from the source. Checkout :doc:`Installation Guide </install>`.
13
13
14
14
.. contents:: Contents
15
+
:local:
15
16
16
17
.. _get_source:
17
18
@@ -152,11 +153,11 @@ On Windows, run CMake as follows:
152
153
153
154
mkdir build
154
155
cd build
155
-
cmake .. -G"Visual Studio 14 2015 Win64" -DUSE_CUDA=ON
156
+
cmake .. -G"Visual Studio 17 2022" -A x64 -DUSE_CUDA=ON
156
157
157
158
(Change the ``-G`` option appropriately if you have a different version of Visual Studio installed.)
158
159
159
-
The above cmake configuration run will create an ``xgboost.sln`` solution file in the build directory. Build this solution in release mode as a x64 build, either from Visual studio or from command line:
160
+
The above cmake configuration run will create an ``xgboost.sln`` solution file in the build directory. Build this solution in Release mode, either from Visual studio or from command line:
160
161
161
162
.. code-block:: bash
162
163
@@ -176,110 +177,103 @@ Building Python Package with Default Toolchains
176
177
===============================================
177
178
There are several ways to build and install the package from source:
178
179
179
-
1. Use Python setuptools directly
180
+
1. Build C++ core with CMake first
180
181
181
-
The XGBoost Python package supports most of the setuptools commands, here is a list of tested commands:
182
+
You can first build C++ library using CMake as described in :ref:`build_shared_lib`.
183
+
After compilation, a shared library will appear in ``lib/`` directory.
184
+
On Linux distributions, the shared library is ``lib/libxgboost.so``.
185
+
The install script ``pip install .`` will reuse the shared library instead of compiling
186
+
it from scratch, making it quite fast to run.
182
187
183
-
.. code-block:: bash
184
-
185
-
python setup.py install # Install the XGBoost to your current Python environment.
186
-
python setup.py build # Build the Python package.
187
-
python setup.py build_ext # Build only the C++ core.
188
-
python setup.py sdist # Create a source distribution
189
-
python setup.py bdist # Create a binary distribution
190
-
python setup.py bdist_wheel # Create a binary distribution with wheel format
191
-
192
-
Running ``python setup.py install`` will compile XGBoost using default CMake flags. For
193
-
passing additional compilation options, append the flags to the command. For example,
194
-
to enable CUDA acceleration and NCCL (distributed GPU) support:
195
-
196
-
.. code-block:: bash
188
+
.. code-block:: console
197
189
198
-
python setup.py install --use-cuda --use-nccl
190
+
$ cd python-package/
191
+
$ pip install . # Will re-use lib/libxgboost.so
199
192
200
-
Please refer to ``setup.py`` for a complete list of available options. Some other
201
-
options used for development are only available for using CMake directly. See next
202
-
section on how to use CMake with setuptools manually.
193
+
2. Install the Python package directly
203
194
204
-
You can install the created distribution packages using pip. For example, after running
205
-
``sdist`` setuptools command, a tar ball similar to ``xgboost-1.0.0.tar.gz`` will be
206
-
created under the ``dist`` directory. Then you can install it by invoking the following
207
-
command under ``dist`` directory:
195
+
You can navigate to ``python-package/`` directory and install the Python package directly
196
+
by running
208
197
209
-
.. code-block:: bash
198
+
.. code-block:: console
210
199
211
-
# under python-package directory
212
-
cd dist
213
-
pip install ./xgboost-1.0.0.tar.gz
200
+
$ cd python-package/
201
+
$ pip install -v .
214
202
203
+
which will compile XGBoost's native (C++) code using default CMake flags.
204
+
To enable additional compilation options, pass corresponding ``--config-settings``:
215
205
216
-
For details about these commands, please refer to the official document of `setuptools
217
-
<https://setuptools.readthedocs.io/en/latest/>`_, or just Google "how to install Python
218
-
package from source". XGBoost Python package follows the general convention.
219
-
Setuptools is usually available with your Python distribution, if not you can install it
220
-
via system command. For example on Debian or Ubuntu:
See :doc:`contrib/python_packaging` for instructions on packaging
276
+
and distributing XGBoost as Python distributions.
283
277
284
278
.. _python_mingw:
285
279
@@ -297,7 +291,7 @@ So you may want to build XGBoost with GCC own your own risk. This presents some
297
291
2. ``-O3`` is OK.
298
292
3. ``-mtune=native`` is also OK.
299
293
4. Don't use ``-march=native`` gcc flag. Using it causes the Python interpreter to crash if the DLL was actually used.
300
-
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``.
294
+
5. You may need to provide the lib with the runtime libs. If ``mingw32/bin`` is not in ``PATH``, build a wheel (``pip 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``.
0 commit comments