Python Forum
Embedding Python into a simulator - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Embedding Python into a simulator (/thread-17811.html)



Embedding Python into a simulator - siggi - Apr-24-2019

I am trying to embed python in a commercial Discrete Event Simulator (ExtendSim). The simulator offers an extension programming environment which also contains a DLL interface. The simulator is a 64 bit application. My plan is therefore to link to python37.dll, initialize Python and run a function from a python text which is loaded. I managed to get quite far with the initialization part and it seems that the DLL calls work as intended. Still I run into problems with some functions, namely PyTuple_SetItem (used to generate and argument list for the function I want to call) and PyFloat_Check (inserted mainly as a precaution, could be deleted, but should work). The former returns -1, without any obvious reason (the tuple is generated, long enough and I have a pointer which seems valid). The latter crashes the whole simulator (again, the PyFloat is generated and there seems to be a valid pointer). Is there anybody out there with experience from these 'low level' issues? What is wrong and how can it be resolved?