[maemo-developers] Problem using swig to compile python module in scratchbox

From: Pierre Amadio pierre.amadio at laposte.net
Date: Tue Jun 17 18:15:57 EEST 2008
Hello.

I'm encoutering problem building a python module that used to build ok in 
scratchbox with previous upstream version and wich is still compiling
all i right when i try to do so in a up to date debian Etch box.

However, i am not able to compile the latest version in scratchbox (maemo 
chinook, scratchbox-core 1.0.10,  scratchbox-devkit-maemo3  1.0.3 ).

The library is sword, http://www.crosswire.org/sword/index.jsp 

Currently available in garage for maemo, are sword 1.5.10 and python-sword, 
a packaged python module (coming from the same sources as sword).

When compiling the python module for 1.5.10, i had to use an newest version 
of swig, as it always failed when i used the one available in scratchbox, so 
I packaged "maemoswig" to have a freshest version available at the time (1.3.31)

Trying the same method with sword 1.5.11 fails in scratchbox.

In the Sword/bindings/swig, directory, i create the following setup.py file:
______________________
#! /usr/bin/python2.5

from distutils.core import setup, Extension
setup (name = "sword",
 version = "1.5.11",
 maintainer = "Sword Developers",
 maintainer_email = "sword-devel at crosswire.org",
 url = "http://www.crosswire.org/sword",
 py_modules = ["Sword"],
 include_dirs=['/usr/include/sword'],
 ext_modules = [Extension("_Sword", ["Sword.cxx"],
 libraries=[('sword')], 
 define_macros=[('SWIG',1)])], 
)
________________________

Compiling the module is then done with:

export SWIG_LIB=/usr/share/swig/1.3.31
export SWIG_FEATURES=-I/usr/include/sword
/usr/bin/swig -python -c++ -shadow -o Sword.cxx -I. -I/usr/include/sword sword.i
/usr/bin/python2.5 setup.py build_ext -I. -I/usr/include/sword -L/usr/lib/sword         

The python2.5 setup.py fails with a lot of error starting with:

In file included from Sword.cxx:5850:/usr/bin/python2.5 setup.py build_ext -I. -I/usr/include/sword -L/usr/lib/sword         
rendercallback.h: At global scope:
rendercallback.h:189: error: base `sword::BasicFilterUserData' with only non-default constructor in class without a constructor
rendercallback.h:212: error: base `sword::BasicFilterUserData' with only non-default constructor in class without a constructor
In file included from Sword.cxx:5911:
Sword.h:18: error: `Swig' has not been declared
Sword.h:18: error: expected class-name before '{' token
Sword.h:64: error: `Swig' has not been declared

It looks to me like there is a problem interacting with the scratchbox's swig 
for several reason:

* The Sword.cxx file i get says it has been generated by Version 1.3.29 
(scratchox) and not by the 1.3.31 version I installed.

* Although /usr/bin/swig is the one i packaged, it still behave as the 
scratchbox one. It start behaving as expected if i launch it from some where 
else, and this really puzzle me.


[sbox-CHINOOK_X86: ~] > ls -l /usr/bin/swig 
-rwxr-xr-x  1 user user 1112152 Jan  9 20:05 /usr/bin/swig
[sbox-CHINOOK_X86: ~] > /usr/bin/swig -version

SWIG Version 1.3.29

Compiled with g++  [i386-pc-linux-gnu]
Please see http://www.swig.org for reporting bugs and further information
[sbox-CHINOOK_X86: ~] > cp /usr/bin/swig .
[sbox-CHINOOK_X86: ~] > ./swig -version

SWIG Version 1.3.31

Compiled with i486-linux-gnu-g++ [i486-pc-linux-gnu]
Please see http://www.swig.org for reporting bugs and further information

* The compilation works if i perform it on a debian box

Now, just to see, i copied /usr/bin/sword in my local directory and try again 
to create sword.cxx , but using the ./swig binary.
I managed to have a Sword.cxx file that says it has been generated by swig 
1.3.31) , but still, the next step fails.

/usr/bin/python2.5 setup.py build_ext -I. -I/usr/include/sword -L/usr/lib/sword      

This time with less errors; and different one:

rendercallback.h:189: error: base `sword::BasicFilterUserData' with only non-default constructor in class without a constructor
rendercallback.h:212: error: base `sword::BasicFilterUserData' with only non-default constructor in class without a constructor

Around those line in the header file are the following comment :

// trick SWIG into thinking this is not inherited from an inner class...

The "trick" compile when done under debian, so my guess is that this error may still be due to an interaction with the swig coming from scratchbox.

I do not know where to go from there.

I would appreciate any idea that would let me

1) be able to compile this module within scratchbox
2) be able to automatise the compilation when building package (ie most 
probably finding another way than copying /usr/bin/swig somewhere else).

Any ideas ?

More information about the maemo-developers mailing list