Panda Module Builder

Hey everybody!

I’d like to present my module builder, which automates the whole process of distributing a C++ module for use in python, including interrogate and compilation.

Basically you just copy your .cpp files to a directory, run a single command, and you will get a ready-to-use .pyd / .so file, which you can use in your python code.

Download & Source Code: https://github.com/tobspr/P3DModuleBuilder

Usage instructions can be found in the README included in the repository. Its as simple as running

python build.py

It would be cool if you guys could test it, and report if any errors occur!

1 Like

Excellent! Many thanks Tobias for this: I believe this is very useful.

I tried it with VS2015 (I know requirements were stating VS2010…) and CMake is generating an error (excerpt from CMakeError):

XXXX\P3DModuleBuilder-master\P3DModuleBuilder-master\win_amd64\CMakeFiles\3.4.1\CompilerIdC\CompilerIdC.vcxproj(18,3): 
error MSB4019: the import project  "D:\Microsoft.Cpp.Default.props" can't be found. Please check that the path in the <Import> declaration is correct and that the file exists.

Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.

Output in the console is:

Process error:
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:5 (project):
  No CMAKE_C_COMPILER could be found.

CMake Error at CMakeLists.txt:5 (project):
  No CMAKE_CXX_COMPILER could be found.

I would assume that some parameters should be changed to fit with VS2015: if that is the case and if you don’t mind to adjust it, I would be happy to continue to test it.

Thanks!

Hey, thanks for testing!

I had hardcoded VC2010 because I didn’t think anybody would compile Panda with a newer version, however I made it configurable now.

Checkout the updated readme to see how to change the version, I also added a generate_pdb config variable.

Super, thanks so much Tobias.

Your sample class is perfectly working for me.
Note for VS2015 users: the config file should be “Visual Studio 14 2015”

I tried to compile my module (which works with VS2015 as described [url][SOLVED] Issue with Linking Panda classes with Interrogate]), I have several linker errors relating to the Panda classes:

error LNK2019:external symbol not resolved  "__declspec(dllimport) bool __cdecl Dtool_Coerce_LVecBase3f(struct _object *,class LVecBase3f  * &,bool &)" (__imp_?Dtool_Coerce_LVecBase3f@@YA_NPEAU_object@@AEAPEAVLVecBase3f@@AEA_N@Z)

error LNK2019: external symbol not resolved"__declspec(dllimport) bool __cdecl Dtool_Coerce_LVecBase4f

Quick question: as I had the same issue (see [url][SOLVED] Issue with Linking Panda classes with Interrogate]), does the scripts link to ‘core.lib’ (which is required in 1.9x)?

[EDIT]
As a further comment, I have the same issue in the packaging of the pyd (“specified procedure can’t be found”) - see [url]Oh my god!]. I used the one generated with the sample class. Does it work for you?

Thanks!

Well I didn’t link to core.lib, since it it is not included in the official sdks. I added a check tho, so it should get linked if it exists, or got generated with the methods you described.

I haven’t test packaging yet, but I will as soon as I find some time.

EDIT: I get the same error (Using stock P3D 1.9.1, win 32 bit):

C:\Users\tspringe\Downloads\PackP3D>test.win_i386.p3d
:AppRunner: Total Panda3D disk space used: 122 MB
:AppRunner: Configured max usage is: 2048 MB
Mainfile loaded
Traceback (most recent call last):
  File "C:\buildslave\rtdist-windows-i386\build\built\direct\showbase\Messenger.py", line 354, in __
taskChainDispatch
  File "C:\buildslave\rtdist-windows-i386\build\built\direct\showbase\Messenger.py", line 412, in __
dispatch
  File "C:\buildslave\rtdist-windows-i386\build\built\direct\p3d\AppRunner.py", line 716, in __start
IfReady
  File "VFSImporter", line 148, in load_module
  File "Test\main.py", line 5, in <module>
  File "VFSImporter", line 122, in load_module
  File "VFSImporter", line 223, in _import_extension_module
ImportError: DLL load failed: The specified procedure could not be found.
:task(error): Exception occurred in PythonTask Messenger-default
Traceback (most recent call last):
  File "C:\buildslave\rtdist-windows-i386\build\built\direct\p3d\AppRunner.py", line 596, in run
  File "C:\buildslave\rtdist-windows-i386\build\built\direct\task\Task.py", line 510, in run
  File "C:\buildslave\rtdist-windows-i386\build\built\direct\task\Task.py", line 467, in step
  File "C:\buildslave\rtdist-windows-i386\build\built\direct\showbase\Messenger.py", line 354, in __
taskChainDispatch
  File "C:\buildslave\rtdist-windows-i386\build\built\direct\showbase\Messenger.py", line 412, in __
dispatch
  File "C:\buildslave\rtdist-windows-i386\build\built\direct\p3d\AppRunner.py", line 716, in __start
IfReady
  File "VFSImporter", line 148, in load_module
  File "Test\main.py", line 5, in <module>
  File "VFSImporter", line 122, in load_module
  File "VFSImporter", line 223, in _import_extension_module
ImportError: DLL load failed: The specified procedure could not be found.
Failure on startup.

Thanks for the testing!

Thanks Tobias and you are welcome!

The linking is now working and I managed to re-generate my module.

One thing I noticed with the last update you made: it seems that the script is not asking anymore for the module name the first time you launch it. I manually added the "module_name.cfg file in the build.py dir and changed it with the target module name (“TestInterrogate”) but the script is still generating a ‘Test.pyd’ file.

Thank you for the packaging test: at least it seems not (only) caused by my lack of knowledge!!:slight_smile:

Again many thanks

Ah thanks, I accidentally committed a wrong config.ini, it should be fixed now :slight_smile:

You can remove the old module_name.cfg, its not used anymore, and not in the repo any longer, too

Perfect, it works.

Thank you Tobias for this tool and your support!

Hello, I’m using a slightly modified version of this excellent tool, and it works good for me, but I noticed that in the interrogate step the “-nomangle” option is passed, if Panda3D has a newer version. I would like to ask why, because if you build inside the Panda3D code tree there isn’t that option?
Thank you

Without -nomangle, interrogate basically generates two versions of your functions: camelCase and under_score.
Thats why you can call nodepath.set_pos() and nodepath.setPos() for example.

Panda3D currently supports both versions, although the camelCase version is deprecated and will be removed in future versions. The problem is just that the whole direct/ source tree depends on camelCase, which is why its non-trivial to change.

The module builder has no such dependencies, and so I thought it’d be a good way to already encourage users to use the under_score versions of the functions.

I did not know that was deprecated, I will follow the new style of programming.
Thanks for the explanation.