Greetings,
in my desperate :-) quest for a flexible solution to provide scripting to my
Qt6-based C++ project, I am now contemplating Python also. I had tried months
ago to build PySide on my Debian box, but never succeeded.
I tried now again (see [ Procedure ] below) and I can actually build the
shiboken6 generator:
% lls pyside6/pyside-setup/build/testenv/build/shiboken6/generator/shiboken6
-rwxr-xr-x 1 rusconi rusconi 2856416 Nov 17 16:08
pyside6/pyside-setup/build/testenv/build/shiboken6/generator/shiboken6
That was a wonderful start!
And then, I couldn't believe it :-)
--- Build completed (1167s)
(Note that the build fails with CMake but is sucessful with SetupTools -- as
described in an issue that I posted some days ago)
I could run the tetrix.py program (although the doc is erroneous on the location
of the file).
So, now that I actually could build PySide6, comes the actual work.
1. I could build and use the scriptableapplication example.
2. I "transferred" the samplebinding example to my use case, that I describe
below:
The library (Qt6-based) for which I want to develop bindings is named
libpappsomspp and is entirely contained in the "pappso" namespace.
I decided to start with the most simple component: the pappso::DataPoint struct.
The datapoint.h file contains omitted QDataStream stuff, which requires Qt6Core.
namespace pappso
{
struct PMSPP_LIB_DECL DataPoint
{
pappso_double x = -1;
pappso_double y = 0;
DataPoint();
DataPoint(const DataPoint &other);
DataPoint(pappso_double x, pappso_double y);
DataPoint(std::pair pair);
DataPoint(const QString &text);
// For debugging purposes.
//~DataPoint();
DataPointCstSPtr makeDataPointCstSPtr() const;
void initialize(pappso_double x, pappso_double y);
void initialize(const DataPoint &other);
bool initialize(const QString &text);
void reset();
void incrementX(pappso_double value);
void incrementY(pappso_double value);
bool operator==(const DataPoint &other) const;
DataPoint &operator=(const DataPoint &other);
bool isValid() const;
QString toString() const;
QString toString(int decimals) const;
};
} // namespace pappso
that implements just this: (x,y).
The typesystem file (copied and modified from the sample binding example) is:
The project builds, but I have to problems, a series of build warnings and the
fact that upon loading of the generated Python module in Python there is a
missing reference.
First the build warnings:
-
[ 98%] Building CXX object
pybind/CMakeFiles/PyPappsomspp.dir/PyPappsomspp/pypappsomspp_module_wrapper.cpp.o
cd /home/rusconi/devel/pappsomspp/build-area/unix/pybind && /usr/lib/ccache/c++
-DPyPappsomspp_EXPORTS -DQT_CORE_LIB -DQT_NO_DEBUG -DQT_NO_DEBUG_OUTPUT
-DQT_NO_KEYWORDS -I/home/rusconi/devel/pappsomspp/build-area/unix
-I/home/rusconi/devel/pappsomspp/development
-I/home/rusconi/devel/pappsomspp/development/src/pappsomspp -I/usr/include/python3.10
-I/home/rusconi/devel/small-pyside6/lib/python3.10/site-packages/shiboken6_generator/include
-I/home/rusconi/devel/small-pyside6/lib/python3.10/site-packages/PySide6/include
-I/home/rusconi/devel/small-pyside6/lib/python3.10/site-packages/PySide6/include/QtCore
-isystem /usr/include/x86_64-linux-gnu/qt6/QtCore -isystem
/usr/include/x86_64-linux-gnu/qt6 -isystem
/usr/lib/x86_64-linux-gnu/qt6/mkspecs/linux-g++ -O3 -DNDEBUG -fPIC
-Wno-unknown-pragmas -Wall -Wextra -fPIC -fPIC -std=gnu++17 -MD -MT
pybind/CMakeFiles/PyPappsomspp.dir/PyPappsomspp/pypappsomspp_module_wrapper.cpp.o -MF
CMakeFiles/PyPappsomspp.dir/PyPappsomspp/pypappsomspp_module_wrapper.cpp.o.d -o
CMakeFiles/PyPappsomspp.dir/PyPappsomspp/pypappsomspp_module_wrapper.cpp.o -c
/home/rusconi/devel/pappsomspp/build-area/unix/pybind/PyPappsomspp/pypappsomspp_module_wrapper.cpp
/home/rusconi/devel/pappsomspp/build-area/unix/pybind/PyPappsomspp/pypappsomspp_module_wrapper.cpp:22:1:
warning: missing initializer for member ‘PyMethodDef::ml_meth’
[-Wmissing-field-initializers]
22 | };
| ^
/home/rusconi/devel/pappsomspp/build-area/unix/pybind/PyPappsomspp/pypappsomspp_module_wrapper.cpp:22:1:
warning: missing initializer for member ‘PyMethodDef::ml_flags’
[-Wmissing-field-initializers]
/home/rusconi/devel/pappsomspp/build-area/unix/pybind/PyPappsomspp/pypappsomspp_module_wrapper.cpp:22:1:
warning: missing initializer for member ‘PyMethodDef::ml_doc’
[-Wmissing-field-initializers]
/home/rusconi/devel/pappsomspp/build-area/unix/pybind/PyPappsomspp/pypappsomspp_module_wrapper.cpp:116:15:
warning: cast between incompatible function types from ‘PyObject*
(*)(PyObject*)’ {aka ‘_object* (*)(_object*)’} to ‘PyCFunction’ {aka ‘_object*
(*)(_object*, _object*)’} [-Wcast-function-type]
116 | {"clear", reinterpret_cast(ShibokenSequenceContainerPrivate>::clear), METH_NOARGS, "clear"},
|
^~~