[Numpy-svn] r4367 - in branches/numpy.scons/numpy: . distutils distutils/scons

numpy-svn@scip... numpy-svn@scip...
Wed Oct 31 18:21:46 CDT 2007


Author: cdavid
Date: 2007-10-31 18:21:39 -0500 (Wed, 31 Oct 2007)
New Revision: 4367

Modified:
   branches/numpy.scons/numpy/distutils/misc_util.py
   branches/numpy.scons/numpy/distutils/scons/configuration.py
   branches/numpy.scons/numpy/setupscons.py
Log:
configres correctly generated and read (show_config still does not work)

Modified: branches/numpy.scons/numpy/distutils/misc_util.py
===================================================================
--- branches/numpy.scons/numpy/distutils/misc_util.py	2007-10-31 14:57:41 UTC (rev 4366)
+++ branches/numpy.scons/numpy/distutils/misc_util.py	2007-10-31 23:21:39 UTC (rev 4367)
@@ -1446,6 +1446,12 @@
         """
         self.py_modules.append((self.name,name,generate_config_py))
 
+    def scons_make_config_py(self, name = '__config__'):
+        """Generate package __config__.py file containing system_info
+        information used during building the package.
+        """
+        self.py_modules.append((self.name, name, scons_generate_config_py))
+
     def get_info(self,*names):
         """Get resources information.
         """
@@ -1497,6 +1503,59 @@
     The path is relative to the top setup.py"""
     return '__configres.py'
 
+def scons_generate_config_py(target):
+    """generate config.py file containing system_info information
+    used during building the package.
+
+    usage:
+        config['py_modules'].append((packagename, '__config__',generate_config_py))
+    """
+    from distutils.dir_util import mkpath
+    import imp
+    d = {}
+    mkpath(os.path.dirname(target))
+    f = open(target, 'w')
+    f.write('# this file is generated by %s\n' % (os.path.abspath(sys.argv[0])))
+    f.write('# it contains system_info results at the time of building this package.\n')
+    f.write('__all__ = ["get_info","show"]\n\n')
+    confdir = get_scons_configres_dir()
+    confilename = get_scons_configres_filename()
+    for root, dirs, files in os.walk(confdir):
+        if files:
+            file = os.path.join(root, confilename)
+            assert root.startswith(confdir)
+            pkg_name = '.'.join(root[len(confdir)+1:].split(os.sep))
+            fid = open(file, 'r')
+            try:
+                config_mod = imp.load_module(pkg_name, fid, confilename,
+                                             ('.py', 'U', 1))
+                d[pkg_name] = config_mod.config
+            finally:
+                fid.close()
+    for k, i in d.items():
+        f.write('%s=%r\n' % (k, i))
+    f.write(r'''
+def get_info(name):
+    g = globals()
+    return g.get(name, g.get(name + "_info", {}))
+
+def show():
+    for name,info_dict in globals().items():
+        if name[0] == "_" or type(info_dict) is not type({}): continue
+        print name + ":"
+        if not info_dict:
+            print "  not available"
+        for k,v in info_dict.items():
+            v = str(v)
+            if k == "sources" and len(v) > 200:
+                v = v[:60] + " ...\n... " + v[-60:]
+            print "    %s = %s" % (k,v)
+        print
+    ''')
+
+    f.close()
+    return target
+
 #########################
 
 def default_config_dict(name = None, parent_name = None, local_path=None):
@@ -1546,18 +1605,18 @@
     return os.path.normpath(njoin(drive + prefix, subpath))
 
 def generate_config_py(target):
-    """Generate config.py file containing system_info information
+    """generate config.py file containing system_info information
     used during building the package.
 
-    Usage:
+    usage:
         config['py_modules'].append((packagename, '__config__',generate_config_py))
     """
     from numpy.distutils.system_info import system_info
     from distutils.dir_util import mkpath
     mkpath(os.path.dirname(target))
     f = open(target, 'w')
-    f.write('# This file is generated by %s\n' % (os.path.abspath(sys.argv[0])))
-    f.write('# It contains system_info results at the time of building this package.\n')
+    f.write('# this file is generated by %s\n' % (os.path.abspath(sys.argv[0])))
+    f.write('# it contains system_info results at the time of building this package.\n')
     f.write('__all__ = ["get_info","show"]\n\n')
     for k, i in system_info.saved_results.items():
         f.write('%s=%r\n' % (k, i))
@@ -1571,7 +1630,7 @@
         if name[0] == "_" or type(info_dict) is not type({}): continue
         print name + ":"
         if not info_dict:
-            print "  NOT AVAILABLE"
+            print "  not available"
         for k,v in info_dict.items():
             v = str(v)
             if k == "sources" and len(v) > 200:

Modified: branches/numpy.scons/numpy/distutils/scons/configuration.py
===================================================================
--- branches/numpy.scons/numpy/distutils/scons/configuration.py	2007-10-31 14:57:41 UTC (rev 4366)
+++ branches/numpy.scons/numpy/distutils/scons/configuration.py	2007-10-31 23:21:39 UTC (rev 4367)
@@ -4,16 +4,14 @@
 
 def add_info(env, name, opt):
     cfg = env['NUMPY_PKG_CONFIG']
-    cfg[name] = opt
+    cfg[name] = str(opt)
 
 def write_info(env):
     print "File is %s" % env['NUMPY_PKG_CONFIG_FILE']
     print "Info is %s" % env['NUMPY_PKG_CONFIG']
     dir = os.path.dirname(env['NUMPY_PKG_CONFIG_FILE'])
     if not os.path.exists(dir):
-        os.makedirs()
+        os.makedirs(dir)
     f = open(env['NUMPY_PKG_CONFIG_FILE'], 'w')
     f.writelines("config = %s" % str(env['NUMPY_PKG_CONFIG']))
     f.close()
-
-

Modified: branches/numpy.scons/numpy/setupscons.py
===================================================================
--- branches/numpy.scons/numpy/setupscons.py	2007-10-31 14:57:41 UTC (rev 4366)
+++ branches/numpy.scons/numpy/setupscons.py	2007-10-31 23:21:39 UTC (rev 4367)
@@ -21,7 +21,7 @@
     # scons instead).
     # !! DO NOT REMOVE THIS !!
     config.add_extension('', sources = [])
-    config.make_config_py() # installs __config__.py
+    config.scons_make_config_py() # installs __config__.py
     return config
 
 if __name__ == '__main__':



More information about the Numpy-svn mailing list