Interrogate tool


I was fighting for three days now with the interrogate tool. I’m close from victory but I need help for the last round !

I followed that post [Interrogate Hello World troubles) . It give me good clues.

But now I’m stuck. When I try to include panda3d dependency into my c++ code, interrogate doesn’t wrap it for python.

For example, I have a function :

void blop(void)

It works ! C++ is wrapped into the _igate.cpp file, _module.cpp, compile, etc … it print “pass” !
I have try also :

void blop(int i)
  printf("pass %d\n", i);

It works too !

But with something like :

void blop(CardMaker& cm)
  cm.set_color(0.f, 0.f, 255.0f, 255.0f);

No code is wrapped into the _igate.cpp file so I get the ImportError when running python.

I have well encapsulated, in the header file, the definition of the function with the __begin_publish and __end_publish (BEGIN_PUBLISH & END_PUBLISH macro are not recognized from interrogate with me… o_O ?)
I have also used the -refcount option of interrogate.

Some interrogate gurus here ? :stuck_out_tongue:


BEGIN_PUBLISH and END_PUBLISH are defined in dtoolbase.h, which is included by every other Panda header out there. Are you even including cardMaker.h?

Yes I have included cardMaker.h, and also tryied to include dtoolbase.h directly but interrogate give me the following error :

 *** Error in ../examples/PythonDisplayExample/PythonDisplayExample.h near line 14, column 6:
  syntax error, unexpected KW_VOID, expecting '{' or ';' or ':' or '='
Error parsing file: '../examples/PythonDisplayExample/PythonDisplayExample.h'

Well, and what is at line 14 of PythonDisplayExample.h? Clearly something on that line has confused interrogate, and it’s probably an undefined typename or something.

If interrogate doesn’t find a header file, it quietly ignores it, so just putting an #include “foo.h” doesn’t necessarily mean that foo.h was read and processed. You should add -v to the interrogate command line to get a list of header files it skips and such; this will give you more insight if you see it skipping a header file you expected it to process.

Also, as to your original question, interrogate won’t generate wrappers for a function that involve types that it don’t have wrappers for themselves. There would be no way it could generate a wrapper for a function that involves a type that Python can’t access! Since it didn’t generate a wrapper for your function when you made it use the CardMaker type, it follows that interrogate didn’t believe CardMaker was a published type. Since CardMaker is a published type, it follows that interrogate either (a) didn’t read the header file for cardMaker.h, or (b) didn’t understand it properly because (for instance) PUBLISHED wasn’t properly defined for some other reason. This is, of course, consistent with your report that BEGIN_PUBLISH and END_PUBLISH aren’t working, so I guess you need to figure out what’s going on with that problem first.


Thanks for your answer drwr. Again, you’re right. And the -v option helps a lot !

As it was used in the related post, I included path to panda with the <-I path> option. But it seems to doesn’t affect interrogate at all. That’s why it couldn’t find the includes.
So what I need now is to tell interrogate were to find the include file without changing the path in my header file (because it wouldn’t compile).

May I use <-srcdir> option ? Or something else, like environment variables ?


The -I option should certainly work. If it doesn’t, something else is wrong. Note that this is a capital letter i, not a lowercase letter L. You can examine the interrogate command line generated by makepanda for more examples (use the --verbose option to makepanda to print out the command lines as it runs).


Ok I notice that I have only warnings on global includes

                  *** Warning in /home/vash/Workspaces/commons/include/python/Python.h near line 19, column 2:
                  Cannot find limits.h
                  *** Error in /home/vash/Workspaces/commons/include/python/Python.h near line 22, column 2:
                  "Something's broken.  UCHAR_MAX should be defined in limits.h."
                  *** Warning in /home/vash/Workspaces/commons/include/python/Python.h near line 25, column 2:
                  Ignoring invalid expression UCHAR_MAX != 255
                  *** Warning in /home/vash/Workspaces/commons/include/python/Python.h near line 33, column 2:
                  Cannot find stdio.h
                  *** Warning in /home/vash/Workspaces/commons/include/python/Python.h near line 38, column 2:
                  Cannot find string.h
                  *** Warning in /home/vash/Workspaces/commons/include/python/Python.h near line 40, column 2:
                  Cannot find errno.h
                  *** Warning in /home/vash/Workspaces/commons/include/python/Python.h near line 42, column 2:
                  Cannot find stdlib.h
                  *** Warning in /home/vash/Workspaces/commons/include/python/Python.h near line 44, column 2:
                  Cannot find unistd.h
                  *** Warning in /home/vash/Workspaces/commons/include/python/Python.h near line 56, column 2:
                  Cannot find assert.h

