Build

This section covers building the pyRat pyrat Python module and its Python wheels.

A wheel is a single .whl file that pip installs into any environment of a matching platform and Python version, without compiling anything:

python -m pip install ./pyrat-2.0.1-cp314-cp314-win_amd64.whl

Its name tells what it was built for, here:

  • pyRat 2.0.1

  • CPython 3.14 (cp314)

  • Windows on x86-64 (win_amd64)

numpy is its only Python dependency. The wheel is self-contained: it ships the Rat C++ libraries and everything they link (vcpkg libraries, MKL, the CUDA runtime and cuBLAS), so the machine that installs it needs neither Rat nor the CUDA Toolkit, only an NVIDIA driver recent enough for the CUDA version the wheel was built with. These libraries make it large: about 540 MB for a Windows wheel with CUDA 13 and MKL.

Note

Wheels are built with CUDA only for now: RAT’s MLFMM runs on the GPU, and pyrat --version shows the CUDA major version a wheel was built with.

Build in three steps

scripts/build_wheel.py (Scripts) chains them:

  1. Build: uv build runs scikit-build-core, which configures and builds the CMake project in an isolated environment for the requested Python version, in build/<wheel tag> (one build tree per Python version, kept between runs). With stubs requested, CMake also generates the .pyi files and installs them into the wheel. The result only holds pyRat itself: it is not portable yet.

  2. Repair: a platform tool copies the libraries the module needs into the wheel: delvewheel on Windows, auditwheel on Linux, delocate on macOS. CMake writes where these libraries are into build/<wheel tag>/pyrat_runtime.json.

  3. Check: the repaired wheel is installed and imported in a fresh environment, away from the build’s libraries.

Important

Only Windows has been built and tested so far (rat-all v3.004.5, MSVC, vcpkg, MKL, CUDA 13). The Linux and macOS paths of the script are written but have not been run yet.

Manual build describes what the script does underneath, the CMake options of the project, and how a superbuild uses it.