Creating Python bindings for a large quantity of C++ Qt Libraries

224 views Asked by At

Question in short: Do you maybe know, or have any idea how I could implement the below mentioned, existing libraries in Python, whether that be through bindings or any other possible solution?


Description:

I'm working on a project and I have a very large quantity of custom built, fast-changing C++ Qt Libraries (version 5.15.2) that I need to use in Python.

I have done a lot of research on the topic over the past few weeks. However I can't seem to find a suitable solution on how to perform the bindings in an appropriate way.

I have mainly researched Shiboken, as that is the python bindings solution that the Qt Framework officially supports and encourages.

However Shiboken requires me to handwrite a type-system and header file for each library with each method or required part of that library that I want to use in my bindings. This is an issue for me as I require every method that is present in the C++ version to be present in the Python version, and hand writing that file is practically impossible.

They will need to be called from Python scripts as any other library would, or in a similar manner.

1

There are 1 answers

0
Alexander Trotsenko On

Shiboken could be a good choice. Yes, you need to specify each class/struct/enum/namespace in a type-system and header file. But not each method. If you specify a class in a type-system file, all the class methods will be extracted to Python. For example, this definition is enough:

<?xml version="1.0"?>
<typesystem package="mylibrary">
    <object-type name="MyClass1"/>
    <object-type name="MyClass2"/>
</typesystem>

Also, you can look at PySide sources. There is a big amount of Qt libraries extracted to Python. Good example.