[Numpy-svn] r6078 - in trunk: . numpy/distutils numpy/distutils/command
numpy-svn at scipy.org
numpy-svn at scipy.org
Mon Nov 17 09:09:50 EST 2008
Author: cdavid
Date: 2008-11-17 08:09:39 -0600 (Mon, 17 Nov 2008)
New Revision: 6078
Modified:
trunk/
trunk/numpy/distutils/command/config.py
trunk/numpy/distutils/mingw32ccompiler.py
Log:
Merged revisions 6041-6077 via svnmerge from
http://svn.scipy.org/svn/numpy/branches/visualstudio_manifest
................
r6042 | cdavid | 2008-11-16 18:04:37 +0900 (Sun, 16 Nov 2008) | 3 lines
Initialized merge tracking via "svnmerge" with revisions "1-6041" from
http://svn.scipy.org/svn/numpy/trunk
................
r6045 | cdavid | 2008-11-16 20:44:02 +0900 (Sun, 16 Nov 2008) | 1 line
Add a function to get the content of the xml version of manifest to deal with VS.
................
r6046 | cdavid | 2008-11-16 20:44:18 +0900 (Sun, 16 Nov 2008) | 1 line
Add comment on how to get exact MSVCR version.
................
r6047 | cdavid | 2008-11-16 20:44:33 +0900 (Sun, 16 Nov 2008) | 1 line
Add manifest_rc to generate the .rc file which will be used to embed the manifest file.
................
r6048 | cdavid | 2008-11-16 20:44:54 +0900 (Sun, 16 Nov 2008) | 1 line
Use directly the manifest name for generating the rc file + add docstring.
................
r6049 | cdavid | 2008-11-16 20:45:09 +0900 (Sun, 16 Nov 2008) | 1 line
Forgot to change argument of manifest_rc.
................
r6051 | cdavid | 2008-11-16 22:02:09 +0900 (Sun, 16 Nov 2008) | 17 lines
Merged revisions 6042-6050 via svnmerge from
http://svn.scipy.org/svn/numpy/trunk
........
r6043 | jarrod.millman | 2008-11-16 18:14:01 +0900 (Sun, 16 Nov 2008) | 2 lines
removing some quotes
........
r6044 | jarrod.millman | 2008-11-16 18:15:59 +0900 (Sun, 16 Nov 2008) | 2 lines
adding back a few quotes
........
r6050 | cdavid | 2008-11-16 21:30:17 +0900 (Sun, 16 Nov 2008) | 1 line
Add deprecation warning for get_output and try_run: we should not use it anymore.
........
................
r6052 | cdavid | 2008-11-16 22:04:59 +0900 (Sun, 16 Nov 2008) | 1 line
Trailing spaces.
................
r6056 | cdavid | 2008-11-17 21:03:57 +0900 (Mon, 17 Nov 2008) | 1 line
Detect whether config link needs embedding the manifest for the MSVC runtime.
................
r6057 | cdavid | 2008-11-17 21:04:27 +0900 (Mon, 17 Nov 2008) | 1 line
Refactor msvc runtime checking, put it into mingw32compiler
................
r6058 | cdavid | 2008-11-17 21:05:01 +0900 (Mon, 17 Nov 2008) | 1 line
Fix string formatting.
................
r6059 | cdavid | 2008-11-17 21:05:29 +0900 (Mon, 17 Nov 2008) | 1 line
fix imports.
................
r6060 | cdavid | 2008-11-17 21:05:56 +0900 (Mon, 17 Nov 2008) | 1 line
Generate the xml manifest file.
................
r6061 | cdavid | 2008-11-17 21:06:26 +0900 (Mon, 17 Nov 2008) | 1 line
Separate function to get the configtest name.
................
r6062 | cdavid | 2008-11-17 21:06:58 +0900 (Mon, 17 Nov 2008) | 1 line
Generate the rc file for manifest embedding.
................
r6063 | cdavid | 2008-11-17 21:07:36 +0900 (Mon, 17 Nov 2008) | 1 line
Fix configtest and manifest_name.
................
r6064 | cdavid | 2008-11-17 21:08:08 +0900 (Mon, 17 Nov 2008) | 1 line
temp_files is a list of filenames, not files.
................
r6065 | cdavid | 2008-11-17 21:08:38 +0900 (Mon, 17 Nov 2008) | 1 line
Disable .rc generation for manifest: having the xml file in the same dir as the _configtest.exe is enough for now.
................
r6066 | cdavid | 2008-11-17 21:09:08 +0900 (Mon, 17 Nov 2008) | 1 line
Refactor manifest generation and put it back into mingw32ccompiler module.
................
r6067 | cdavid | 2008-11-17 21:32:46 +0900 (Mon, 17 Nov 2008) | 1 line
Fix spelling.
................
r6071 | cdavid | 2008-11-17 21:49:26 +0900 (Mon, 17 Nov 2008) | 30 lines
Merged revisions 6051-6070 via svnmerge from
http://svn.scipy.org/svn/numpy/trunk
........
r6053 | charris | 2008-11-17 12:27:28 +0900 (Mon, 17 Nov 2008) | 1 line
Test moving generic loops to umathmodule.
........
r6054 | charris | 2008-11-17 12:27:46 +0900 (Mon, 17 Nov 2008) | 2 lines
Add umathmodule.c.src to files scanned for ufunc api.
This is preparation for splitting the umathmodule.c.src file.
........
r6055 | pierregm | 2008-11-17 16:00:42 +0900 (Mon, 17 Nov 2008) | 1 line
simplify MAError
........
r6068 | cdavid | 2008-11-17 21:35:43 +0900 (Mon, 17 Nov 2008) | 1 line
Simplify ftime workaround for python 2.6 under mingw: we only need to make _ftime an alias to _ftime64 when needed.
........
r6069 | cdavid | 2008-11-17 21:36:17 +0900 (Mon, 17 Nov 2008) | 1 line
Use a wrapper around _ftime to work around a mingw bug in msvc runtimes import libraries.
........
r6070 | cdavid | 2008-11-17 21:41:13 +0900 (Mon, 17 Nov 2008) | 1 line
Set __MSVCRT_VERSION__ to make _ftime64 visible from time.h header when we need to workaround mingw bug.
........
................
r6077 | cdavid | 2008-11-17 22:58:23 +0900 (Mon, 17 Nov 2008) | 25 lines
Merged revisions 6071-6076 via svnmerge from
http://svn.scipy.org/svn/numpy/trunk
........
r6072 | cdavid | 2008-11-17 22:52:47 +0900 (Mon, 17 Nov 2008) | 1 line
Fix the inaccurate comment regarding _ftime issues with mingw.
........
r6073 | cdavid | 2008-11-17 22:53:05 +0900 (Mon, 17 Nov 2008) | 1 line
Do not generate a config.h for randomkit: it does not work as it is, and adding per-subpackage include path is a PITA with distutils.
........
r6074 | cdavid | 2008-11-17 22:53:25 +0900 (Mon, 17 Nov 2008) | 1 line
Conditionally setup mingw workaround on __GNUC__ since we can't detect if we are built with mingw in distutils setup.py.
........
r6075 | cdavid | 2008-11-17 22:53:42 +0900 (Mon, 17 Nov 2008) | 1 line
Forgot to update needs_mingw_ftime_workaround function.
........
r6076 | cdavid | 2008-11-17 22:53:58 +0900 (Mon, 17 Nov 2008) | 1 line
Include time.h and sys/timeb.h just after defining our custom __MSVCRT_VERSION__ to avoid possible duplicate.
........
................
Property changes on: trunk
___________________________________________________________________
Name: svnmerge-integrated
- /branches/distutils-revamp:1-2752 /branches/multicore:1-3687 /branches/visualstudio_manifest:1-6040 /trunk:1-2871
+ /branches/distutils-revamp:1-2752 /branches/multicore:1-3687 /branches/visualstudio_manifest:1-6077 /trunk:1-2871
Modified: trunk/numpy/distutils/command/config.py
===================================================================
--- trunk/numpy/distutils/command/config.py 2008-11-17 13:58:23 UTC (rev 6077)
+++ trunk/numpy/distutils/command/config.py 2008-11-17 14:09:39 UTC (rev 6078)
@@ -11,6 +11,7 @@
from distutils import log
from distutils.file_util import copy_file
from numpy.distutils.exec_command import exec_command
+from numpy.distutils.mingw32ccompiler import generate_manifest
LANG_EXT['f77'] = '.f'
LANG_EXT['f90'] = '.f90'
@@ -110,6 +111,8 @@
if fileexists: continue
log.warn('could not find library %r in directories %s' \
% (libname, library_dirs))
+ elif self.compiler.compiler_type == 'mingw32':
+ generate_manifest(self)
return self._wrap_method(old_config._link,lang,
(body, headers, include_dirs,
libraries, library_dirs, lang))
Modified: trunk/numpy/distutils/mingw32ccompiler.py
===================================================================
--- trunk/numpy/distutils/mingw32ccompiler.py 2008-11-17 13:58:23 UTC (rev 6077)
+++ trunk/numpy/distutils/mingw32ccompiler.py 2008-11-17 14:09:39 UTC (rev 6078)
@@ -27,6 +27,7 @@
from distutils.errors import DistutilsExecError, CompileError, UnknownFileError
from distutils.unixccompiler import UnixCCompiler
+from distutils.msvccompiler import get_build_version as get_build_msvc_version
from numpy.distutils.misc_util import msvc_runtime_library
# the same as cygwin plus some additional parameters
@@ -225,3 +226,119 @@
# msg = "Couldn't find import library, and failed to build it."
# raise DistutilsPlatformError, msg
return
+
+# Functions to deal with visual studio manifests. Manifest are a mechanism to
+# enforce strong DLL versioning on windows, and has nothing to do with
+# distutils MANIFEST. manifests are XML files with version info, and used by
+# the OS loader; they are necessary when linking against a DLL no in the system
+# path; in particular, python 2.6 is built against the MS runtime 9 (the one
+# from VS 2008), which is not available on most windows systems; python 2.6
+# installer does install it in the Win SxS (Side by side) directory, but this
+# requires the manifest too. This is a big mess, thanks MS for a wonderful
+# system.
+
+# XXX: ideally, we should use exactly the same version as used by python, but I
+# have no idea how to obtain the exact version from python. We could use the
+# strings utility on python.exe, maybe ?
+_MSVCRVER_TO_FULLVER = {'90': "9.0.21022.8"}
+
+def msvc_manifest_xml(maj, min):
+ """Given a major and minor version of the MSVCR, returns the
+ corresponding XML file."""
+ try:
+ fullver = _MSVCRVER_TO_FULLVER[str(maj * 10 + min)]
+ except KeyError:
+ raise ValueError("Version %d,%d of MSVCRT not supported yet" \
+ % (maj, min))
+ # Don't be fooled, it looks like an XML, but it is not. In particular, it
+ # should not have any space before starting, and its size should be
+ # divisible by 4, most likely for alignement constraints when the xml is
+ # embedded in the binary...
+ # This template was copied directly from the python 2.6 binary (using
+ # strings.exe from mingw on python.exe).
+ template = """\
+<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.VC%(maj)d%(min)d.CRT" version="%(fullver)s" processorArchitecture="*" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
+ </dependentAssembly>
+ </dependency>
+</assembly>"""
+
+ return template % {'fullver': fullver, 'maj': maj, 'min': min}
+
+def manifest_rc(name, type='dll'):
+ """Return the rc file used to generate the res file which will be embedded
+ as manifest for given manifest file name, of given type ('dll' or
+ 'exe').
+
+ Parameters
+ ---------- name: str
+ name of the manifest file to embed
+ type: str ('dll', 'exe')
+ type of the binary which will embed the manifest"""
+ if type == 'dll':
+ rctype = 2
+ elif type == 'exe':
+ rctype = 1
+ else:
+ raise ValueError("Type %s not supported" % type)
+
+ return """\
+#include "winuser.h"
+%d RT_MANIFEST %s""" % (rctype, name)
+
+def check_embedded_msvcr_match_linked(msver):
+ """msver is the ms runtime version used for the MANIFEST."""
+ # check msvcr major version are the same for linking and
+ # embedding
+ msvcv = msvc_runtime_library()
+ if msvcv:
+ maj = int(msvcv[5:6])
+ if not maj == int(msver):
+ raise ValueError, \
+ "Discrepancy between linked msvcr " \
+ "(%d) and the one about to be embedded " \
+ "(%d)" % (int(msver), maj)
+
+def configtest_name(config):
+ base = os.path.basename(config._gen_temp_sourcefile("yo", [], "c"))
+ return os.path.splitext(base)[0]
+
+def manifest_name(config):
+ # Get configest name (including suffix)
+ root = configtest_name(config)
+ exext = config.compiler.exe_extension
+ return root + exext + ".manifest"
+
+def rc_name(config):
+ # Get configest name (including suffix)
+ root = configtest_name(config)
+ return root + ".rc"
+
+def generate_manifest(config):
+ msver = get_build_msvc_version()
+ if msver is not None:
+ if msver >= 8:
+ check_embedded_msvcr_match_linked(msver)
+ ma = int(msver)
+ mi = int((msver - ma) * 10)
+ # Write the manifest file
+ manxml = msvc_manifest_xml(ma, mi)
+ man = open(manifest_name(config), "w")
+ config.temp_files.append(manifest_name(config))
+ man.write(manxml)
+ man.close()
+ # # Write the rc file
+ # manrc = manifest_rc(manifest_name(self), "exe")
+ # rc = open(rc_name(self), "w")
+ # self.temp_files.append(manrc)
+ # rc.write(manrc)
+ # rc.close()
More information about the Numpy-svn
mailing list