Skip to content

Latest commit

 

History

History
67 lines (44 loc) · 2.4 KB

UPGRADE_C_API.rst

File metadata and controls

67 lines (44 loc) · 2.4 KB

Contents

Overview

This small guide shows how to update PySlurm to a new Major Slurm Release - specifically it shows how to translate the C-API Headers into an appropriate file with cython definitions.

Directory Structure

All the Cython definitions for Slurm can be found in the directory pyslurm/slurm/ Essentially, the two most important files are header.pxi and extra.pxi. The first one contains all auto-generated definitions, the latter one contains definitions not found in the headers directly, but exported in libslurm.so.

The Idea here is to simply have one branch for each Major release, e.g. 20.11, 21.08, 22.05 and so on.

Requirements

  • autopxd2
  • C-Preprocessor (cpp, clang)
  • Slurm headers (slurm.h, slurmdb.h, slurm_errno.h)
  • Cython compiler (latest stable)

Generating Code

The script in scripts/pyslurm_bindgen.py basically generates all of the needed definitions from the Header files. Inside the script, autopxd2 is used which helps to create Cython specific definitions for all structs and functions. In addition, also all constants from the headers (#define) are made available with their appropriate data types.

First of all, checkout a new branch in the Repository, and give it the name of the major release to target, for example:

git checkout -b 22.05

Then, simply generate the header definitions like in this example:

scripts/pyslurm_bindgen.py -D /directory/with/slurm/headers > pyslurm/slurm/header.pxi

The script outputs everything to stdout. Simply redirect the output to the file: pyslurm/slurm/header.pxi. The headers should now be fully translated.

Compiling, Updating, Testing

Now with the generated headers, you can try and build pyslurm (e.g. by having a slurm installation in a virtual machine):

python3 setup.py build

This will likely give you a bunch of errors, since usually a few things have changed in between major releases. Usually it is rather straightforward to adapt the code. Often only a few constants have been deleted/renamed. If no more errors are showing and it compiles, everything is done.