4. Building Python auxiliary libraries

eProsima Fast DDS-Gen can generate the required source files and CMake project to build the Python modules that allow the use of the IDL defined data types within a Fast DDS Python-based application. Each IDL file will result in a new Python module that will contain all the data types defined in the file. The Python binding is generated building the provided solution using SWIG.

Calling eProsima Fast DDS-Gen with the option -python will generate these files. eProsima Fast DDS-Gen will generate a .i file which will be processed by SWIG and a CMake project to call SWIG first generating C++ files (for connecting C++ and Python) and Python files (Python module for your type) and then compiling the C++ sources.

Before calling CMake, the Building process needs several Dependencies to be met.

4.1. Dependencies

4.1.1. SWIG

SWIG is a development tool that allows connecting programs written in C/C++ with a variety of other programming languages, among them Python. SWIG 4.0 is required in order to build Fast DDS Python bindings.

Note

More recent SWIG releases are not yet supported. Please, ensure to be using SWIG 4.0.

SWIG can be installed directly from the package manager of the appropriate Linux distribution. For Ubuntu, please run:

sudo apt install swig

4.1.2. Header files and static library for Python

Python static libraries and header files are needed to compile C++ source code generated by SWIG. They can be installed directly from the package manager of the appropriate Linux distribution. For Ubuntu, please run:

sudo apt install libpython3-dev

4.2. Building

Call CMake:

mkdir build
cd build
cmake ..
cmake --build .

This will create the Python files (.py) with the modules (one per each IDL file) that have to be imported within the Python script.