swig python graphviz

 Hi I am trying to use swig to make a wrapper for attribs.c. I need the functions agnodeattr and agedgeattr but they don't seem to be included in the wrapper I am using. This is my first time using swig. I need to compile attribs_wrap.c with attribs.c but I don't know how to resolve all of the dependencies. I would like to get the makefile to do it but it's pretty complex. Any tips?

Re: swig python graphviz

Can you just extend the swig wrapper that is used for all the "gv"  language bindings?
See tclpkg/gv/gv.i
Installed in /usr/include/graphviz/gv.i  from graphviz-devel package.   (along with gvc.h and gv.cpp in the same directory).
 
 

Re: swig python graphviz

Oh yes, you asked how to compile:  See dot.demo/Makefile.python_wrapper  in the source tree.  Reproduced here as it is short:
 
all: gv_test.png

################################################
# This demo uses some files shipped with the distro.
# You could replace these with your own.
INCLUDEDIR=`pkg-config libgvc --variable=includedir`
gv.i:
        cp $(INCLUDEDIR)/gv.i .
gv.cpp:
        cp $(INCLUDEDIR)/gv.cpp .

EXTRACLEAN = gv.i gv.cpp
################################################

PYTHON_PREFIX = `python -c "import sys; print sys.prefix"`
PYTHON_VERSION = `python -c 'import sys; print sys.version[:3]'`

CXXFLAGS = `pkg-config libgvc --cflags` \
           -I$(PYTHON_PREFIX)/include/python$(PYTHON_VERSION) \
           -Wall -g -O2 -fPIC

LDFLAGS = -Wl,--rpath -Wl,`pkg-config libgvc --variable=libdir` \
          `pkg-config libgvc --libs` -shared

gv_test.png: gv_test.py _gv.so
        ./gv_test.py

_gv.so: gv.o gv_python.o
        g++ $(LDFLAGS) gv.o gv_python.o -o _gv.so
       
gv_python.cpp gv.py: gv.i
        swig -c++ -python -o gv_python.cpp gv.i

clean:
        rm -f gv.py gv_python.cpp _gv.so *.o gv_test.png $(EXTRACLEAN)
 

Re: swig python graphviz

 Thanks for the help. I compiled everything and installed it and then used the gv_python that comes with it like you suggested. I am getting an error when I try to use the function protonode
 def_node = gv.protonode(self.handle)
.....
TypeError: in method 'protonode', argument 1 of type 'Agraph_t *'
I have ran pdb and verified that the argument I am passing is the correc type. self.handle is of type  'Agraph_t *'
I've compiled it a million different ways and I keep getting the same type errors.
Any idea what is wrong?
 
 

Recent comments