Scripts¶
pyrat/scripts/build_wheel.py builds a portable wheel in one command, on every platform: build, repair, check (see Build).
Important
Tested on Windows only (rat-all v3.004.5, MSVC, vcpkg, MKL, CUDA 13). The Linux (auditwheel) and macOS (delocate) paths are written but have not been run yet.
Requirements¶
UV on
PATH: it runs the script, the build and the repair tools, with the Python versions they need.RAT built and installed, from one of the three sources below.
On Windows: an MSVC developer shell. With RAT linking Intel oneAPI MKL, load oneAPI’s environment first (
setvars.bat, or setMKLROOT).
See Setup for the versions required.
Run¶
From a clone of the pyRat repository:
git clone https://gitlab.com/project-rat-extras/pyrat.git
cd pyrat
The script only needs Python’s standard library and
pefile (read on Windows), which uv run installs.
Pick where RAT comes from:
# A rat-all build (configured, built and installed)
uv run scripts/build_wheel.py --rat-all C:\path\to\rat-all\build -p 3.14 --stubs
# A vcpkg installation in classic mode (root given, VCPKG_ROOT, or vcpkg on PATH)
uv run scripts/build_wheel.py --vcpkg --triplet x64-linux-dynamic-release -p 3.13
# RAT installed under a prefix, its dependencies found by CMake
uv run scripts/build_wheel.py --prefix /opt/rat -p 3.13
The wheel ends up in wheelhouse/.
Options¶
Option |
Meaning |
|---|---|
|
A rat-all build directory. Its |
|
A vcpkg installation in classic mode, with RAT installed in it or
under |
|
RAT installed under |
|
Where RAT is installed: overrides rat-all’s install prefix, or tells
|
|
vcpkg triplet for |
|
Python version of the wheel. Default: the Python running the script. |
|
Generate the |
|
Extra CMake definition, repeatable (e.g. |
|
Output directory. Default: |
|
Keep the wheel as built: not portable, and not checked. |
|
Skip the import check. |
uv run scripts/build_wheel.py --help prints the same list.
What it does¶
Build:
uv build --wheelfor the requested Python, with Ninja as the default CMake generator (CMAKE_GENERATORoverrides it). CMake only compiles pyRat’s sources, RAT is linked, inbuild/<wheel tag>: a later build for the same Python only recompiles what changed.CUDA version (Windows): read from the CUDA runtime that RAT’s DLLs import (
cudart64_13.dllgives13), since RAT’s CMake package does not tell. Elsewhere it comes from rat-all’sRAT_ALL_ENABLE_CUDA.-D PYRAT2_CUDA_VERSION=...overrides both. The wheel reports it inpyrat --versionandpyrat.meta.CUDA_VERSION.Repair: delvewheel, auditwheel or delocate, run with
uvx, bundle the libraries found in the directories listed bybuild/<wheel tag>/pyrat_runtime.json: RAT, vcpkg, CUDA and MKL. On Windows with MKL from oneAPI, MKL’s CPU kernels (mkl_def,mkl_avx2, …), which MKL loads by name at runtime and no tool can see, are added explicitly, and the MKL DLL names are kept as they are so that they still find each other.Check: the wheel must contain the examples (and the stubs, with
--stubs); it is then imported in a fresh environment without the build’s library directories, printing the pyRat, RAT and CUDA versions compiled into the module.