[Numpy-svn] r4429 - branches/numpy.scons/numpy/distutils/scons/core

numpy-svn at scipy.org numpy-svn at scipy.org
Sat Nov 10 05:38:27 EST 2007


Author: cdavid
Date: 2007-11-10 04:38:20 -0600 (Sat, 10 Nov 2007)
New Revision: 4429

Modified:
   branches/numpy.scons/numpy/distutils/scons/core/extension_scons.py
   branches/numpy.scons/numpy/distutils/scons/core/numpyenv.py
Log:
DLL manifest now handled for VS 2005 in scons builders

Modified: branches/numpy.scons/numpy/distutils/scons/core/extension_scons.py
===================================================================
--- branches/numpy.scons/numpy/distutils/scons/core/extension_scons.py	2007-11-10 09:42:48 UTC (rev 4428)
+++ branches/numpy.scons/numpy/distutils/scons/core/extension_scons.py	2007-11-10 10:38:20 UTC (rev 4429)
@@ -12,8 +12,7 @@
 
 def built_with_mstools(env):
     """Return True if built with MS tools (compiler + linker)."""
-    # Handle case where MSVS is found, but mingw is used
-    return env.has_key('MSVS') and not built_with_mingw(env)
+    return env['cc_opt'] == 'msvc'
 
 def built_with_mingw(env):
     """Return true if built with mingw compiler."""

Modified: branches/numpy.scons/numpy/distutils/scons/core/numpyenv.py
===================================================================
--- branches/numpy.scons/numpy/distutils/scons/core/numpyenv.py	2007-11-10 09:42:48 UTC (rev 4428)
+++ branches/numpy.scons/numpy/distutils/scons/core/numpyenv.py	2007-11-10 10:38:20 UTC (rev 4429)
@@ -3,6 +3,7 @@
 from os.path import join as pjoin, dirname as pdirname
 import sys
 
+import re
 from distutils.sysconfig import get_config_vars
 
 from numpy.distutils.misc_util import get_scons_build_dir, get_scons_configres_dir,\
@@ -11,7 +12,7 @@
 from default import tool_list, get_cc_config
 from custom_builders import NumpySharedLibrary, NumpyCtypes, NumpyPythonExtension
 from libinfo import get_config
-from extension_scons import PythonExtension
+from extension_scons import PythonExtension, built_with_mstools
 
 from numpy.distutils.scons.tools.substinfile import TOOL_SUBST
 
@@ -35,7 +36,6 @@
     # while returning success (0).
     
     import os
-    import re
     suncc = re.compile('Sun C')
     # Redirect stderr to stdout
     cmd = fullpath + ' -V 2>&1'
@@ -45,6 +45,19 @@
 
     return suncc.search(cnt)
 
+def get_vs_version(env):
+    try:
+         version = env['MSVS']['VERSION']
+	 m = re.compile("([0-9]).([0-9])").match(version)
+	 if m:
+	     major = int(m.group(1))
+	     minor = int(m.group(2))
+	     return (major, minor)
+	 else:
+ 	     raise RuntimeError("FIXME: failed to parse VS version")
+    except KeyError:
+	 raise RuntimeError("Could not get VS version !")
+
 def GetNumpyOptions(args):
     """Call this with args=ARGUMENTS to take into account command line args."""
     from SCons.Options import Options
@@ -77,6 +90,21 @@
     cfg = get_cc_config(name)
     env.AppendUnique(**cfg.get_flags_dict())
 
+def finalize_env(env):
+    if built_with_mstools(env):
+        major, minor = get_vs_version(env)
+	# For VS 8 and above (VS 2005), use manifest for DLL
+	if major >= 8:
+	    env['LINKCOM'] = [env['LINKCOM'], 
+			      'mt.exe -nologo -manifest ${TARGET}.manifest '\
+			      '-outputresource:$TARGET;1']
+	    env['SHLINKCOM'] = [env['SHLINKCOM'], 
+			        'mt.exe -nologo -manifest ${TARGET}.manifest '\
+			        '-outputresource:$TARGET;2']
+	    env['LDMODULECOM'] = [env['LDMODULECOM'], 
+			        'mt.exe -nologo -manifest ${TARGET}.manifest '\
+			        '-outputresource:$TARGET;2']
+
 def GetNumpyEnvironment(args):
     env = _GetNumpyEnvironment(args)
     env.AppendUnique(CFLAGS  = env['NUMPY_WARN_CFLAGS'] + env['NUMPY_OPTIM_CFLAGS'] +\
@@ -117,6 +145,8 @@
 
     # ===============================================
     # Setting tools according to command line options
+    if not env['ENV'].has_key('PATH'):
+	env['ENV']['PATH'] = []
 
     # XXX: how to handle tools which are not in standard location ? Is adding
     # the full path of the compiler enough ? (I am sure some compilers also
@@ -144,6 +174,12 @@
                         env['ENV']['PATH'] += ';%s' % env['cc_opt_path']
                     else:
                         env['ENV']['PATH'] += ':%s' % env['cc_opt_path']
+	    else:
+		# Do not care about PATH info because none given from scons
+		# distutils command
+                t = Tool(env['cc_opt'])
+                t(env) 
+                customize_cc(t.name, env)
         except EnvironmentError, e:
             # scons could not understand cc_opt (bad name ?)
             raise AssertionError("SCONS: Could not initialize tool ? Error is %s" % \
@@ -219,6 +255,8 @@
     for t in FindAllTools(DEF_OTHER_TOOLS, env):
         Tool(t)(env)
 
+    finalize_env(env)
+
     try:
         env['ENV']['HOME'] = os.environ['HOME']
     except KeyError:




More information about the Numpy-svn mailing list