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.
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.
SWIG can be installed directly from the package manager of the appropriate Linux distribution. For Ubuntu, please run:
sudo apt install swig
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.