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

numpy-svn@scip... numpy-svn@scip...
Wed Nov 21 05:31:28 CST 2007


Author: cdavid
Date: 2007-11-21 05:31:17 -0600 (Wed, 21 Nov 2007)
New Revision: 4483

Modified:
   branches/numpy.scons/numpy/distutils/scons/core/custom_builders.py
   branches/numpy.scons/numpy/distutils/scons/core/default.py
   branches/numpy.scons/numpy/distutils/scons/core/extension_scons.py
   branches/numpy.scons/numpy/distutils/scons/core/numpyenv.py
Log:
Handle keyword args in PythonExtension builder

Modified: branches/numpy.scons/numpy/distutils/scons/core/custom_builders.py
===================================================================
--- branches/numpy.scons/numpy/distutils/scons/core/custom_builders.py	2007-11-21 10:29:54 UTC (rev 4482)
+++ branches/numpy.scons/numpy/distutils/scons/core/custom_builders.py	2007-11-21 11:31:17 UTC (rev 4483)
@@ -28,7 +28,18 @@
     inst_lib = env.Install("$distutils_installdir", lib)
     return lib, inst_lib
 	
+def NumpyStaticExtLibrary(env, target, source, *args, **kw):
+    """This builder is the same than StaticExtLibrary, except for the fact that it
+    takes into account build dir info passed by distutils, and put the target at
+    the right location in distutils build directory for correct installation."""
+    newsource = [pjoin(env['build_dir'], i) for i in source]
+    # XXX: why target is a list ? It is always true ?
+    lib = env.StaticExtLibrary("$build_dir/%s" % target[0], newsource, *args, **kw)
+
+    inst_lib = env.Install("$distutils_installdir", lib)
+    return lib, inst_lib
 	
