Panda Module Builder

Return to Panda Features in Development

Panda Module Builder

Postby tobspr » Fri Dec 04, 2015 1:33 pm

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

Code: Select all
python build.py


It would be cool if you guys could test it, and report if any errors occur!
User avatar
tobspr
 
Posts: 402
Joined: Wed Apr 10, 2013 11:03 am
Location: Germany

Re: Panda Module Builder

Postby Melan » Sat Dec 05, 2015 1:47 am

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):

Code: Select all
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:
Code: Select all
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!
Melan
 
Posts: 63
Joined: Sat Oct 19, 2013 3:04 am

Re: Panda Module Builder

Postby tobspr » Sat Dec 05, 2015 2:54 am

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.
User avatar
tobspr
 
Posts: 402
Joined: Wed Apr 10, 2013 11:03 am
Location: Germany

Re: Panda Module Builder

Postby Melan » Sat Dec 05, 2015 4:23 am

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 https://www.panda3d.org/forums/viewtopic.php?f=12&t=18348), I have several linker errors relating to the Panda classes:

Code: Select all
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 https://www.panda3d.org/forums/viewtopic.php?f=12&t=18348), 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 https://www.panda3d.org/forums/viewtopic.php?f=1&t=18074&start=30. I used the one generated with the sample class. Does it work for you?

Thanks!
Melan
 
Posts: 63
Joined: Sat Oct 19, 2013 3:04 am

Re: Panda Module Builder

Postby tobspr » Sat Dec 05, 2015 5:11 am

Melan wrote: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 https://www.panda3d.org/forums/viewtopic.php?f=12&t=18348), I have several linker errors relating to the Panda classes:

Code: Select all
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 https://www.panda3d.org/forums/viewtopic.php?f=12&t=18348), 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 https://www.panda3d.org/forums/viewtopic.php?f=1&t=18074&start=30. 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):

Code: Select all
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!
User avatar
tobspr
 
Posts: 402
Joined: Wed Apr 10, 2013 11:03 am
Location: Germany

Re: Panda Module Builder

Postby Melan » Sat Dec 05, 2015 6:12 am

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!!:-)

Again many thanks
Melan
 
Posts: 63
Joined: Sat Oct 19, 2013 3:04 am

Re: Panda Module Builder

Postby tobspr » Sat Dec 05, 2015 6:18 am

Melan wrote: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.


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

You can remove the old module_name.cfg, its not used anymore, and not in the repo any longer, too
User avatar
tobspr
 
Posts: 402
Joined: Wed Apr 10, 2013 11:03 am
Location: Germany

Re: Panda Module Builder

Postby Melan » Sat Dec 05, 2015 8:56 am

Perfect, it works.

Thank you Tobias for this tool and your support!
Melan
 
Posts: 63
Joined: Sat Oct 19, 2013 3:04 am

Re: Panda Module Builder

Postby consultit » Sat Apr 16, 2016 12:42 am

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
User avatar
consultit
 
Posts: 79
Joined: Wed Nov 30, 2011 7:41 am

Re: Panda Module Builder

Postby tobspr » Sat Apr 16, 2016 3:02 am

consultit wrote: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.
User avatar
tobspr
 
Posts: 402
Joined: Wed Apr 10, 2013 11:03 am
Location: Germany

Re: Panda Module Builder

Postby consultit » Sat Apr 16, 2016 5:13 am

I did not know that was deprecated, I will follow the new style of programming.
Thanks for the explanation.
User avatar
consultit
 
Posts: 79
Joined: Wed Nov 30, 2011 7:41 am


Return to Panda Features in Development

Who is online

Users browsing this forum: No registered users and 3 guests