You said that those warnings are normals in another post. But I get errors because, I think, some declarations aren’t reads from thoses skipped includes.

*** Error in /home/vash/Workspaces/commons/include/python/Python.h near line 22, column 2:
                  "Something's broken.  UCHAR_MAX should be defined in limits.h."

And finaly interrogate can’t release files because of this.

Again, what I have missed ?

Thanks for your help

Add -S/usr/include/panda3d/parser-inc to the command-line.

I have already put this option, without success :frowning:

rdb is right. Something’s wrong with your parser-inc directory.

Make sure that parser-inc appears first on the header path, and that the parser-inc directory you reference actually includes the relevant header files like Python.h.

If you look at parser-inc/Python.h, you’ll see it is just a stub header file that makes a few key typedefs and such necessary to understand Python code within Panda, but that’s all. The point is that our parser-inc/Python.h should be read by interrogate instead of the actual Python.h. Your error message indicates that interrogate is trying to read the actual Python.h, so something has gone wrong.


Ok it was somethings with my paths.

Sometimes panda includes Python files from parser-inc/ and others from original python include files.

I have changed path of include to point on the good folders that contains the right files.

Now interrogate works fine. But I get errors when compiling -_-’’

I have a conflict with typedef declared in Python.h from Panda3d and Python.

Error on py_panda.h :

../../commons/include/python/pyport.h:113:25: error: conflicting declaration ‘typedef ssize_t Py_ssize_t’
../../commons/include/panda3d/parser-inc/Python.h:25:13: error: ‘Py_ssize_t’ has a previous declaration as ‘typedef int Py_ssize_t’

py_panda.h include the Python.h from python, right ?

Maybe I am not supposed to passe in the #if defined(HAVE_PYTHON) && !defined(CPPPARSER)” directive ?

Again, thank you for your help, I do not despair of success the python binding !


It appears that you have picked up the Python.h from parser-inc during your regular compilation step.

It is very important that you do not include the parser-inc header files on the regular compilation step. These header files are not real header files, and they contain invalid definitions for many symbols. Their point is just to define certain types so that interrogate can successfully parse your code (the C language grammar requires the parser to know a priori which symbols are type names, and which are not).


Yeah ! It works ! I found how to set my path for both interrogate and g++ compiling.
Now I can add some python in my dev environment.

Thanks for your unbelievable patience :slight_smile:

BUT ! It’s not completly finished :smiley:. In order to end the whole build process I have a last little problem.
I try to package my new howsome functionnalities into a p3d file. They are in a external homemade lib and called by the wrapped python code. When I lauch python ./, it works fine. But when packaged, panda say my lib were not found.
When I packaged it, the lib was in the same folder. Again, what am I missing ?


A p3d file is designed to contain pure Python code only. If you have a compiled library, you have to add it to a Panda3d “Package”, which is produced using the ppackage tool and a pdef file. When you host this package on your own webserver, you can then reference the package into your own p3d file with the -r parameter to packp3d.


Ok I have looked around the ppackage tool. It seems very powerfull. I’ll try to take advantage of it.

However, for now I’ve got the following error when I launch my p3d file :

ImportError: ****/.panda3d/hosts/localhost_a5557f12ad24718f/cmmPackage/ version `GLIBCXX_3.4.11' not found (required by ****/.panda3d/hosts/localhost_a5557f12ad24718f/cmmPackage/

libstdc++ must be included as package or something ?


What kind of system are you on? Operating system, version?

I’m on GNU/Linux Ubuntu
kernel : 2.6.38
proc : x86_64

It’s the version of Ubuntu that I’m interested in.

oops sorry, I have forgotten :

Ubuntu 11.04 “Natty Narwhal”

Hmm, there’s a conflict going on with two different versions of libstdc++. How exactly did you make this build? Which libraries did you link your program against?