---
metadata:
  - name: generator
    content: Diplodoc Platform v5.50.3
alternate:
  - https://catboost.ai/docs/en/installation/python-installation-method-build-from-source-windows-using-ya-make.md
---
> **Documentation Index:** Fetch the complete configuration index at https://catboost.ai/docs/en/llms.txt

# Build Python package from source on Windows using Ya Make


{% note info %}

<!-- source: en/_includes/work_src/reusage-installation/ya-make-to-cmake-switch.md -->
CatBoost uses [CMake](https://cmake.org/)-based build process since [this commit](https://github.com/catboost/catboost/commit/c5c642ca0b8e093336d0229ac4b14c78db3915bb). Previously `Ya Make` (Yandex's build system) had been used.
<!-- endsource: en/_includes/work_src/reusage-installation/ya-make-to-cmake-switch.md -->

This page describes building using Ya Make. For building using CMake see [documentation here](https://catboost.ai/docs/en/installation/python-installation-method-build-from-source.md).

{% endnote %}

<!-- source: en/_includes/work_src/reusage-code-examples/cuda-toolkit__compatible-system-compilers.md -->
The system compiler must be compatible with CUDA Toolkit if GPU support is required. Refer to the [Supported Host Compilers](https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/#supported-host-compilers) section of the [NVIDIA CUDA Compiler Driver NVCC](https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html) documentation for more details. The required steps to change the system compiler depend on the OS.
<!-- endsource: en/_includes/work_src/reusage-code-examples/cuda-toolkit__compatible-system-compilers.md -->

<!-- source: en/_includes/work_src/reusage-code-examples/nvidia-driver-reqs.md -->
Training or inference on CUDA-enabled GPUs requires NVIDIA Driver of version 450.80.02 or higher.
<!-- endsource: en/_includes/work_src/reusage-code-examples/nvidia-driver-reqs.md -->

## [Environment setup](https://catboost.ai/docs/en/installation/build-environment-setup-for-ya-make.md)

## Building steps

1. Open the `catboost/catboost/python-package/catboost` directory from the local copy of the CatBoost repository.

1. <!-- source: en/_includes/work_src/reusage-code-examples/compile-the-library.md -->
   Compile the packages using one of the following methods:
   - Use one of the Python versions provided by the `ya make` utility:

       ```bash
       ../../../ya make -r -DUSE_ARCADIA_PYTHON=no -DUSE_SYSTEM_PYTHON=<Python version> [optional parameters]
       ```

   - Use one of the Python versions installed on the machine:

       ```python
       ../../../ya make -r -DUSE_ARCADIA_PYTHON=no -DOS_SDK=local -DPYTHON_CONFIG=<path to the required python-config> [optional parameters]
       ```

   <table>
     <tr>
       <th>Parameter</th>
       <th>Description</th>
     </tr>
     <tr>
       <td colspan="2"><b>Parameters that define the Python version to use for compiling. Only one of the following blocks of options can be used at a time</b></td>
     </tr>
     <tr>
       <td colspan="2">Use one of the Python versions provided by the <code>ya make</code> utility</td>
     </tr>
     <tr>
        <td><code>-DUSE_SYSTEM_PYTHON</code></td><td>The version of Python to use for compiling the package on machines without installed Python.

   The following Python versions are supported and can be defined as values for this parameter:
   - 2.7
   - 3.4
   - 3.5
   - 3.6</td>
     </tr>
     <tr>
       <td colspan="2">Use one of the Python versions installed on the machine</td>
     </tr>
     <tr>
        <td><code>-DPYTHON_CONFIG</code></td><td>Defines the path to the configuration of an installed Python version to use for compiling the package.

   Value examples:
   - <code>python2-config</code> for Python 2
   - <code>python3-config</code> for Python 3
   - <code>/usr/bin/python2.7-config</code>

   <note type="attention">

   - The configuration must be explicitly named <code>python3-config</code> to successfully build the package for Python 3.
   - Manually redefine the following variables when encountering problems with the Python configuration:
       - <code>-DPYTHON_INCLUDE</code>
       - <code>-DPYTHON_LIBRARIES</code>
       - <code>-DPYTHON_LDFLAGS</code>
       - <code>-DPYTHON_FLAGS</code>
       - <code>-DPYTHON_BIN</code>

   </note></td>
     </tr>
     <tr>
       <td colspan="2"><b>Optional parameters</b></td>
     </tr>
     <tr>
        <td><code>-DCUDA_ROOT</code></td><td>The path to CUDA. This parameter is required to support training on GPU.</td>
     </tr>
     <tr>
        <td><code>-DHAVE_CUDA=no</code></td><td>Disable CUDA support. This speeds up compilation.

   By default, the package is built with CUDA support if CUDA Toolkit is installed.</td>
     </tr>
     <tr>
        <td><code>-o</code></td><td>The directory to output the compiled package to. By default, the current directory is used.</td>
     </tr>
   </table>
   <!-- endsource: en/_includes/work_src/reusage-code-examples/compile-the-library.md -->

    <!-- source: en/_includes/work_src/reusage-code-examples/installation-example.md -->
    For example, the following command builds the package for Python 3 with training on GPU support:
    ```no-highlight
    ../../../ya make -r -DUSE_ARCADIA_PYTHON=no -DOS_SDK=local -DPYTHON_CONFIG=python3-config -DCUDA_ROOT=/usr/local/cuda
    ```
    <!-- endsource: en/_includes/work_src/reusage-code-examples/installation-example.md -->

    {% note info %}

    Explicitly specify the `PYTHON_INCLUDE` and `PYTHON_LIBRARIES` variables:
    ```
    ../../../ya make -r -DUSE_ARCADIA_PYTHON=no -DOS_SDK=local -DPYTHON_INCLUDE="/I C:/Python27/include/" -DPYTHON_LIBRARIES="C:/Python27/libs/python27.lib"
    ```

    {% endnote %}
