On 5/20/07, Alexander Michael
On 5/18/07, Mowry, Peter
wrote: So I tried ctypes, and it just worked (without any build issues - in fact I didn't have to build anything or write any code). Is there any reason I'd want to write an extend python module (to load my shared library and run exported functions from it) that compiles with distutils, instead of just using ctypes? Thanks
If I can accomplish the task with ctypes, I use it. While distutils generally does a good job with compiling extension modules, using ctypes allows you to avoid distributing platform specific packages which will make your life a bit easier. Additionally, I find it faster to work with ctypes as I can avoid the compile step required for developing extension module.
While ctypes is part of Python 2.5, your users will need to install it for Python 2.3 and 2.4. If you need to target earlier versions of Python (*not as typical these days), then ctypes won't work for you. Unfortunately, ctypes is not available as an egg, so you won't be able to take advantage of setuptool's easy_install to ensure that your user has installed all the dependencies.
Correction: Apparently easy_install handles source packages that aren't eggs, so scratch my scratch comment as it looks like you can specify ctypes as a dependency in order to ensure that it is installed.