Skip to content

Commit

Permalink
#16: bindings: Update README to describe python binding build
Browse files Browse the repository at this point in the history
  • Loading branch information
pierrepebay committed Nov 23, 2023
1 parent eea2cc7 commit 6c2f729
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 4 deletions.
41 changes: 40 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,43 @@ using Paraview. Additionally, the task visualizer can produce PNGs
directly using a VTK workflow to render a visualization of ranks and
tasks over phases.

![Example Output PNG](./docs/example-output-image.png)
![Example Output PNG](./docs/example-output-image.png)

## Building the Python bindings

###Requirements

In order to build the python bindings, make sure you have a Python <ins>`3.8` or `3.9`</ins> environment, with the `nanobind` package installed. You can install `nanobind` with `pip`:

```bash
pip install nanobind
```

You must have a C++ compiler that supports C++17, and `cmake` >= 3.17.

Finally, you must have a (<ins>C++</ins>) [VTK](https://vtk.org/) build available on your system. We recommend building from source, and the currently tested version is `9.3.0`. You can find instructions for building VTK [here](https://gitlab.kitware.com/vtk/vtk/-/blob/master/Documentation/docs/build_instructions/build.md).

### Building

To build the python bindings, you must specify in the `VTTV_VTK_DIR` environment variable the path to the VTK build directory:

```bash
export VTTV_VTK_DIR=/path/to/vtk/build
```


Then, to install python-environment-wide the binded `vt-tv` python module, run:

```bash
pip install .
```
**Optional**

To specify the number of parallel jobs to use during the build, you can set the `VTTV_J` environment variable:

```bash
export VTTV_J=8
```

> [!NOTE]
> Behind the scenes, the usual `cmake` and `make` commands are run. Depending on your system, this can cause the install process to be lengthy as it will be compiling the entire `vt-tv` library.
Binary file modified docs/example-output-image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ def build_extension(self, ext):
build_temp = os.path.join('python-build', 'build', 'temp')
os.makedirs(build_temp, exist_ok=True)

vtk_dir = os.environ.get('VTK_DIR')
vtk_dir = os.environ.get('VTTV_VTK_DIR')
if not vtk_dir:
raise RuntimeError("Environment variable VTK_DIR is required")
raise RuntimeError("Environment variable VTTV_VTK_DIR is required")

jobs = os.environ.get('JOBS', os.cpu_count())
jobs = os.environ.get('VTTV_JOBS', os.cpu_count())

cmake_args = ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=' + extdir,
'-DPYTHON_EXECUTABLE=' + sys.executable,
Expand Down

0 comments on commit 6c2f729

Please sign in to comment.