- E02 - Support for MinGW Open Source Compiler

Fredrik Lundh fredrik at pythonware.com
Mon Feb 14 15:24:33 EST 2005


Stephen Kellett wrote:

>>if I have both versions of Python installed - 2.3.5 and 2.4?  Is there
>>an easy way to detect this and switch between the two dlls?
>
> Easy? Depends what you call easy.

in the context of "building a C extension when you have multiple versions
installed", the answer is "easy".  setup.py automatically finds the right DLL,
mingw seems take care of the rest.

> a) You just need to detect if pythonNN.dll is implicitly linked to msvcrt.dll or msvcrXX.dll 
> (where XX indicates a VS studio number, currently XX can only be 71, but if Python is done for 
> Visual Studio 2005 (8.0) then XX may also have a value of 80).
>
> b) GetModuleHandle(name of DLL from a) to get the DLL handle.
>
> c) GetProcAddress on the respective to get the C runtime function you want to call (for example, 
> fopen).
>
> d) call the function.
>
> You either need (a) or all of (a)...(d) depending on what you are doing. Those embedding Python 
> but no idea of the Python version in advance will do the latter.

if someone needs code that does it all, check the exemaker sources:

    http://effbot.org/zone/exemaker.htm

</F> 






More information about the Python-list mailing list