Gateau User Manual
Atmospheric simulation of astronomical signals
For Maintainers

Development Lifecycle

The gateau development lifecycle is partially automated using Github Actions. It is possible to see all action runs on the actions page:

Automated parts: docker image, building, and pages

We use one docker image for both creating gateau sdists and compiling the doxygen documentation. This image is uploaded to GHCR (github container registry). This is done in the build-image.yml github workflow. The workflow runs on any push that updates Dockerfile or the workflow file itself.

Although creating the sdist tarball does not require compiling gateau, due to how meson-python works, all of the compile-time dependencies need to be present in the image.

We go a step further and include absolutely everything needed to build gateau in the container. It will succeed in building wheels (compiled distributions) even with no internet access. We do this for archival purposes.

It is possible to download the built image from the packages page:

Building the sdist is done in the build-sdist.yml github workflow. That workflow downloads the docker image from GHCR and uses it to build the sdist. A new release is then automatically created, and the sdist tarball are attached as release artifacts. This workflow runs on any git tag starting with v.

The sdist tarballs can be downloaded from the releases page:

Documentation is built automatically using doxygen and published to github pages. This is done using the build-doxy.yml github action, which runs on any git tag starting with v. The built documentation can be viewed on the pages site:

Old versions of the documentation can be downloaded as gzip archives from the "artifacts" section of a specific action's run. For example:

Non-automated part: testing and publishing

Testing the sdist and publishing to pypi is not automated and has to be done manually.

Testing the sdist

  1. Start with an environment capable of running Gateau (i.e. as described in README.md)
  2. Download the sdist to be tested from the releases page
  3. pip install gateau-x.x.x.tar.gz
  4. python -m unittest

If all tests pass, the sdist is good.

Publishing to pypi

Procedure for publishing to pypi is same as for any other python package.

  1. Create access token using pypi web interface
  2. Download the wheel and source archive to be published from the releases page
  3. pip install twine
  4. TWINE_USERNAME=__token__ TWINE_PASSWORD=pypi-xxxxxxx twine upload \
    --verbose --skip-existing --non-interactive \
    gateau-x.x.x.tar.gz
  • replace pypi-xxxxxx with your token. Do not change the TWINE_USERNAME=__token__ string.

Architecture: ctypes wrapper module

Most Python modules that have a backend written in a compiled language like C++ are Python Extension Modules, also known as Python Extensions. Python Extension Modules facilitate the interaction between the compiled code and Python by linking against Python's C ABI.

Gateau is not a Python Extension Module because it does not link against the Python ABI. Instead, the compiled part is bundled as a shared object (libgateau.so), which interacts with the pure Python part of Gateau using the ctypes module.

There is no conventional name for this type of Python module because almost nobody does it this way. In the absence of a standardized terminology, we have decided to call this type of python module a "ctypes wrapper module".

Source distribution

Since version 0.2.3, Gateau is distributed as an sdist. We do this to support a wide variety of target platforms and CUDA versions.

Prior to 0.2.3, Gateau was distributed as a compiled wheel, which links against hdf5 and libgsl statically, and libcufft dynamically. We decided to abandon this approach when we realised that there are multiple versions of libcufft that we have to support.

pip is not smart enough to probe versions of specific libraries (other than the standard c library) before installing a package. So even if we built multiple versions of Gateau for multiple versions of libcufft, the user would still need to manually check which versions of libcufft they have and choose the corresponding version of gateau. This is a pain in the neck for the user. Or, more precisely, it is a bigger pain in the neck than apt-getting a few build dependencies before pip installing gateau.

The git tag cuda-static-deadend contains a meson.build file which successfully produces gateau wheels with static libcufft that function correctly regardless of the system's libcufft version. However, these wheels are illegal to distribute due to license incompatibility.

Building Gateau: Editable install for development

In order to build Gateau, the following dependencies are required:

These can likely be installed from your package manager.

Prepare CUDA

CUDA is required to build and run Gateau. This can be installed from NVIDIA's website. All minor versions of CUDA 11 and CUDA 12 should work, but if you don't know which to choose, go with 12.3 (because that's what we use for Gateau).

The entire CUDA toolchain is quite large (~7GB). If you only want to build gateau without running it, you do not need the entire toolchain. You only need nvcc, cufft, and curand. So, if you want to save space and time, you can install only those components instead of the full toolchain. To do this, follow the deb (network) (or equivalent for your distro) steps on the CUDA website, but, instead of running

sudo apt-get -y install cuda-toolkit-12-3

run

sudo apt-get -y install \
cuda-nvcc-12-3 \
libcufft-dev-12-3 \
libcurand-dev-12-3

IMPORTANT Once installed, make sure nvcc is in your $PATH.

Build

Gateau uses meson as its build system, You can likely install meson from your package manager.

Once the dependencies, meson, and CUDA have been installed, you can install Gateau in development mode like this:

pip install -e .

Meson integrates tightly with the python packaging system. You do not need to manually recompile Gateau every time you make changes; recompilation will be triggered automatically every time import gateau is invoked.

If you would still like to manually trigger recompilation, you can do so by running pip install -e . again. Build caches is stored in the build directory in the project root. It is safe to delete.

Windows

For documentation of our failure to build Gateau for Windows, see Gateau on Windows .

Troubleshooting

Below are some common issues and solutions.

NVCC Not in Path

When trying to compile gateau:

../meson.build:1:0: ERROR: Could not find suitable CUDA compiler: "nvcc"
A full log can be found at /play/gateau/.mesonpy-fxjbc6lj/meson-logs/meson-log.txt

Cause

Either Cuda is not installed, or it is installed, but not in $PATH.

Solution

If cuda is not installed, then install it. If it is installed, but you cannot run nvcc from a shell, you need to update the $PATH variable to include cuda's bin directory. For example:

export PATH=/usr/local/cuda/bin:$PATH

<tt>build</tt> not installed

When trying to compile gateau:

/venv/bin/python: No module named build.__main__; 'build' is a package and cannot be directly executed

or

/usr/bin/python: No module named build

Solution

pip install build
gateau
Definition: __init__.py:1