makepanda/interrogate questions

I am trying to simply compile an extension. This has worked, basically cloning the skel folder and renaming everything. I then copied the skel directory stuff in After some tweaking, it worked.

However, I have some questions about the various files in this directory:

  1. Is sources.pp required for makepanda?
  2. what role does the composite files play? Every directory seems to have multiple of them, but the skel ones seemed simply to include the other composite file, which simply included everything else. Is having two composite files necessary?
  3. What is the difference between panda’s INLINE and the normal inline? Do I have to have a *.I file with all the INLINE functions or can I define them in the header/source file? (I am not talking about good coding, simply what makepanda/interrogate require).
  4. What is PUBLISHED doing exactly? Are there any more “special” panda specific keywords?

I am on windows xp, if that makes any difference.

Thanks again!

No, it is only required for ppremake.

To speed up compiling, so several files can be compiled at the same time. When directories get too big, we have to split the composites so the compiler won’t take up too much memory.

It’s just a convention. Makepanda doesn’t require either. You can’t put inline functions in the source file, though, because they need to be available by including the header file.

PUBLISHED is just like public, but Interrogate will generate Python wrappers for PUBLISHED functions, not for public.

There’s also BEGIN_PUBLISH and END_PUBLISH, which can be used to bracket a set of global functions, typedefs, or enum declarations–things outside of a class body that still want to be published.

There’s also BLOCKING, which tags a method to indicate that the method performs I/O or something along those lines which might cause an automatic context switch within Panda, but the method itself won’t be making any unprotected calls back into Python, and so the Python GIL (Global Interpreter Lock) should be released during the method call to allow other Python threads to run in parallel. This one is fairly subtle, and if you don’t understand it, you don’t need to use it; it’s just a small optimization for when you’re using Python threading.

Finally, there’s the new MAKE_SEQ() macro, which synthesizes a sequence
method. For instance, GeomNode defines get_num_geoms() and get_geom(), which can be used to iterate through the list of Geoms stored on a GeomNode. Then MAKE_SEQ() is used to synthesize a new Python method getGeoms(), which returns a Python list of Geoms, for the Python programmer’s convenience.

You can see the macro definitions for these special keywords in dtoolbase.h. Most of them are defined to map to special interrogate keywords when running interrogate (CPPPARSER is defined), or to nothing at all (or “public”) when running the normal compiler (CPPPARSER is not defined).


another question…

I have noticed that skel has a bunch of configure things to fix this, and treeform has a relatively simpler way, but neither seem to be working. What is the minimum required to get interrogate to put an init function in the dll?
ImportError: dynamic module does not define init function (inittest)

The minimum required? I dunno. You do need to define at least one published method, and you need to run interrogate_module.

These are necessary, but not sufficient, conditions. I guess there are probably a dozen different things you could do wrong to make interrogate fail to generate a module. It’s kind of like asking what’s the minimum you have to do to make the compiler accept your program without giving any errors. :slight_smile:


no,no sorry if I was not clear…

I am trying to import the generated dll file into python, and it is giving me this error
ImportError: dynamic module does not define init function (inittest)

I am trying to figure out what I have to do to fix it. I have seen two implementations (one from treeforms old pyro4 code and the skel) and can get neither to work. I am also using the following code to import it into python (copied again from treeform)

	import test
	import imp
	import sys
	if 'win' in sys.platform:
		module = imp.load_dynamic( "test", "test.dll")
		sys.modules["test"] = module
from test import TestClass

Right, that’s a very common symptom, it either means that interrogate didn’t generate any code, or that you supplied the wrong module name, or that you didn’t link in the generated code properly, or any of a dozen different things that might have gone wrong.

Since you did get a dll, it means it went at least partly right. But it’s hard for me to speculate on which part of it didn’t get the rest of the way right, since there are lots of different things that can cause that symptom.

You might start looking backward. Examine the generated .cxx file to see if the named module function is there. If it is, check to see if the symbol made it into the dll (e.g. with dumpbin /exports). If it isn’t, check to see if you missed any parameters to interrogate.

It’s surprising to me that it doesn’t even work on the skel directory. That should work out of the box. Are you compiling it out of the box?


Make sure you didn’t forget to link in the _igate.cxx and _module.cxx files, and that the specified -module argument is the same in both the interrogate and interrogate_module call. You can check that by checking the _module.cxx file, and checking how the function is called - should be inittest.
Also, if you rename your .dll into .pyd, you can import it without the ugly imp.load_dynamic. :slight_smile:

I’ve just discovered that skel doesn’t, in fact, work out of the box, at least not using ppremake. The ppremake scripts fail to generate the interrogate_module command for the skel directory. This causes exactly the problem described above (the lack of initlibskel). My apologies; how embarrassing!

I’m committing a fix to the ppremake scripts for this problem now. I think ppremake has never handled skel properly; but I think makepanda has always done it right. (Skel was added by a user of makepanda, not ppremake, and I suspect he never tested it under ppremake.)


Thanks for your help; I managed to get it working (it was a combination of a couple of problems)…

Would it be useful if there was a script that you could run on your cxx file that would automatically build a dll out of it using everything from an already compiled panda?

Like there is another program inside of the bin folder that when called with a c++ directory/file does all of this stuff automatically? I have gotten a rough way of doing this; it seems to work well…Would it be useful if I cleaned it up? (otherwise I won’t put the effort into it). How much does the makepanda system change from update to update?