[PyQt] numpy and sip

Alexander Schmolck a.schmolck at gmx.net
Wed Jan 2 13:13:45 GMT 2008


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

    #include <numpy/arrayobject.h>


    %Import QtCore/QtCoremod.sip
    %Import QtGui/QtGuimod.sip

    // primitive demo-class
    class A : QObject
    #include "a.h"
        int two();
        int addToTwo(int bob);

however, that gives the following warning when compiling the code for the
wrapped class:

    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

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



More information about the PyQt mailing list