[PySide] Failing build with newly-compiled PySide2 5.15.1
Stephen Morris
stephen.morris at silvaco.com
Wed Oct 14 12:41:15 CEST 2020
I found this documentation... (continued below)
https://doc.qt.io/qtforpython/shiboken2/typesystem_codeinjection.html
On 10/12/20 3:26 PM, Stephen Morris via PySide wrote:
OK, I got this to build with the aid of a filthy hack: I'd still appreciate advice on how to avoid the hack...
On 10/12/20 1:11 PM, Stephen Morris via PySide wrote:
A further observation...
On 10/12/20 12:14 PM, Stephen Morris via PySide wrote:
Following an apparently successful build of Qt 5.15.1 and PySide2 5.15.1 from source, I'm now attempting to compile the application which I was previously compiling using version 5.12.5.
I get a slew of error messages involving PySide Properties:
<myproject>_wrapper.cpp: In function 'int Sbk_icp_RenderWindow_setattro(PyObject*, PyObject*, PyObject*)':
<myproject>_wrapper.cpp:1984:66: error: 'PySide::Property' has not been declared
Shiboken::AutoDecRef pp(reinterpret_cast<PyObject *>(PySide::Property::getObject(self, name)));
^~~~~~~~
<myproject>_wrapper.cpp:1986:24: error: 'PySide::Property' has not been declared
return PySide::Property::setValue(reinterpret_cast<PySideProperty *>(pp.object()), self, value);
^~~~~~~~
<myproject>_wrapper.cpp:1986:60: error: 'PySideProperty' does not name a type; did you mean 'QMetaProperty'?
return PySide::Property::setValue(reinterpret_cast<PySideProperty *>(pp.object()), self, value);
^~~~~~~~~~~~~~
QMetaProperty
<myproject>_wrapper.cpp:1986:75: error: expected '>' before '*' token
return PySide::Property::setValue(reinterpret_cast<PySideProperty *>(pp.object()), self, value);
^
<myproject>_wrapper.cpp:1986:75: error: expected '(' before '*' token
return PySide::Property::setValue(reinterpret_cast<PySideProperty *>(pp.object()), self, value);
<myproject>
(
<myproject>_wrapper.cpp:1986:76: error: expected primary-expression before '>' token
return PySide::Property::setValue(reinterpret_cast<PySideProperty *>(pp.object()), self, value);
^
Is this likely to be a problem with my PySide2 build, or do I need to update my project's syntax?
Thank you,
Stephen Morris.
I can eliminate the compile error by opening up the auto-generated wrapper file "<myproject>_wrapper.cpp" and manually inserting:
#include "pysideproperty.h"
... near the beginning. However, it still doesn't get me out of the woods because when I try to import the resulting module from Python I get a link error:
Traceback (most recent call last):
File "<string>", line 20, in <module>
File ".../lib/python2.7/site-packages/shiboken2/files.dir/shibokensupport/__feature__.py", line 146, in _import
return original_import(name, *args, **kwargs)
ImportError: .../lib/python2.7/<mylibrary>.so: undefined symbol: _ZN6PySide8Property8setValueEP14PySidePropertyP7_objectS4_
I've revisited the successful build of the my project using Qt and PySide version 5.12.5, and the <myproject>_wrapper.cpp file generated there makes no reference to PySideProperty.
In general the versions of the wrapper file generated by versions 5.12.5 and 5.15.1 of Shiboken diverge quite substantially, despite being generated from the same sources, so it's very hard to tell why the PySideProperty dependance has been introduced, or what to do about it.
My successful hack was this:
Firstly, I added the following lines to my CMakeLists.txt file:
pyside2_release_config(--pyside2-include-path pyside2_release_include_dir)
pyside2_release_config(--pyside2-shared-libraries-cmake pyside2_release_shared_libraries 0)
# Will need to do this for the debug version as well eventually, but for now I'm only building Release
target_include_directories(${shibLibName} PRIVATE $<IF:$<CONFIG:Debug>,${pyside2_debug_include_dir},${pyside2_release_include_dir}>)
target_link_libraries(${shibLibName} PRIVATE $<IF:$<CONFIG:Debug>,${pyside2_debug_shared_libraries},${pyside2_release_shared_libraries}>)
Then I configured my project and started the build, which failed in the way described in my original post. Per my previous post, I opened up the auto-generated file and inserted the line
#include "pysideproperty.h"
...near the beginning, whereupon I continued the build and everything built, loaded and ran cleanly.
What it amounts to is that I 'injected' the additional include statement into the generated .cpp file. The Shiboken documentation says that this may be necessary from time to time (see https://doc.qt.io/qtforpython/shiboken2/shibokengenerator.html), but I can't find any reference to a clean method to do this without hacking the file after the build fails. I also don't really understand why the injection is necessary at all - there are no references to PySideProperties in the code that version 5.12.5 generates at all, and I haven't requested them, so I don't understand why version 5.15.1 puts them into the code.
I haven't been successful in following it, though. Based on the documentation, I tried adding the code:
<inject-code class="native" position="beginning">
#include "pysideproperty.h"
</inject-code>
... into my existing typesystem.xml directory, but it made no difference.
Even if it had, though, it would still feel like a hack. The underlying issue is why does version 5.15.1 generate apparently-redundant code without taking care of the necessary inclusions itself? Essentially it's a breaking change, since it breaks code that worked perfectly well in 5.12.5.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/pyside/attachments/20201014/32762a13/attachment-0001.html>
More information about the PySide
mailing list