Migrate PYD Files

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • David Duerrenmatt

    #1

    Migrate PYD Files

    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
  • Fredrik Lundh

    #2
    Re: Migrate PYD Files

    David Duerrenmatt wrote:
    [color=blue]
    > Is there a way to use old pyd files (Python 1.5.2) with a newer version
    > of Python without recompiling them?[/color]
    [color=blue]
    > 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.[/color]

    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.d ll" 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>



    Comment

    • fraca7

      #3
      Re: Migrate PYD Files

      David Duerrenmatt a écrit :
      [color=blue]
      > Is there a way to use old pyd files (Python 1.5.2) with a newer version
      > of Python without recompiling them?[/color]

      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.

      Comment

      • Kay Schluehr

        #4
        Re: Migrate PYD Files

        David Duerrenmatt wrote:[color=blue]
        > 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[/color]

        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.Loa dLibrary("pytho n24.dll")
        python24.Py_Ini tialize()
        python24.PyRun_ SimpleString("f rom time import time,ctime\n")
        python24.PyRun_ SimpleString("p rint 'Today is',ctime(time( ))\n");
        python24.Py_Fin alize()

        Kay

        Comment

        Working...