Change win32 build to reinsert VC Library Manifest

Added a change at the end of the build process that would reinsert the VC library manifest.  This patch will fix issues when an embedded program does not have a manifest pointing to the VC 2008 runtime library, such as in an apache/mod_python situation.

Signed-off-by: Jason Erickson <jerickso@stickpeople.com>
This commit is contained in:
Jason Erickson 2011-01-03 17:14:50 -07:00
parent 88cc5a986d
commit 8d28509f49
2 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
</requestedPrivileges>
</security>
</trustInfo>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.vc90.CRT" version="9.0.21022.8" processorArchitecture="*" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
</dependentAssembly>
</dependency>
</assembly>

View File

@ -52,6 +52,7 @@ from distutils.errors import DistutilsFileError
from distutils.command.build_ext import build_ext
from distutils.sysconfig import get_python_inc
from distutils.ccompiler import get_default_compiler
from distutils.dep_util import newer_group
# Take a look at http://www.python.org/dev/peps/pep-0386/
# for a consistent versioning pattern.
@ -130,6 +131,25 @@ class psycopg_build_ext(build_ext):
def get_pg_config(self, kind):
return get_pg_config(kind, self.pg_config)
def build_extension(self, ext):
build_ext.build_extension(self, ext)
# For MSVC compiler and Python 2.6/2.7 (aka VS 2008), re-insert the
# Manifest into the resulting .pyd file.
sysVer = sys.version_info[:2]
if self.get_compiler().lower().startswith('msvc') and \
sysVer in ((2,6), (2,7)):
sources = list(ext.sources)
ext_path = self.get_ext_fullpath(ext.name)
depends = sources + ext.depends
if not (self.force or newer_group(depends, ext_path, 'newer')):
return
self.compiler.spawn(['mt.exe', '-nologo', '-manifest',
os.path.join('psycopg', '_psycopg.vc9.manifest'),
'-outputresource:%s;2' % (os.path.join(self.build_lib, 'psycopg2', '_psycopg.pyd'))])
def finalize_win32(self):
"""Finalize build system configuration on win32 platform."""
import struct