[GRASS-dev] getting SWIG/Python to work

Markus Neteler neteler at itc.it
Thu May 17 01:45:24 EDT 2007


On Thu, May 17, 2007 at 05:35:08PM +1200, Hamish wrote:
> A couple of issues here:
> 
> should "./configure --with-python" trigger make swig/python somehow?
> (currently you have to manually run make)
> Running make in the swig/ dir is a no-op.
> See missing Python.h problem below, check for that too?
> 
> As per the readme, I had to install the 'swig' package to get going.
> Add check for [-x `which swig`] to ./configure if --with-python?
> (make exited with error the first time as it was missing)

I think that configure[.in] should be improved in this regard.

> 
> make distclean doesn't clean these: (they are auto-generated by Makefile)
> ? interfaces/dig_structs.i
> ? interfaces/gisdefs.i
> ? interfaces/vect.i
> 
> this patch ok?

No - these files should be better autogenerated like the other *.i
files in that directory.

...
> grass63/swig/python$ make           
> Makefile:21: warning: overriding commands for target `clean'
> ../../include/Make/Rules.make:34: warning: ignoring old commands for target `clean'
> gcc -c -fpic -I/usr/include/python2.3 -I./ -I/usr/local/src/grass/grass63/dist.i686-pc-linux-gnu/include  python_grass6_wrap.c
> python_grass6_wrap.c:22:20: Python.h: No such file or directory
[...]
 
> $ locate Python.h
> [nothing]

/usr/include/python2.4/Python.h

Perhaps we can borrow this from GDAL where things are already solved.

> grass63/swig/python$ make
> Makefile:21: warning: overriding commands for target `clean'
> ../../include/Make/Rules.make:34: warning: ignoring old commands for target `clean'
> gcc -c -fpic -I/usr/include/python2.3 -I./ -I/usr/local/src/grass/grass63/dist.i686-pc-linux-gnu/include  python_grass6_wrap.c
> python_grass6_wrap.c: In function `_wrap_Categories_labels_get':
> python_grass6_wrap.c:9151: warning: passing arg 1 of `PyList_SetItem' from incompatible pointer type
> python_grass6_wrap.c: In function `_wrap_Key_Value_key_get':
> python_grass6_wrap.c:12128: warning: passing arg 1 of `PyList_SetItem' from incompatible pointer type
> python_grass6_wrap.c: In function `_wrap_Key_Value_value_get':
> python_grass6_wrap.c:12189: warning: passing arg 1 of `PyList_SetItem' from incompatible pointer type
> python_grass6_wrap.c: In function `_wrap_Option_opts_get':
> python_grass6_wrap.c:12511: warning: passing arg 1 of `PyList_SetItem' from incompatible pointer type
> python_grass6_wrap.c: In function `_wrap_Option_descs_get':
> python_grass6_wrap.c:12760: warning: passing arg 1 of `PyList_SetItem' from incompatible pointer type
> python_grass6_wrap.c: In function `_wrap_Option_answers_get':
> python_grass6_wrap.c:12915: warning: passing arg 1 of `PyList_SetItem' from incompatible pointer type
> python_grass6_wrap.c: In function `_wrap_G_list':
> python_grass6_wrap.c:26292: warning: passing arg 1 of `PyList_SetItem' from incompatible pointer type
> python_grass6_wrap.c: In function `_wrap_G__ls':
> python_grass6_wrap.c:26672: warning: passing arg 1 of `PyList_SetItem' from incompatible pointer type
> python_grass6_wrap.c: In function `_wrap_G_available_mapsets':
> python_grass6_wrap.c:27240: warning: passing arg 1 of `PyList_SetItem' from incompatible pointer type
> python_grass6_wrap.c: In function `_wrap_G_tokenize':
> python_grass6_wrap.c:34387: warning: passing arg 1 of `PyList_SetItem' from incompatible pointer type
> python_grass6_wrap.c: In function `_wrap_SITE_ATT_str_get':
> python_grass6_wrap.c:49748: warning: passing arg 1 of `PyList_SetItem' from incompatible pointer type
> ld -shared -L/usr/local/src/grass/grass63/dist.i686-pc-linux-gnu/lib -lgrass_I -lgrass_Iortho -lgrass_bitmap -lgrass_btree -lgrass_cdhc -lgrass_datetime -lgrass_dbmibase -lgrass_dbmiclient -lgrass_dbmidriver -lgrass_dbstubs -lgrass_dgl -lgrass_display -lgrass_dspf -lgrass_edit -lgrass_form -lgrass_g3d -lgrass_gis -lgrass_gmath -lgrass_gproj -lgrass_interpdata -lgrass_interpfl -lgrass_linkm -lgrass_qtree -lgrass_raster -lgrass_rowio -lgrass_rtree -lgrass_segment -lgrass_shape -lgrass_sites -lgrass_symb -lgrass_trans -lgrass_vask -lgrass_vect -lgrass_psdriver python_grass6_wrap.o -o _python_grass6.so
> 
> 
> 
> Are those incompatible pointer type warnings meaningful?

(expert wanted here)
 
> grass63/swig/python$ ls -l python_grass6.py _python_grass6.so
> ... 1030944 May 17 16:52 _python_grass6.so
> ...  277076 May 17 16:47 python_grass6.py
> [success!]
> 
> 
> "make -C interfaces/" didn't run. (why not?) I had to go into the subdir
> and run make manually to generate gisdefs.i, dig_structs.i, and vect.i.

No clue...
 
... 
> swig/python$ ldd _python_grass6.so  | grep vect
>   libgrass_vect.so => /usr/lib/grass/lib/libgrass_vect.so (0x40271000)
> 
> 
> ahh, it is using /usr/lib/grass/lib/ (Debian 6.0.2 package install) not
> /usr/src/grass/grass63/dist.i686-pc-linux-gnu/lib  build dir.
> 
> 
> swig/python/Makefile:
> ...
> LDFLAGS=-shared -L$(ARCH_LIBDIR) -lgrass_I -lgrass_Iortho [...]
> 
> 
> why doesn't it respect -L$(ARCH_LIBDIR) as other things calling
>   include $(MODULE_TOPDIR)/include/Make/Lib.make
> do??

No special reason. Please fix it.

> I've always had /usr/lib/grass/lib/ there, never a problem before.
> (Debian's libgrass package is a needed prereq for the libgdal1-1.3.1-grass
> [the GDAL GRASS plugin] and qgis-plugin-grass packages)
> 
> 
> # apt-get remove libgrass
> 
> swig/python$ make clean && make && make -C interfaces
> [ok]
> 
> swig/python$ ldd _python_grass6.so | grep vect
>         libgrass_vect.so => not found
> 
> mmmph!

Folks are kindly invited to fix the remaining problems :)

Markus




More information about the grass-dev mailing list