I have a third party, closed source library coming as a windows dll built with visual studio 2010. First, I planned building an extension module for that dll using e.g. SWIG. However that's spoiled by the fact that it's build with VS 2010, whereas all python 2 distributions are built with VS 2008.
Now it seems ctypes doesn't have this limitation.
I've built a trivial dll using VS 2010 (dependency walker shows the dll is linked to msvcr100.dll
) with a function:
int fnTestLib2(int a, int b)
{
return a+b;
}
loaded it in ctypes and
fcn = mydll.fnTestLib2
fcn.argtypes = [ctypes.c_int, ctypes.c_int]
fcn.restype = ctypes.c_int
print fcn(1,2)
correctly prints 3
.
Now, I'm somewhat confused:
Is this just because I'm lucky and because the example is trivial or is there a fundamental difference in the underlying technique of ctypes
and an extension module?
If yes, what is it? ;)
And finally: would it be safe to implement a ctypes wrapper library for that third party dll?
EDIT Upon Serge's answer I compiled my swig extension using distutils in combination with the Windows SDK. So, now I have my extension bla.pyd and it indeed seems to work. Though I'm wondering if the this dependency on two c runtimes is recommendable or not. Looking at it with dependency walker: