diff options
author | David Cournapeau <cournape@gmail.com> | 2008-01-06 10:35:44 +0000 |
---|---|---|
committer | David Cournapeau <cournape@gmail.com> | 2008-01-06 10:35:44 +0000 |
commit | 470e98b187506cf8073ba948510c420a47afc069 (patch) | |
tree | 91ce0d18dc36d003916c753170f9aca57e6cb1d8 | |
parent | e5c30c117783154c90d91a50a1872daa3b207aaa (diff) | |
download | numpy-470e98b187506cf8073ba948510c420a47afc069.tar.gz |
Add facilities to generate config file for future sconsified modules.
-rw-r--r-- | numpy/distutils/misc_util.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/numpy/distutils/misc_util.py b/numpy/distutils/misc_util.py index 0bc3a318a..9f99d55b5 100644 --- a/numpy/distutils/misc_util.py +++ b/numpy/distutils/misc_util.py @@ -1472,6 +1472,51 @@ def get_numpy_include_dirs(): # else running numpy/core/setup.py return include_dirs +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__ = ["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() + # d is a dictionary whose keys are package names, and values the + # corresponding configuration. Each configuration is itself a dictionary + # (lib : libinfo) + f.write('_config = %s\n' % d) + f.write(r''' +def show(): + for pkg, config in _config.items(): + print "package %s configuration:" % pkg + for lib, libc in config.items(): + print ' %s' % lib + for line in libc.split('\n'): + print '\t%s' % line + ''') + f.close() + return target + ######################### def default_config_dict(name = None, parent_name = None, local_path=None): |