~ubuntu-branches/ubuntu/lucid/python2.6/lucid

« back to all changes in this revision

Viewing changes to Lib/distutils/msvc9compiler.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2010-03-11 13:30:19 UTC
  • mto: (10.1.13 sid)
  • mto: This revision was merged to the branch mainline in revision 44.
  • Revision ID: james.westby@ubuntu.com-20100311133019-sblbooa3uqrkoe70
Tags: upstream-2.6.5~rc2
ImportĀ upstreamĀ versionĀ 2.6.5~rc2

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#   finding DevStudio (through the registry)
13
13
# ported to VS2005 and VS 2008 by Christian Heimes
14
14
 
15
 
__revision__ = "$Id: msvc9compiler.py 68082 2008-12-30 23:06:46Z tarek.ziade $"
 
15
__revision__ = "$Id: msvc9compiler.py 76652 2009-12-03 20:56:15Z martin.v.loewis $"
16
16
 
17
17
import os
18
18
import subprocess
19
19
import sys
 
20
import re
20
21
from distutils.errors import (DistutilsExecError, DistutilsPlatformError,
21
22
    CompileError, LibError, LinkError)
22
23
from distutils.ccompiler import (CCompiler, gen_preprocess_options,
641
642
            # will still consider the DLL up-to-date, but it will not have a
642
643
            # manifest.  Maybe we should link to a temp file?  OTOH, that
643
644
            # implies a build environment error that shouldn't go undetected.
644
 
            mfid = 1 if target_desc == CCompiler.EXECUTABLE else 2
 
645
            if target_desc == CCompiler.EXECUTABLE:
 
646
                mfid = 1
 
647
            else:
 
648
                mfid = 2
 
649
                try:
 
650
                    # Remove references to the Visual C runtime, so they will
 
651
                    # fall through to the Visual C dependency of Python.exe.
 
652
                    # This way, when installed for a restricted user (e.g.
 
653
                    # runtimes are not in WinSxS folder, but in Python's own
 
654
                    # folder), the runtimes do not need to be in every folder
 
655
                    # with .pyd's.
 
656
                    manifest_f = open(temp_manifest, "rb")
 
657
                    manifest_buf = manifest_f.read()
 
658
                    manifest_f.close()
 
659
                    pattern = re.compile(
 
660
                        r"""<assemblyIdentity.*?name=("|')Microsoft\."""\
 
661
                        r"""VC\d{2}\.CRT("|').*?(/>|</assemblyIdentity>)""",
 
662
                        re.DOTALL)
 
663
                    manifest_buf = re.sub(pattern, "", manifest_buf)
 
664
                    pattern = "<dependentAssembly>\s*</dependentAssembly>"
 
665
                    manifest_buf = re.sub(pattern, "", manifest_buf)
 
666
                    manifest_f = open(temp_manifest, "wb")
 
667
                    manifest_f.write(manifest_buf)
 
668
                    manifest_f.close()
 
669
                except IOError:
 
670
                    pass
645
671
            out_arg = '-outputresource:%s;%s' % (output_filename, mfid)
646
672
            try:
647
673
                self.spawn(['mt.exe', '-nologo', '-manifest',