[PyQt] numpy and sip
Alexander Schmolck
a.schmolck at gmx.net
Wed Jan 2 13:13:45 GMT 2008
Hi,
I'm having trouble to find the right invocation to get numpy and sip to
cooperate nicely
My first attempt was adding this to the .sip file
%ModuleHeaderCode
#include <numpy/arrayobject.h>
%End
%PostInitialisationCode
import_array();
%End
%Import QtCore/QtCoremod.sip
%Import QtGui/QtGuimod.sip
// primitive demo-class
class A : QObject
{
%TypeHeaderCode
#include "a.h"
%End
public:
A();
~A();
int two();
int addToTwo(int bob);
};
however, that gives the following warning when compiling the code for the
wrapped class:
/usr/local/lib/python2.5/site-packages/numpy/core/include/numpy/__multiarray_api.h:943:
warning: ‘int _import_array()’ defined but not used
I think the problem is due to the fact that one has to jump through some hoops
if one wants to split an extension module that uses numpy into several files
(IIRC #define PY_ARRAY_UNIQUE_SYMBOL to something and judiciously place
#define NO_IMPORT_ARRAY in the .c files that don't directly call
#import_array).
I vaguely remember that I've come across this issue before, but it's rather
poorly documented and googling doesn't turn up that much either, and getting
it to work by trial and error looks somewhat painful.
Given that numpy is pretty popular, maybe someone already got a simple example
handy?
cheers,
'as
More information about the PyQt
mailing list