[Numpy-svn] r4539 - in branches/numpy.scons/numpy/distutils/scons: . core doc

numpy-svn at scipy.org numpy-svn at scipy.org
Tue Dec 4 02:50:34 EST 2007


Author: cdavid
Date: 2007-12-04 01:50:25 -0600 (Tue, 04 Dec 2007)
New Revision: 4539

Modified:
   branches/numpy.scons/numpy/distutils/scons/Changelog
   branches/numpy.scons/numpy/distutils/scons/core/default.py
   branches/numpy.scons/numpy/distutils/scons/core/numpyenv.py
   branches/numpy.scons/numpy/distutils/scons/doc/TODO
Log:
Handle fortran compiler configurations, + some minor changes

Modified: branches/numpy.scons/numpy/distutils/scons/Changelog
===================================================================
--- branches/numpy.scons/numpy/distutils/scons/Changelog	2007-12-04 06:58:41 UTC (rev 4538)
+++ branches/numpy.scons/numpy/distutils/scons/Changelog	2007-12-04 07:50:25 UTC (rev 4539)
@@ -1,3 +1,16 @@
+Tue, 04 Dec 2007 16:32:20 +0900 (1st beta)
+
+User-visible changes:
+	* sunperf now works for numpy and scipy
+	* cflags and fflags are overridable from the command line
+
+Implemenation changes:
+	* BLAS, LAPACK, CBLAS and CLAPACK checkers implemented for scipy
+	* FFT checker implemented
+	* F2py tool added
+	* sub packages now build correctly
+	* Static library builder, handling correctly pic related flags
+
 Mon, 12 Nov 2007 19:57:24 +0900
 
 	* g77 and MS visual studio can now be used together. CheckF77Mangler,

Modified: branches/numpy.scons/numpy/distutils/scons/core/default.py
===================================================================
--- branches/numpy.scons/numpy/distutils/scons/core/default.py	2007-12-04 06:58:41 UTC (rev 4538)
+++ branches/numpy.scons/numpy/distutils/scons/core/default.py	2007-12-04 07:50:25 UTC (rev 4539)
@@ -1,5 +1,5 @@
 #! /usr/bin/env python
-# Last Change: Mon Nov 26 05:00 PM 2007 J
+# Last Change: Tue Dec 04 04:00 PM 2007 J
 import sys
 import distutils.sysconfig
 
@@ -123,6 +123,34 @@
                 d[k] = []
         return d
 
+class FCompilerConfig:
+    def __init__(self, optim = None, warn = None, debug = None, debug_symbol =
+                 None, thread = None, extra = None):
+        # XXX: several level of optimizations ?
+        self.optim = optim
+        # XXX: several level of warnings ?
+        self.warn = warn
+        # To enable putting debugging info in binaries
+        self.debug_symbol = debug_symbol
+        # To enable friendly debugging
+        self.debug = debug
+        # XXX
+        self.thread = thread
+        # XXX
+        self.extra = extra
+
+    def get_flags_dict(self):
+        d = {'NUMPY_OPTIM_FFLAGS' : self.optim,
+             'NUMPY_WARN_FFLAGS' : self.warn,
+             'NUMPY_THREAD_FFLAGS' : self.thread,
+             'NUMPY_DEBUG_FFLAGS' : self.debug,
+             'NUMPY_EXTRA_FFLAGS' : self.extra,
+             'NUMPY_DEBUG_SYMBOL_FFLAGS' : self.debug_symbol}
+        for k, v in d.items():
+            if v is None:
+                d[k] = []
+        return d
+
 # It seems that scons consider any option with space in it as a multi option,
 # which breaks command line options. So just don't put space.
 def get_cc_config(name):
@@ -196,7 +224,19 @@
 
 import numpy.distutils.fcompiler as _FC
 
+# XXX: handle F77, F90 and co ?
 def get_f77_config(name):
     # name is the scons name for the tool
-    if name == 'g77':
-        cfg = CompilerConfig(optim = ['-O2']) 
+    if name == 'g77' or name == 'gfortran':
+        if distutils.sysconfig.get_config_vars('LDFLAGS')[0].find('-pthread'):
+            thread = ['-pthread']
+        else:
+            thread = []
+        cfg = FCompilerConfig(optim = ['-O2', '-fno-strict-aliasing', '-DNDEBUG'],
+                              warn = ['-Wall'],
+                              debug_symbol = ['-g'], 
+                              thread = thread)
+    else:
+        cfg = FCompilerConfig()
+
+    return cfg

Modified: branches/numpy.scons/numpy/distutils/scons/core/numpyenv.py
===================================================================
--- branches/numpy.scons/numpy/distutils/scons/core/numpyenv.py	2007-12-04 06:58:41 UTC (rev 4538)
+++ branches/numpy.scons/numpy/distutils/scons/core/numpyenv.py	2007-12-04 07:50:25 UTC (rev 4539)
@@ -9,7 +9,7 @@
 from numpy.distutils.misc_util import get_scons_build_dir, get_scons_configres_dir,\
     get_scons_configres_filename
 
