Migrate PYD Files

  • Thread starter David Duerrenmatt
  • Start date
D

David Duerrenmatt

Is there a way to use old pyd files (Python 1.5.2) with a newer version
of Python without recompiling them?

Because the source code is not available anymore, I'm wondering whether
it's possible or not to change few bytes with a hex editor (version
number?). I'd like to give it a try since the modules don't use too
critical functions.

Thanks
dd
 
F

Fredrik Lundh

David said:
Is there a way to use old pyd files (Python 1.5.2) with a newer version
of Python without recompiling them?
Because the source code is not available anymore, I'm wondering whether
it's possible or not to change few bytes with a hex editor (version
number?). I'd like to give it a try since the modules don't use too
critical functions.

on windows, Python PYD files are linked against that version of the Python
interpreter DLL (python15.dll, python22.dll, etc). you could perhaps try
changing any occurence of "python15" to "python23" and see how get far
you get...

(another approach would be to develop a custom "python15.dll" which
implements the necessary operations and maps them to the appropriate
Python interpreter DLL (using LoadLibrary/GetProcAddress for "manual"
linking. use "dumpbin /exports" on your PYD to see what Python API:s
it's using)

</F>
 
F

fraca7

David Duerrenmatt a écrit :
Is there a way to use old pyd files (Python 1.5.2) with a newer version
of Python without recompiling them?

No. In general, incrementing the middle version number means that the
Python C API has changed in an incompatible manner. There are some
exceptions (2.2 modules may work in 2.3) but there's no way you can use
a 1.5 .pyd with Python >= 2.2. As far as I know.
 
K

Kay Schluehr

David said:
Is there a way to use old pyd files (Python 1.5.2) with a newer version
of Python without recompiling them?

Because the source code is not available anymore, I'm wondering whether
it's possible or not to change few bytes with a hex editor (version
number?). I'd like to give it a try since the modules don't use too
critical functions.

Thanks
dd

Hi David,

you might checkout embedding your Python 1.5.2 interpreter into Python
using ctypes. Just follow chap.5 of the "Extending and Embedding"
tutorial and the docs of the cytpes API.

The following little script runs successfully on Python23 interpreter.

======================================================================

import ctypes
python24 = ctypes.cdll.LoadLibrary("python24.dll")
python24.Py_Initialize()
python24.PyRun_SimpleString("from time import time,ctime\n")
python24.PyRun_SimpleString("print 'Today is',ctime(time())\n");
python24.Py_Finalize()

Kay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top