[Python-Dev] compiling python2.5 (msys+mingw+wine) using msvcr80 assemblies

Luke Kenneth Casson Leighton lkcl at lkcl.net
Mon Jan 19 21:53:07 CET 2009


folks, hi,
after some quiet advice i've tracked down a method for compiling
python2.5 using msvcr80 that _will_ actually work both under native
win32 and also under wine, but it's a _bit_ dodgy, as i couldn't track
down where you're supposed to put Microsoft.VC80.CRT, except in the
path of the application where it's running from.  so, instead, i put
the _contents_ of Microsoft.VC80.CRT.manifest into the manifest for
the file, and this _does_ actually seem to work.
i'm thinking of adding the Microsoft.VC80.CRT.manifest to the rc file
(for compilation as a resource) to see if _that_ works, and will
report back, but first i wanted to describe what i've done and see
what people think:

1) created python_2.5_8.0_mingw_exe.manifest contents as follows, this
is _normally_ what is in Microsoft.VC80.CRT _not_ in the .exe.manifest

<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
    <file name="msvcr80.dll"
hash="10f4cb2831f1e9288a73387a8734a8b604e5beaa"
hashalg="SHA1"><asmv2:hash
xmlns:asmv2="urn:schemas-microsoft-com:asm.v2"
xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"><dsig:Transforms><dsig:Transform
Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity"></dsig:Transform></dsig:Transforms><dsig:DigestMethod
Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></dsig:DigestMethod><dsig:DigestValue>n9On8FItNsK/DmT8UQxu6jYDtWQ=</dsig:DigestValue></asmv2:hash></file>
        <file name="msvcp80.dll"
hash="b2082dfd3009365c5b287448dcb3b4e2158a6d26"
hashalg="SHA1"><asmv2:hash
xmlns:asmv2="urn:schemas-microsoft-com:asm.v2"
xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"><dsig:Transforms><dsig:Transform
Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity"></dsig:Transform></dsig:Transforms><dsig:DigestMethod
Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></dsig:DigestMethod><dsig:DigestValue>0KJ/VTwP4OUHx98HlIW2AdW1kuY=</dsig:DigestValue></asmv2:hash></file>
            <file name="msvcm80.dll"
hash="542490d0fcf8615c46d0ca487033ccaeb3941f0b"
hashalg="SHA1"><asmv2:hash
xmlns:asmv2="urn:schemas-microsoft-com:asm.v2"
xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"><dsig:Transforms><dsig:Transform
Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity"></dsig:Transform></dsig:Transforms><dsig:DigestMethod
Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></dsig:DigestMethod><dsig:DigestValue>YJuB+9Os2oxW4mY+2oC/r8lICZE=</dsig:DigestValue></asmv2:hash></file>
</assembly>

2) created python_2.5_8.0_mingw_exe.rc contents as follows:

#include "winuser.h"
2 RT_MANIFEST PC/python_2.5_8.0_mingw_exe.manifest

you could get away with 2 24 PC/..... and could exclude the #include

3) added a rule to Makefile.pre.in to create the .res as a binary:

# This rule builds the .res file for the Python EXE, required when
# linking and using msvcrt80 or above.  good luck to us all...
$(PYTHONEXEMSVRES): $(srcdir)/PC/python_$(VERSION)_$(MSRTVER)_exe.manifest \
                    $(srcdir)/PC/python_$(VERSION)_$(MSRTVER)_mingw_exe.rc
    windres --input $(srcdir)/PC/python_$(VERSION)_$(MSRTVER)_mingw_exe.rc \
            --output $(PYTHONEXEMSVRES) \
            --output-format=coff

4) added $(PYTHONEXEMSVRES) to the objects to be linked.


stunningly, this actually works (of course, you need an msvcr80.dll
for it to work duh).

i tried finding a location to place the Microsoft.VC80.CRT.Manifest,
prior to this hack - a wine dump showed this:

0009:trace:actctx:lookup_assembly looking for
name=L"Microsoft.VC80.CRT" version=8.0.50727.762 arch=L"x86"
0009:trace:heap:RtlAllocateHeap (0x110000,00000002,00000038): returning 0x115148
0009:trace:file:RtlDosPathNameToNtPathName_U
(L"C:\\windows\\winsxs\\manifests",0xff8c7d08,(nil),(nil))
0009:trace:file:RtlGetFullPathName_U
(L"C:\\windows\\winsxs\\manifests" 520 0xff8c79f4 (nil))

attempts to copy the manifest into that directory resulted in "no joy".

so, i'm a bit stuck, and would appreciate some advice on whether the
above is acceptable (yes i know it makes sure that python.exe can only
use one _very_ specific version of msvcr80.dll - and there are
currently two: 8.0.50727.762 and 8.0.50608.0.

also i'd appreciate some advice on what the _really_ best way to do this is.

and on where the hell i'm supposed to put the VC80.CRT manifest so it
will actually... _do_ something!

l.


More information about the Python-Dev mailing list