-from default import tool_list, get_cc_config
+from default import tool_list, get_cc_config, get_f77_config
 from custom_builders import NumpySharedLibrary, NumpyCtypes, \
             NumpyPythonExtension, NumpyStaticExtLibrary
 from libinfo import get_config
@@ -105,10 +105,15 @@
     return opts
 
 def customize_cc(name, env):
-    """Customize env options related to the given tool."""
+    """Customize env options related to the given tool (C compiler)."""
     cfg = get_cc_config(name)
     env.AppendUnique(**cfg.get_flags_dict())
 
+def customize_f77(name, env):
+    """Customize env options related to the given tool (F77 compiler)."""
+    cfg = get_f77_config(name)
+    env.AppendUnique(**cfg.get_flags_dict())
+
 def finalize_env(env):
     if built_with_mstools(env):
         major, minor = get_vs_version(env)
@@ -126,12 +131,30 @@
 
 def GetNumpyEnvironment(args):
     env = _GetNumpyEnvironment(args)
-    env.AppendUnique(CFLAGS  = env['NUMPY_WARN_CFLAGS'] +\
-                               env['NUMPY_OPTIM_CFLAGS'] +\
-                               env['NUMPY_DEBUG_SYMBOL_CFLAGS'] +\
-                               env['NUMPY_EXTRA_CFLAGS'] +\
-                               env['NUMPY_THREAD_CFLAGS'])
+
+    # Apply optim and warn flags considering context
+    if 'CFLAGS' in os.environ:
+        env.Append(CFLAGS = "%s" % os.environ['CFLAGS'])
+        env.AppendUnique(CFLAGS = env['NUMPY_EXTRA_CFLAGS'] +
+                                  env['NUMPY_THREAD_CFLAGS'])
+    else:
+        env.AppendUnique(CFLAGS  = env['NUMPY_WARN_CFLAGS'] +\
+                                   env['NUMPY_OPTIM_CFLAGS'] +\
+                                   env['NUMPY_DEBUG_SYMBOL_CFLAGS'] +\
+                                   env['NUMPY_EXTRA_CFLAGS'] +\
+                                   env['NUMPY_THREAD_CFLAGS'])
     env.AppendUnique(LINKFLAGS = env['NUMPY_OPTIM_LDFLAGS'])
+
+    if 'FFLAGS' in os.environ:
+        env.Append(SHFORTRANFLAGS = "%s" % os.environ['FFLAGS'])
+        env.AppendUnique(SHFORTRANFLAGS = env['NUMPY_EXTRA_FFLAGS'] +
+                                        env['NUMPY_THREAD_FFLAGS'])
+    else:
+        env.AppendUnique(SHFORTRANFLAGS  = env['NUMPY_WARN_FFLAGS'] +
+                                         env['NUMPY_OPTIM_FFLAGS'] +
+                                         env['NUMPY_DEBUG_SYMBOL_FFLAGS'] +
+                                         env['NUMPY_EXTRA_FFLAGS'] +
+                                         env['NUMPY_THREAD_FFLAGS'])
     return env
 
 def initialize_cc(env, path_list):
@@ -180,6 +203,7 @@
 
                 t(env) 
                 path_list.append(env['f77_opt_path'])
+                customize_f77(t.name, env)
         except EnvironmentError, e:
             # scons could not understand cc_opt (bad name ?)
             raise AssertionError("SCONS: Could not initialize tool ? Error is %s" % \
@@ -189,6 +213,7 @@
         if def_fcompiler:
             t = Tool(def_fcompiler)
             t(env)
+            customize_f77(t.name, env)
         else:
             print "========== NO FORTRAN COMPILER FOUND ==========="
 

Modified: branches/numpy.scons/numpy/distutils/scons/doc/TODO
===================================================================
--- branches/numpy.scons/numpy/distutils/scons/doc/TODO	2007-12-04 06:58:41 UTC (rev 4538)
+++ branches/numpy.scons/numpy/distutils/scons/doc/TODO	2007-12-04 07:50:25 UTC (rev 4539)
@@ -1,12 +1,11 @@
 Remaining things:
-    - CLAPACK: check old atlas
-    - FFT checker
+    - Add NETLIB blas and lapack
     - check windows
-    - Add CPPPDEFINES in perflib checkers 
-    - Fortran optimizations flags
-    - Control cflags and f77flags from env
     - umfpack checker
     - finish scipy
+    - Add CPPPDEFINES in perflib checkers 
+    - CXX optimizations flags + Control cxxflags from env
+    - CLAPACK: check old atlas
     - handle inplace
     - doc
 




More information about the Numpy-svn mailing list