[PyKDE] How to add handwritten *.cpp files to a sip generated module with configure.py
gvermeul at grenoble.cnrs.fr
gvermeul at grenoble.cnrs.fr
Sun Feb 1 08:12:01 GMT 2004
> On Saturday 31 January 2004 6:55 pm, Gerard Vermeulen wrote:
> > Hi Phil,
> >
> > Ulrich Berning kindly provided me with code to build PyQwt with
> > configure.py.
> >
> > One of his changes was to put a few handwritten *.cpp files to interface
> > the Numerical Python extension modules (numpy and numarray) in the
> > qwtmod.sip file.
> >
> > The problem is that there are conflicts between the header files of numpy
> > and numarray (numarray should become the successor of numpy, so there is an
> > overlap in their API). Putting all the interface code in the qwtmod.sip
> > file leads to compile errors because of the inclusion of the conflicting
> > headers in the same .cpp file.
> >
> > Ulli did not see it, because he is only having numpy, I guess.
> >
> >
> > I can think of several solutions to add extra files to a sip module:
> >
> > (1) put those interface files in a static library that is to be linked to
> > the PyQwt extension module. I think it is a bit tedious and fear
> > that linking a static lib to the extension has a tiny chance of causing
> > problems.
> >
> > (2) add the extra sources to the .sbf file before it is being used by the
> > Makefile.__init__() function (this is what I did, but it is hackish)
> >
> > (3) Add an extra argument "extra_sbf = {}' to the Makefile.__init__()
> > function to pass something like:
> > extra_sbf = { 'sources' : 's1.cpp s2.cpp', 'moc_headers': 'm1.h m2.h' }
> >
> > I prefer (3) and am willing to send a patch. Or do you have another
> > suggestion?
>
> (3) sounds reasonable. The only other thing I'd suggest is putting the code
> in .sip files selected by a new %Feature. Something like...
>
> %Feature numarray
> %Feature numpy
>
> %If (numarray)
> %ModuleCode
> numarray specific code
> %End
> %End
>
> %If (numpy)
> %ModuleCode
> numpy specific code
> %End
> %End
>
> ....and then call sip with either -t numarry or -t numpy as appropriate.
>
PyQwt does already something like that. You'll get a patch.
I am building PyQwt so that it is interfaced to numpy AND numeric (this is
working fine, even in the same Python program as long as the conflicting
headers are included in different source files)
Gerard
-------------------------------------------------------------
This message was sent using HTTPS service from CNRS Grenoble.
---> https://grenoble.cnrs.fr <---
More information about the PyQt
mailing list