[PyQt] SIP: Struggling to build multiple C++ classes for one python module.

Phil Thompson phil at riverbankcomputing.com
Mon May 5 16:03:06 BST 2014


On 05/05/2014 2:49 pm, Christoff Kok wrote:
> Hi,
> 
> I am struggling to get my multiple C++ classes (each in their own .sip
> file) to build for the same module. The documentation is not helping
> me enough yet.
> 
> Currently I am testing with 2 classes: Entity and NamedEntity
>  Entity.sip and NamedEntity.sip's first line of code = "%Module
> emsim"
> When I try build it with my setup.py script, the following error
> appears:
> "
> 
> D:Ex MenteSoftwareExMente.Sim 4 PrototypesEMSIM4EMSIM4Py>python
> setup.py install
> running install
> running build
> running build_ext
> building 'emsim' extension
> C:Python33sip.exe -c buildtemp.win32-3.3Release -b
> buildtemp.win32-3.3ReleaseEntity.sbf -I C:Python33sip "D:...
> ...Entity.sip"
> C:Python33sip.exe -c buildtemp.win32-3.3Release -b
> buildtemp.win32-3.3ReleaseNamedEntity.sbf -I C:Python33sip "D:\...
> ...NamedEntity.sip"
> sip: Entity.sip:2: Module is already defined
> error: command 'C:Python33sip.exe' failed with exit status 1
> "
> 
> When I remove the %Module line in NamedEntity, I receive an error that
> there is no %Module defined for the class. When I make NamedEntity's
> %Module line a %ConsolidateModule, I received the same "Module is
> already defined' error as described above.
> 
> I am sure I am missing something or understanding the Module /
> ConsolidateModule concept wrong.

Forget about consolidated modules - that's advanced stuff.

As far as SIP is concerned there is one logical .sip file per Python 
module. You can break it into multiple actual .sip files and use the 
%Include directive much like you would use #include in C/C++.

If you are going to use one .sip file per class then it's best to have 
another "master" .sip file that contains stuff not related to any 
particular class (like the %Module directive) and have %Include 
directives for each of the individual class .sip files.

Phil


More information about the PyQt mailing list