[PyQt] How to avoid duplication in SIP?

Shaheed Haque srhaque at theiet.org
Sun Apr 9 16:05:47 BST 2017


A recurring problem with my SIP generator efforts is the need to deal
with duplicate SIP code. So far, I've been able to use the SIP concept
of a "feature" to deal with various manifestations of this, but I have
now hit one that has me stumped:

- Module A has a mapped type MTA (e.g. QPair<init, int>)
- Module B imports A, but also needs a mapped type for QPair<int, int>.

when the generator runs for module B, it is not aware of MTA, so it
ends up emitting MTB for its QPair<init, int>. Of course, when I run
SIP on B, MTA and MTB collide.

Is there something already in SIP I could use to say "this duplicate
is fine"? If not, would it be possible to add support for the SIP
equivalent of a define guard, along the lines "#define
feature"/"#ifdef feature"?

I realise that by generating the SIP code, I'm in a minority of SIP
users, but such a feature would also significantly simplify certain
other scenarios that affect me too.

Thanks, Shaheed


More information about the PyQt mailing list