Building Kamayan
This guide covers how to obtain, configure, and build kamayan from source.
Requirements
Kamayan has the following dependencies:
- UV - Python package manager (required for testing, recommended for all builds)
- CMake 3.25 or higher
- C++ Compiler with C++20 support
- HDF5 - For I/O operations
- MPI - Message Passing Interface implementation (OpenMPI, MPICH, Intel MPI, or compatible)
Installing UV
UV is used to manage Python dependencies for kamayan's tooling and bindings. Install it with:
For other installation methods, see the UV documentation.
Getting the Source
Clone the kamayan repository and initialize its submodules (Parthenon, singularity-eos, and nanobind):
CMake Build Options
Kamayan provides several CMake options to control the build:
| Option | Description | Default |
|---|---|---|
kamayan_ENABLE_TESTING |
Enable kamayan test suite (requires UV) | ON |
kamayan_BUILD_DOCS |
Build the kamayan documentation | OFF |
kamayan_BUILD_PYKAMAYAN |
Build Python bindings (pyKamayan) | ON |
KAMAYAN_ENSURE_MPI4PY |
Automatically rebuild mpi4py when MPI mismatch detected | OFF |
kamayan_NP_TESTING |
Number of MPI ranks to use in testing | 2 |
KAMAYAN_VERBOSE_MPI_CHECK |
Enable verbose MPI compatibility checking | OFF |
Additional Parthenon and singularity-eos options are also available. See their respective documentation for details.
Building Kamayan
Standard Build (with Python bindings)
Create a build directory and configure the project:
If UV is installed, you can prefix the cmake commands with uv run to ensure consistency:
This will build:
- The core kamayan library
- Python bindings (pyKamayan)
- Example problems in
src/problems/(see Setting up a Simulation)
C++ Only Build
To build without Python bindings:
Build with Testing Disabled
If UV is not available and you don't need tests:
Note
Disabling testing also disables the documentation build, as docs require the test infrastructure.
Build Types
Kamayan defaults to Release build. To change the build type:
cmake -DCMAKE_BUILD_TYPE=Debug .. # Debug build with symbols
cmake -DCMAKE_BUILD_TYPE=Release .. # Optimized release build (default)
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo .. # Release with debug info
Running a Simulation
After building, you can run one of the example problems:
For information on creating your own simulations, see Setting up a Simulation.
Troubleshooting
MPI/mpi4py Compatibility
Kamayan verifies that the MPI implementation used by mpi4py matches the one discovered by CMake. If there's a mismatch, you'll see an error like:
Solutions:
-
Automatic rebuild (recommended): Reconfigure with
This will automatically rebuild mpi4py with the correct MPI implementation.KAMAYAN_ENSURE_MPI4PY=ON: -
Manual rebuild: Use the provided target:
-
Install matching mpi4py: Install mpi4py manually with your MPI compiler wrappers:
UV Not Found Warnings
If you see warnings about UV not being found:
- For testing: UV is required. Install it from https://docs.astral.sh/uv/ or disable testing with
-Dkamayan_ENABLE_TESTING=OFF - For Python bindings: Install UV or disable bindings with
-Dkamayan_BUILD_PYKAMAYAN=OFF - For docs: Install UV or disable docs with
-Dkamayan_BUILD_DOCS=OFF
Submodules Not Initialized
If you see errors about missing Parthenon or other dependencies:
Python Module Not Found
If you encounter Python import errors when running simulations with pyKamayan, ensure you're using UV to manage the environment:
Or activate the UV-managed environment explicitly.
Building Documentation
To build the kamayan documentation (requires UV and testing enabled):
This will start a python server for the docs, and should give a local url that will dynamically serve the docs for development.
Advanced Build Options
Specifying MPI Implementation
If CMake doesn't find the correct MPI implementation:
Custom HDF5 Location
If HDF5 is installed in a non-standard location:
Parallel Build
Speed up compilation by using more parallel jobs: