|
| 1 | +Contents |
| 2 | +-------- |
| 3 | + |
| 4 | +* `Overview`_ |
| 5 | +* `Directory Structure`_ |
| 6 | +* `Requirements`_ |
| 7 | +* `Generating Code`_ |
| 8 | +* `Compiling, Updating, Testing`_ |
| 9 | + |
| 10 | +Overview |
| 11 | +-------- |
| 12 | + |
| 13 | +This small guide shows how to update PySlurm to a new Major Slurm Release - specifically it shows |
| 14 | +how to translate the C-API Headers into an appropriate file with cython definitions. |
| 15 | + |
| 16 | +Directory Structure |
| 17 | +------------------- |
| 18 | + |
| 19 | +All the Cython definitions for Slurm can be found in the directory :code:`pyslurm/slurm/` |
| 20 | +Essentially, the two most important files are :code:`header.pxi` and :code:`extra.pxi`. |
| 21 | +The first one contains all auto-generated definitions, the latter one contains definitions not found in the headers directly, but exported in `libslurm.so`. |
| 22 | + |
| 23 | +The Idea here is to simply have one branch for each Major release, e.g. `20.11`, `21.08`, `22.05` and so on. |
| 24 | + |
| 25 | +Requirements |
| 26 | +------------ |
| 27 | + |
| 28 | +- `autopxd2 <https://pypi.org/project/autopxd2/>`_ |
| 29 | +- C-Preprocessor (*cpp*, *clang*) |
| 30 | +- Slurm headers (*slurm.h*, *slurmdb.h*, *slurm_errno.h*) |
| 31 | +- Cython compiler (latest stable) |
| 32 | + |
| 33 | +Generating Code |
| 34 | +--------------- |
| 35 | + |
| 36 | +The script in :code:`scripts/pyslurm_bindgen.py` basically generates all of the needed definitions from the Header files. |
| 37 | +Inside the script, `autopxd2` is used which helps to create Cython specific definitions for all structs and functions. |
| 38 | +In addition, also all constants from the headers (`#define`) are made available with their appropriate data types. |
| 39 | + |
| 40 | +First of all, checkout a new branch in the Repository, and give it the name |
| 41 | +of the major release to target, for example: |
| 42 | + |
| 43 | +.. code-block:: bash |
| 44 | +
|
| 45 | + git checkout -b 22.05 |
| 46 | +
|
| 47 | +Then, simply generate the header definitions like in this example: |
| 48 | + |
| 49 | +.. code-block:: bash |
| 50 | +
|
| 51 | + scripts/pyslurm_bindgen.py -D /directoy/with/slurm/headers > pyslurm/slurm/header.pxi |
| 52 | +
|
| 53 | +The script outputs everything to `stdout`. Simply redirect the output to the file: :code:`pyslurm/slurm/header.pxi`. |
| 54 | + |
| 55 | +Now, 99% of the work is done for generating the headers. For the 1% left, you now need to open the generated file, search for the two follwowing statements and comment them out: |
| 56 | + |
| 57 | +- `slurm_addr_t control_addr` |
| 58 | +- `phtread_mutex_t lock` |
| 59 | + |
| 60 | +The compiler will otherwise complain that these are incomplete type definitions. |
| 61 | + |
| 62 | +Compiling, Updating, Testing |
| 63 | +---------------------------- |
| 64 | + |
| 65 | +Now with the generated headers, you can try and build pyslurm (e.g. by having a slurm installation in a virtual machine): |
| 66 | + |
| 67 | +.. code-block:: bash |
| 68 | +
|
| 69 | + python3 setup.py build |
| 70 | +
|
| 71 | +This will likely give you a bunch of errors, since usually a few things have changed in between major releases. |
| 72 | +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. |
0 commit comments