Dynamically compiling and reloading SWIG .pyd file

D

Dave Guthrie

I am creating an application which has it's code split between python
and C. The Python is used to provide a high level GUI interface and
the C is for low level functions. I use SWIG to create Python Bindings
for the C functions. I want to implement a feature where there is a
button in the toolbar of the GUI which will automatically compile the
C code into a .pyd file. The problem I have is when the GUI is
running, the .pyd is loaded as a DLL and thus is locked by the GUI, so
I can't get "gcc" to overwrite the .pyd file.

I have tried to force the GUI to close it's handle on the file

handle =
ctypes.windll.kernel32.GetModuleHandleA("_FirmwareSubSys.pyd")

if handle == 0:
print "_FirmwareSubSys.pyd not loaded"
else:
_ctypes.FreeLibrary(handle)

But by doing this the next time I load the DLL python crashes.

Do anyone know how to dynamically compile and load SWIG Python
Bindings?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,069
Latest member
SimplyleanKetoReviews

Latest Threads

Top