From aabf968e7a425e1b15826b1d15f8df94561479c5 Mon Sep 17 00:00:00 2001 From: Jason Erickson Date: Mon, 3 Jan 2011 17:14:50 -0700 Subject: [PATCH] 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. --- psycopg/_psycopg.vc9.manifest | 15 +++++++++++++++ setup.py | 20 ++++++++++++++++++++ 2 files changed, 35 insertions(+), 0 deletions(-) create mode 100644 psycopg/_psycopg.vc9.manifest diff --git a/psycopg/_psycopg.vc9.manifest b/psycopg/_psycopg.vc9.manifest new file mode 100644 index 0000000..23dcb4d --- /dev/null +++ b/psycopg/_psycopg.vc9.manifest @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/setup.py b/setup.py index 7faefd4..68732bc 100644 --- a/setup.py +++ b/setup.py @@ -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. @@ -133,6 +134,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 -- 1.7.0.2.msysgit.0