Extensions on Windows, questions for experts.
Alex Martelli
aleax at aleax.it
Tue Jan 15 03:55:10 EST 2002
"Michel Van den Bergh" <vdbergh at luc.ac.be> wrote in message
news:3C43EA4B.92029F2 at luc.ac.be...
...
> 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
> GetProcAddress.
(4) ensure the data structures your extension is using are
aligned with those in the Python DLL you're loading. This is
really the only truly-delicate step. No macros can help, as
those get solved at compile-time and the structures' layout
may change afterwards.
> 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 think you'd need a different proxy DLL each time the Python's DLL
structures' layout changes (or more functions are added to the
Python C API). But, that proxy DLL might then take care of all
extensions; besides, I think structures' layout don't change as
often as Python's major/minor version numbers.
> I was planning to try out this idea. However I would like to know:
>
> (1) Is this idea not fundamentally flawed for some reason?
No, but it will take a lot of careful work.
> (2) Has somebody else done it already?
No, probably because it will take a lot of careful work:-).
Alex
More information about the Python-list
mailing list