By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,965 Members | 1,690 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,965 IT Pros & Developers. It's quick & easy.

Migrate PYD Files

P: n/a
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
Sep 8 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
David Duerrenmatt wrote:
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>

Sep 8 '05 #2

P: n/a
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.
Sep 8 '05 #3

P: n/a
David Duerrenmatt wrote:
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

Sep 8 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.