Win32 Libs for 2.4

Daniel Dittmar daniel.dittmar at sap.corp
Mon Dec 6 08:56:54 EST 2004


Robin Becker wrote:
> Does anyone know if it is feasible to have static libraries for both 2.3 
> and 2.4 compatible extensions. I'm worrying about libjpeg etc in a win32 
> environment.

Could you be a bit more specific:

do you want to create a binary python extension that is compatible with 
both Python 2.3 and Python 2.4.

Or do you want to create a static lib containing both the original C lib 
and the code for your extension? This Lib should then be linked with the 
proper python2*.lib to create a version specific binary extension.

Or something else?

The first one is not possible as far as I know because python2*.lib 
tries to load a specific python2*.dll. You could try to replace static 
DLL import with dynamic DLL import (loading the DLL explizit and getting 
the function pointers by name). That would be a lot of work and I don't 
know how well it works for global variables (like all the type objects). 
On the other hand, many people find it annoying that you have to build 
new exte8ensions for every Python version, so this could be something a 
lot of people have an interest in.

I solved this problem by putting .pyd for several versions into the 
download. The right one is picked at runtime by checking sys.version.

Creating one lib which is then linked to python2*.lib works most of the 
time, but you'll probably get a warning during loading of the module 
that the extension has been compiled for a different version of the API.

Daniel



More information about the Python-list mailing list