+	
 def NumpyCtypes(env, target, source, *args, **kw):
     """This builder is essentially the same than SharedLibrary, but should be
     used for libraries which will only be used through ctypes.

Modified: branches/numpy.scons/numpy/distutils/scons/core/default.py
===================================================================
--- branches/numpy.scons/numpy/distutils/scons/core/default.py	2007-11-21 10:29:54 UTC (rev 4482)
+++ branches/numpy.scons/numpy/distutils/scons/core/default.py	2007-11-21 11:31:17 UTC (rev 4483)
@@ -1,5 +1,5 @@
 #! /usr/bin/env python
-# Last Change: Thu Nov 08 06:00 PM 2007 J
+# Last Change: Tue Nov 20 07:00 PM 2007 J
 import sys
 import distutils.sysconfig
 
@@ -193,3 +193,10 @@
                 distutils.sysconfig.get_config_vars('CFLAGS'))
 
     return cfg
+
+import numpy.distutils.fcompiler as _FC
+
+def get_f77_config(name):
+    # name is the scons name for the tool
+    if name == 'g77':
+        cfg = CompilerConfig(optim = ['-O2']) 

Modified: branches/numpy.scons/numpy/distutils/scons/core/extension_scons.py
===================================================================
--- branches/numpy.scons/numpy/distutils/scons/core/extension_scons.py	2007-11-21 10:29:54 UTC (rev 4482)
+++ branches/numpy.scons/numpy/distutils/scons/core/extension_scons.py	2007-11-21 11:31:17 UTC (rev 4483)
@@ -1,5 +1,5 @@
 #! /usr/bin/env python
-# Last Change: Thu Nov 15 07:00 PM 2007 J
+# Last Change: Wed Nov 21 08:00 PM 2007 J
 
 # Module for support to build python extension. scons specific code goes here.
 import sys
@@ -40,49 +40,44 @@
 
 
 def PythonExtension(env, target, source, *args, **kw):
-    # XXX Check args and kw
     # XXX: Some things should not be set here... Actually, this whole
     # thing is a mess.
-    if env.has_key('LINKFLAGS'):
-        LINKFLAGS = deepcopy(env['LINKFLAGS'])
-    else:
-        LINKFLAGS = []
 
-    if env.has_key('CPPPATH'):
-        CPPPATH = deepcopy(env['CPPPATH'])
-    else:
-        CPPPATH = []
+    def floupi(key):
+        if env.has_key(key):
+            narg = deepcopy(env[key])
+        else:
+            narg = []
 
-    if env.has_key('LIBPATH'):
-        LIBPATH = deepcopy(env['LIBPATH'])
-    else:
-        LIBPATH = []
+        if kw.has_key(key):
+            narg.append(kw.pop(key))
 
-    if env.has_key('LIBS'):
-        LIBS = deepcopy(env['LIBS'])
-    else:
-        LIBS = []
+        return narg
 
+    LINKFLAGS = floupi('LINKFLAGS')
+    CPPPATH = floupi('CPPPATH')
+    LIBPATH = floupi('LIBPATH')
+    LIBS = floupi('LIBS')
+
     CPPPATH.append(get_python_inc())
     if sys.platform == 'win32': 
         if built_with_mstools(env):
             # XXX: We add the path where to find python lib (or any other
             # version, of course). This seems to be necessary for MS compilers.
             #env.AppendUnique(LIBPATH = get_pythonlib_dir())
-	    LIBPATH.append(get_pythonlib_dir())
+            LIBPATH.append(get_pythonlib_dir())
     	elif built_with_mingw(env):
-	    # XXX: this part should be moved elsewhere (mingw abstraction
-	    # for python)
+            # XXX: this part should be moved elsewhere (mingw abstraction
+            # for python)
 
-	    # This is copied from mingw32ccompiler.py in numpy.distutils
-	    # (not supported by distutils.)
+            # This is copied from mingw32ccompiler.py in numpy.distutils
+            # (not supported by distutils.)
 
-	    # Include the appropiate MSVC runtime library if Python was
-	    # built with MSVC >= 7.0 (MinGW standard is msvcrt)
+            # Include the appropiate MSVC runtime library if Python was
+            # built with MSVC >= 7.0 (MinGW standard is msvcrt)
             py_runtime_library = msvc_runtime_library()
-	    LIBPATH.append(get_pythonlib_dir())
-	    LIBS.extend([get_pythonlib_name(), py_runtime_library])
-
+            LIBPATH.append(get_pythonlib_dir())
+            LIBS.extend([get_pythonlib_name(), py_runtime_library])
     elif sys.platform == "darwin":
         # XXX: When those should be used ? (which version of Mac OS X ?)
         LINKFLAGS += ' -undefined dynamic_lookup '
@@ -99,8 +94,7 @@
                                  LINKFLAGS = LINKFLAGS, 
                                  LIBS = LIBS, 
                                  LIBPATH = LIBPATH, 
-                                 CPPPATH = CPPPATH, 
-				 *args, **kw)
+                                 CPPPATH = CPPPATH, *args, **kw)
     else:
         wrap = env.LoadableModule(target, source, SHLIBPREFIX = '', 
                                   LDMODULESUFFIX = '$PYEXTSUFFIX', 

Modified: branches/numpy.scons/numpy/distutils/scons/core/numpyenv.py
===================================================================
--- branches/numpy.scons/numpy/distutils/scons/core/numpyenv.py	2007-11-21 10:29:54 UTC (rev 4482)
+++ branches/numpy.scons/numpy/distutils/scons/core/numpyenv.py	2007-11-21 11:31:17 UTC (rev 4483)
@@ -10,7 +10,8 @@
     get_scons_configres_filename
 
 from default import tool_list, get_cc_config
-from custom_builders import NumpySharedLibrary, NumpyCtypes, NumpyPythonExtension
+from custom_builders import NumpySharedLibrary, NumpyCtypes, \
+            NumpyPythonExtension, NumpyStaticExtLibrary
 from libinfo import get_config
 from extension_scons import PythonExtension, built_with_mstools
 from utils import pkg_to_path
@@ -337,7 +338,8 @@
     env['BUILDERS']['NumpyFromCTemplate'] = NumpyFromCTemplate
     env['BUILDERS']['NumpyFromFTemplate'] = NumpyFromFTemplate
 
-    createStaticExtLibBuilder(env)
+    createStaticExtLibraryBuilder(env)
+    env['BUILDERS']['NumpyStaticExtLibrary'] = NumpyStaticExtLibrary
 
     # Setting build directory according to command line option
     if len(env['src_dir']) > 0:
@@ -359,11 +361,12 @@
 
     return env
 
-def createStaticExtLibBuilder(env):
+def createStaticExtLibraryBuilder(env):
     """This is a utility function that creates the StaticExtLibrary Builder in
     an Environment if it is not there already.
 
     If it is already there, we return the existing one."""
+    import SCons.Action
 
     try:
         static_extlib = env['BUILDERS']['StaticExtLibrary']



More information about the Numpy-svn mailing list