[Numpy-svn] r5527 - vendor/tools

numpy-svn@scip... numpy-svn@scip...
Sat Jul 26 00:00:44 CDT 2008


Author: cdavid
Date: 2008-07-26 00:00:39 -0500 (Sat, 26 Jul 2008)
New Revision: 5527

Added:
   vendor/tools/sse2.cfg
Modified:
   vendor/tools/build.py
Log:
Use a config file to switch more easily between configurations.

Modified: vendor/tools/build.py
===================================================================
--- vendor/tools/build.py	2008-07-25 18:35:17 UTC (rev 5526)
+++ vendor/tools/build.py	2008-07-26 05:00:39 UTC (rev 5527)
@@ -3,21 +3,22 @@
 from subprocess import Popen
 import shutil
 import os.path
-from os.path import join as pjoin
+from os.path import join as pjoin, dirname
 import glob
 import tarfile
+from ConfigParser import ConfigParser
+import sys
 
+if os.name == 'nt' and not sys.platform == 'cygwin':
+    raise ValueError("You should use cygwin python on windows for now !")
+
 # Configuration (this should be put in a config file at some point)
 LAPACK_SRC = pjoin('src', 'lapack-lite-3.1.1')
 LAPACK_LIB = pjoin(LAPACK_SRC, 'lapack_MINGW32.a')
 ATLAS_SRC = pjoin('src', 'atlas-3.8.2')
 ATLAS_BUILDDIR = os.path.join(ATLAS_SRC, "MyObj")
-ARCH = "SSE2-P4"
-ATLAS_TARBALL = 'atlas-3.8.2-%s.tbz2' % ARCH
-FC = 'g77'
 # Use INT_ETIME for lapack if building with gfortran
 #TIMER = 'INT_ETIME'
-LAPACK_F77_FLAGS = ''
 
 def build_atlas_tarball():
     print "====== Building ATLAS tarbal ======"
@@ -61,9 +62,64 @@
     clean_atlas()
     clean_lapack()
 
+TARGETS = {'atlas' : [configure_atlas, build_atlas, build_atlas_tarball],
+        'lapack' : build_lapack}
+
+class Config(object):
+    def __init__(self):
+        self.arch = None
+        self.cpuclass = 'i386'
+        self.freq = 0
+        self.pw = 32
+        self.targets = ['blas', 'lapack']
+        self.lapack_flags = ""
+        self.f77 = 'g77'
+
+    def __repr__(self):
+        r = ["Cpu Configurations: "]
+        r += ['\tArch: %s' % self.arch]
+        r += ['\tCpu Class: %s' % self.cpuclass]
+        r += ['\tFreq: %d MHz' % self.freq]
+        r += ['\tPointer width: %d bits' % self.pw]
+        r += ["Targets to build: %s" % str(self.targets)]
+        return "\n".join(r)
+
+def read_config(file):
+    cfgp = ConfigParser()
+    f = cfgp.read(file)
+    if len(f) < 1:
+        raise IOError("file %s not found" % file)
+
+    cfg = Config() 
+    if cfgp.has_section('CPU'):
+        if cfgp.has_option('CPU', 'ARCH'):
+            cfg.arch = cfgp.get('CPU', 'ARCH')
+        if cfgp.has_option('CPU', 'CLASS'):
+            cfg.cpuclass = cfgp.get('CPU', 'CLASS')
+        if cfgp.has_option('CPU', 'MHZ'):
+            cfg.freq = cfgp.getint('CPU', 'MHZ')
+    if cfgp.has_section('BUILD_OPTIONS'):
+        if cfgp.has_option('BUILD_OPTIONS', 'TARGETS'):
+            cfg.targets = cfgp.get('BUILD_OPTIONS', 'TARGETS').split(',')
+        if cfgp.has_option('BUILD_OPTIONS', 'F77'):
+            cfg.f77 = cfgp.get('BUILD_OPTIONS', 'F77')
+        if cfgp.has_option('BUILD_OPTIONS', 'LAPACK_F77FLAGS'):
+            cfg.lapack_flags = " ".join(cfgp.get('BUILD_OPTIONS', 'LAPACK_F77FLAGS').split(','))
+
+    return cfg
+
 if __name__ == '__main__':
+    try:
+        cfg = read_config(pjoin(dirname(__file__), 'site.cfg'))
+    except IOError:
+        print "Using default config (site.cfg not found)"
+        cfg = Config()
+
+    ARCH = cfg.arch
+    FC = cfg.f77
+    LAPACK_F77_FLAGS = cfg.lapack_flags
+    ATLAS_TARBALL = 'atlas-3.8.2-%s.tbz2' % ARCH
+
     clean()
-    build_lapack()
-    configure_atlas()
-    build_atlas()
-    build_atlas_tarball()
+    #for i in cfg.targets:
+    #    TARGETS[i]()

Added: vendor/tools/sse2.cfg
===================================================================
--- vendor/tools/sse2.cfg	2008-07-25 18:35:17 UTC (rev 5526)
+++ vendor/tools/sse2.cfg	2008-07-26 05:00:39 UTC (rev 5527)
@@ -0,0 +1,10 @@
+[CPU]
+ARCH    = SSE2
+CLASS   = P4
+MHZ     = 3200
+# Pointer Width in bits (Not well detected by ATLAS on Windows at least)
+PW      = 32
+[BUILD_OPTIONS]
+TARGETS = lapack
+#LAPACK_F77FLAGS = -O3,-funroll-loops
+F77 = g77



More information about the Numpy-svn mailing list