[PyQt] SIP Error with a %MethodCode
Hi, I have, in C++, a method wich return an array of double and I've set a MethodCode in the .sip file to convert the array to a Python list of int. The array in the C++ code: - double lr[256]; for (int i = 0 ; i 256 ; i++) { float val = cvRound(b_hist.atfloat(i)); lr[i] = val; } return *lr; - The .sip file: - %Module histogram class Histogram { %TypeHeaderCode #include histogram.h %End public: int loadImage(char*) ; double getHistogram() ; %MethodCode PyObject *l ; int size = 256 ; // Create the Python list of the correct length. if ((l = PyList_New(size)) == NULL) return NULL; // Go through each element in the C++ instance and convert it to a // wrapped object. for (int i = 0; i size; ++i) { // Add the wrapper to the list. PyList_SET_ITEM(l, i, PyFloat_FromDouble(sipCpp - at(i))); } return l; %End }; --- The error when I execute make: vincent@djoliba:~/oqapy-2/C++/exemples/2$ make g++ -c -O2 -g -fPIC -Wall -W -DNDEBUG -I. -I/usr/include/python2.7 -o siphistogramcmodule.o siphistogramcmodule.cpp g++ -c -O2 -g -fPIC -Wall -W -DNDEBUG -I. -I/usr/include/python2.7 -o siphistogramHistogram.o siphistogramHistogram.cpp histogram.sip: In function ‘PyObject* meth_Histogram_getHistogram(PyObject*, PyObject*)’: histogram.sip:28:9: erreur: ‘class Histogram’ has no member named ‘at’ make: *** [siphistogramHistogram.o] Erreur 1 In this context, what represent 'sipCpp'? The returned value ? Thanks ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] SIP Error with a %MethodCode
On Sun, 17 Mar 2013 10:10:00 +0100, Vincent Vande Vyvre vincent.vandevy...@swing.be wrote: Hi, I have, in C++, a method wich return an array of double and I've set a MethodCode in the .sip file to convert the array to a Python list of int. The array in the C++ code: - double lr[256]; for (int i = 0 ; i 256 ; i++) { float val = cvRound(b_hist.atfloat(i)); lr[i] = val; } return *lr; - The .sip file: - %Module histogram class Histogram { %TypeHeaderCode #include histogram.h %End public: int loadImage(char*) ; double getHistogram() ; %MethodCode PyObject *l ; int size = 256 ; // Create the Python list of the correct length. if ((l = PyList_New(size)) == NULL) return NULL; // Go through each element in the C++ instance and convert it to a // wrapped object. for (int i = 0; i size; ++i) { // Add the wrapper to the list. PyList_SET_ITEM(l, i, PyFloat_FromDouble(sipCpp - at(i))); } return l; %End }; --- The error when I execute make: vincent@djoliba:~/oqapy-2/C++/exemples/2$ make g++ -c -O2 -g -fPIC -Wall -W -DNDEBUG -I. -I/usr/include/python2.7 -o siphistogramcmodule.o siphistogramcmodule.cpp g++ -c -O2 -g -fPIC -Wall -W -DNDEBUG -I. -I/usr/include/python2.7 -o siphistogramHistogram.o siphistogramHistogram.cpp histogram.sip: In function ‘PyObject* meth_Histogram_getHistogram(PyObject*, PyObject*)’: histogram.sip:28:9: erreur: ‘class Histogram’ has no member named ‘at’ make: *** [siphistogramHistogram.o] Erreur 1 In this context, what represent 'sipCpp'? The returned value ? You code just implements a type convertor - %MethodCode does more than that. See... http://pyqt.sourceforge.net/Docs/sip4/directives.html#directive-%MethodCode sipCpp is this, the Histogram instance. You've defined getHistogram() as returning a double, but you say it returns an array of doubles. You haven't called Histogram::getHistogram(). You have included return statements which you must not do. Phil ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] empty container in QSettings: TypeError
Hi all, When I store a list of strings (but happening to be empty) in QSettings (using QString and QVariant api 2): e.g.: paths = [] QSettings().setValue('paths', paths) Retrieving it yields a TypeError, instead of an empty list: QSettings().value('paths', [], 'QString') Traceback (most recent call last): File stdin, line 1, in module TypeError: unable to convert a QVariant of type 0 to a QMetaType of type 10 What is the most elegant way to circumvent this? cathing the TypeError and returning the empty list? Best regards, Wilbert -- Wilbert Berendsen (http://www.wilbertberendsen.nl) ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Symbol not found: _sipQtConnect (Qt5 and PyQt 4.10 on OSX, 32 bit)
On 16/03/13 21:56, Phil Thompson wrote: On Sat, 16 Mar 2013 14:16:08 +1300, Glenn Ramsey g...@componic.co.nz wrote: On 15/03/13 22:07, Phil Thompson wrote: On Fri, 15 Mar 2013 15:51:00 +1300, Glenn Ramsey g...@componic.co.nz wrote: Hi, I have built a 32 bit version of PyQt on OSX (10.8.2) using Qt5, but it doesn't work: Make sure the qpy libraries are being built as you expect (ie. 32 bits rather than 64), ie. that your change to macx-clang-32 is being applied to everything. Phil Thanks Phil, that does appear to be the problem. QtCore is being built as 64 bit, everything else as 32 bit (this is in a freshly untarred dir): $find . -name '*.o' | xargs file ./pylupdate/fetchtr.o: Mach-O object i386 ./pylupdate/main.o: Mach-O object i386 ./pylupdate/merge.o: Mach-O object i386 ./pylupdate/metatranslator.o: Mach-O object i386 ./pylupdate/moc_translator.o: Mach-O object i386 ./pylupdate/numberh.o: Mach-O object i386 ./pylupdate/proparser.o: Mach-O object i386 ./pylupdate/sametexth.o: Mach-O object i386 ./pylupdate/simtexth.o: Mach-O object i386 ./pylupdate/translator.o: Mach-O object i386 ./pyrcc/main.o: Mach-O object i386 ./pyrcc/rcc.o: Mach-O object i386 ./qpy/QtCore/moc_qpycore_pyqtproxy.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_chimera.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_chimera_signature.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_chimera_storage.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_classinfo.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_init.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_misc.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_post_init.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_pyqtboundsignal.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_pyqtconfigure.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_pyqtmethodproxy.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_pyqtproperty.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_pyqtproxy.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_pyqtpyobject.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_pyqtsignal.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_pyqtslot.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_qabstracteventdispatcher.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_qmetaobject.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_qmetaobject_helpers.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_qobject_getattr.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_qobject_helpers.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_qpynullvariant.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_qstring.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_qstringlist.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_qvariant.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_qvariant_value.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_sip_helpers.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_types.o: Mach-O 64-bit object ./qpy/QtGui/moc_qpytextobject.o: Mach-O 64-bit object ./qpy/QtOpenGL/qpyopengl_attribute_array.o: Mach-O 64-bit object ./qpy/QtOpenGL/qpyopengl_uniform_value_array.o: Mach-O 64-bit object ./Qt/sipQtcmodule.o: Mach-O object i386 ./QtCore/sipQtCorecmodule.o: Mach-O object i386 8 What do I need to do to fix it? Glenn ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Symbol not found: _sipQtConnect (Qt5 and PyQt 4.10 on OSX, 32 bit)
On Mon, 18 Mar 2013 08:17:18 +1300, Glenn Ramsey g...@componic.co.nz wrote: On 16/03/13 21:56, Phil Thompson wrote: On Sat, 16 Mar 2013 14:16:08 +1300, Glenn Ramsey g...@componic.co.nz wrote: On 15/03/13 22:07, Phil Thompson wrote: On Fri, 15 Mar 2013 15:51:00 +1300, Glenn Ramsey g...@componic.co.nz wrote: Hi, I have built a 32 bit version of PyQt on OSX (10.8.2) using Qt5, but it doesn't work: Make sure the qpy libraries are being built as you expect (ie. 32 bits rather than 64), ie. that your change to macx-clang-32 is being applied to everything. Phil Thanks Phil, that does appear to be the problem. QtCore is being built as 64 bit, everything else as 32 bit (this is in a freshly untarred dir): $find . -name '*.o' | xargs file ./pylupdate/fetchtr.o: Mach-O object i386 ./pylupdate/main.o: Mach-O object i386 ./pylupdate/merge.o: Mach-O object i386 ./pylupdate/metatranslator.o: Mach-O object i386 ./pylupdate/moc_translator.o: Mach-O object i386 ./pylupdate/numberh.o: Mach-O object i386 ./pylupdate/proparser.o: Mach-O object i386 ./pylupdate/sametexth.o: Mach-O object i386 ./pylupdate/simtexth.o: Mach-O object i386 ./pylupdate/translator.o: Mach-O object i386 ./pyrcc/main.o: Mach-O object i386 ./pyrcc/rcc.o: Mach-O object i386 ./qpy/QtCore/moc_qpycore_pyqtproxy.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_chimera.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_chimera_signature.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_chimera_storage.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_classinfo.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_init.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_misc.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_post_init.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_pyqtboundsignal.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_pyqtconfigure.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_pyqtmethodproxy.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_pyqtproperty.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_pyqtproxy.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_pyqtpyobject.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_pyqtsignal.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_pyqtslot.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_qabstracteventdispatcher.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_qmetaobject.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_qmetaobject_helpers.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_qobject_getattr.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_qobject_helpers.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_qpynullvariant.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_qstring.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_qstringlist.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_qvariant.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_qvariant_value.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_sip_helpers.o: Mach-O 64-bit object ./qpy/QtCore/qpycore_types.o: Mach-O 64-bit object ./qpy/QtGui/moc_qpytextobject.o: Mach-O 64-bit object ./qpy/QtOpenGL/qpyopengl_attribute_array.o: Mach-O 64-bit object ./qpy/QtOpenGL/qpyopengl_uniform_value_array.o: Mach-O 64-bit object ./Qt/sipQtcmodule.o: Mach-O object i386 ./QtCore/sipQtCorecmodule.o: Mach-O object i386 8 What do I need to do to fix it? Glenn As we are talking hacks here anyway... Edit your installed sipconfig.py and change the value of 'platform' in _pkg_config to 'macx-clang-32'. Then back out all your related changes to PyQt's configure.py. In PyQt's new build system (4.10.1 hopefully) you will just be able to pass --spec macx-clang-32 to its configure.py. Phil ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Symbol not found: _sipQtConnect (Qt5 and PyQt 4.10 on OSX, 32 bit)
On 18/03/13 11:18, Phil Thompson wrote: On Mon, 18 Mar 2013 08:17:18 +1300, Glenn Ramsey g...@componic.co.nz wrote: On 16/03/13 21:56, Phil Thompson wrote: On Sat, 16 Mar 2013 14:16:08 +1300, Glenn Ramsey g...@componic.co.nz wrote: On 15/03/13 22:07, Phil Thompson wrote: On Fri, 15 Mar 2013 15:51:00 +1300, Glenn Ramsey g...@componic.co.nz wrote: Hi, I have built a 32 bit version of PyQt on OSX (10.8.2) using Qt5, but it doesn't work: Make sure the qpy libraries are being built as you expect (ie. 32 bits rather than 64), ie. that your change to macx-clang-32 is being applied to everything. Phil Thanks Phil, that does appear to be the problem. QtCore is being built as 64 bit, everything else as 32 bit (this is in a freshly untarred dir): $find . -name '*.o' | xargs file ./pylupdate/fetchtr.o: Mach-O object i386 ./qpy/QtCore/moc_qpycore_pyqtproxy.o: Mach-O 64-bit object 8 What do I need to do to fix it? Glenn As we are talking hacks here anyway... Edit your installed sipconfig.py and change the value of 'platform' in _pkg_config to 'macx-clang-32'. Then back out all your related changes to PyQt's configure.py. In PyQt's new build system (4.10.1 hopefully) you will just be able to pass --spec macx-clang-32 to its configure.py. Phil It is already set to that. $ more /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sipconfig.py ... # These are installation specific values created when SIP was configured. _pkg_config = { 'arch': 'i386', 'default_bin_dir': '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin', 'default_mod_dir': '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages', 'default_sip_dir': '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/share/sip', 'deployment_target': '', 'platform': 'macx-clang-32', 'py_conf_inc_dir': '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7', 'py_inc_dir': '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7', 'py_lib_dir': '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config', 'py_version': 0x020703, 'sip_bin': '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/sip', 'sip_config_args':'--arch i386 --platform macx-clang-32', 'sip_inc_dir': '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7', 'sip_mod_dir': '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages', 'sip_version':0x040e04, 'sip_version_str':'4.14.4', 'universal': '' } ... Glenn ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Symbol not found: _sipQtConnect (Qt5 and PyQt 4.10 on OSX, 32 bit)
On Mon, 18 Mar 2013 13:36:51 +1300, Glenn Ramsey g...@componic.co.nz wrote: On 18/03/13 11:18, Phil Thompson wrote: On Mon, 18 Mar 2013 08:17:18 +1300, Glenn Ramsey g...@componic.co.nz wrote: On 16/03/13 21:56, Phil Thompson wrote: On Sat, 16 Mar 2013 14:16:08 +1300, Glenn Ramsey g...@componic.co.nz wrote: On 15/03/13 22:07, Phil Thompson wrote: On Fri, 15 Mar 2013 15:51:00 +1300, Glenn Ramsey g...@componic.co.nz wrote: Hi, I have built a 32 bit version of PyQt on OSX (10.8.2) using Qt5, but it doesn't work: Make sure the qpy libraries are being built as you expect (ie. 32 bits rather than 64), ie. that your change to macx-clang-32 is being applied to everything. Phil Thanks Phil, that does appear to be the problem. QtCore is being built as 64 bit, everything else as 32 bit (this is in a freshly untarred dir): $find . -name '*.o' | xargs file ./pylupdate/fetchtr.o: Mach-O object i386 ./qpy/QtCore/moc_qpycore_pyqtproxy.o: Mach-O 64-bit object 8 What do I need to do to fix it? Glenn As we are talking hacks here anyway... Edit your installed sipconfig.py and change the value of 'platform' in _pkg_config to 'macx-clang-32'. Then back out all your related changes to PyQt's configure.py. In PyQt's new build system (4.10.1 hopefully) you will just be able to pass --spec macx-clang-32 to its configure.py. Phil It is already set to that. $ more /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sipconfig.py ... # These are installation specific values created when SIP was configured. _pkg_config = { 'arch': 'i386', 'default_bin_dir': '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin', 'default_mod_dir': '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages', 'default_sip_dir': '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/share/sip', 'deployment_target': '', 'platform': 'macx-clang-32', 'py_conf_inc_dir': '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7', 'py_inc_dir': '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7', 'py_lib_dir': '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config', 'py_version': 0x020703, 'sip_bin': '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/sip', 'sip_config_args':'--arch i386 --platform macx-clang-32', 'sip_inc_dir': '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7', 'sip_mod_dir': '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages', 'sip_version':0x040e04, 'sip_version_str':'4.14.4', 'universal': '' } ... In your original report you stated that sip was built with just '--arch i386'. '--platform macx-clang-32' is not supported and configure.py will generate an error message if used, so I don't see how that configuration could be created. With a clean PyQt, set the QMAKESPEC environment variable to macx-clang-32 and then run configure.py. That works for me. Phil ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt