Extensions on Windows, questions for experts.

Michel Van den Bergh vdbergh at luc.ac.be
Tue Jan 15 03:37:06 EST 2002


This is a followup on the recent trend on extensions on Windows.

The problem is that extensions on Windows depend on the Python
version. This is because references to pythonxx.dll need to be resolved
at compile time (through the import library).

However Windows also has a mechanism for resolving references
to dll's at runtime (through LoadLibrary and GetProcAddress).

Has anybody used this to produce Python-version independent
extensions? The steps one would need to take are:

(1) Find current version of Python in registry.
(2) Perform LoadLibrary("pythonxx.dll")
(3) Resolve reference to functions in the C-extension API through

This seems like a lot of work but a tool like SWIG could do it

Perhaps an even better idea would be to link agains a dll
named something like "python_proxy.dll" which would perform
steps (1)-(3). Then C-extensions would not have to be modified
at all. The only thing necessary is to distribute python_proxy.dll
with your application.

I was planning to try out this idea. However I would like to know:

(1) Is this idea not fundamentally flawed for some reason?
(2) Has somebody else done it already?

Best regards,

More information about the Python-list mailing list