Re: Python 2.6 and wrapping C libraries on Windows



L. Lindstrom schrieb:
I have read that Python extension modules must link to the same C
run-time as the Python interpreter. This I can appreciate. But does this
requirement extend to the C libraries an extension module wraps. The
case in point is Pygame and SDL. The Pygame extension modules are built
with distutils, so for Python 2.6 using Visual Studio 2008 should ensure
the .pyd files link to msvcr90.dll. But SDL is built using Msys/MinGW
and the configure/make tool chain. This fails when linking to
msvcr90.dll since the small test programs configure builds lack manifest
files. They fail to load msvcr90.dll, raising an R6034 error instead. So
besides heap management and FILE pointers, is there any reason SDL, or
any C dependency, needs to link to the same C run-time as Python? If I
ensure SDL frees memory it allocates and does not directly access a file
opened by Python can I just use another C run-time such as msvcrt?


Your analysis of the problem and the implication of mixing CRTs is
correct. However ...

It should be trivial to modify the build systemof SDL so that the
manifest is integrated into the DLLs. Everything else is a hack. It
*should* work and in reality it *does* work for most cases. But someday
you'll hit a solid wall and get strange and hard to debug segfaults.

It's in your own interest to get it right in the first place. And you'd
serve the Python community greatly by providing a nice tutorial how to
modify 3rd party builds. *hint* :)

If you need any help feel free to contact me. The new build system is
mostly my work with help from Martin, Amaury and other core developers.

Christian

.



Relevant Pages

  • Re: Python 2.6 and wrapping C libraries on Windows
    ... Can you confirm this Lenard? ... Has anyone tested the new python binaries that link to msvcr90.dll on ... manifest is integrated into the DLLs. ... If this works I will make SDL and a test ...
    (comp.lang.python)
  • Re: Python 2.6 and wrapping C libraries on Windows
    ... run-time as the Python interpreter. ... requirement extend to the C libraries an extension module wraps. ... But SDL is built using Msys/MinGW ... manifest is integrated into the DLLs. ...
    (comp.lang.python)
  • Re: New SolarWolf, 1.5
    ... All the graphics and sound routines happen inside SDL. ... Pygame does offer the ability to map image pixel data inside Numeric arrays, ... > box) who is running Fedora which still has Python 2.2. ...
    (comp.lang.python)
  • Python 2.6 and wrapping C libraries on Windows
    ... I have read that Python extension modules must link to the same C run-time as the Python interpreter. ... The Pygame extension modules are built with distutils, so for Python 2.6 using Visual Studio 2008 should ensure the .pyd files link to msvcr90.dll. ... But SDL is built using Msys/MinGW and the configure/make tool chain. ... This fails when linking to msvcr90.dll since the small test programs configure builds lack manifest files. ...
    (comp.lang.python)
  • Re: extension module, thread safety?
    ... If the threads under discussion are all Python threads, ... the extension module C functions will appear to be atomic ... the GIL (global interpreter lock) is still ... GIL, no other Python threads can execute (even though those threads ...
    (comp.lang.python)