Exemple #1
0
def runTest(preset_list, module, test_tree):
    
    # Run several different versions; with and without cache 

    def test(opttree):
        reset()
        initialize(opttree)
        runner = manager()
        
        results = runner.getResults(modules = [module], presets = preset_list)
        t = results[module]
        
        if type(test_tree) is TreeDict:
            for k, v in test_tree.iteritems():
                assert t[k] == v, ("%s: t[%s] != %s" % (module, k, repr(v)))
        else:
            assert test_tree == t
            
    
    opttree = TreeDict()
    opttree.project_directory = project_directory
    opttree.debug_mode = True
    opttree.verbose_mode = True
    
    test(opttree)
    
    opttree.cache_directory = join(project_directory, ".cache")
    
    test(opttree)
    test(opttree)
    
    shutil.rmtree(opttree.cache_directory, ignore_errors = True)
Exemple #2
0
def run(modules, presets = [], project_directory = '.', options = None):
    """
    Convenience function for running things directly. `options`, if given,
    should be a TreeDict of configuration options.
    """
    if options is None:
        options = TreeDict()
    else:
        if type(options) is not TreeDict:
            raise TypeError("options parameter needs to be a TreeDict.")
        
    options.project_directory = project_directory
     
    m = RunManager(options)
    
    return m.getResults(modules, presets)
################################################################################
# Default global options

is_boolean = set([True, False])

__default_opttree = TreeDict()
    
__default_opttree.logging.format = (str, '%(asctime)s %(name)-12s %(levelname)-8s %(message)s', 
                                    'Format string used for the logging.')
__default_opttree.logging.datefmt = (str, '%H:%M:%S', 
                                    'Format string used for the date in the logging.')
    
__default_opttree.debug_mode = (is_boolean, False, "Enable debug mode in compilation.")
__default_opttree.use_hdf5 = (is_boolean, False, "Use hdf5 for caching instead of simple pickling.")
__default_opttree.cache_compression = (is_boolean, True, "Use bz2 compression on the cache files.")
__default_opttree.project_directory = (str, '.', "The root of the project directory.")
__default_opttree.verbose = (is_boolean, False, "Print more detailed diagnostic and progress messages.")
__default_opttree.no_cache = (is_boolean, False, "Disable the caching system.")
__default_opttree.force = (is_boolean, False, "Overwrite existing files when creating new modules.")
__default_opttree.cache_read_only = (is_boolean, False, "Only load things from cache; never save.")
__default_opttree.no_compile = (is_boolean, False, "Disable compiling things, even if source files are modified.")
__default_opttree.config_file = (str, 'conf', "The configuration file to load options from.")
__default_opttree.cache_directory = ([str, type(None)], None, "The cache directory to use; None disables caching.")
__default_opttree.import_list = (list, [], "List of modules / directories to import in loading project.")
__default_opttree.auto_import = (is_boolean, True, "Automatically import all subdirs with __init__.py files.")
__default_opttree.cython.use_cpp = (is_boolean, False, "Compile cython extensions in C++ mode.")

__default_opttree.cython.compiler_args = (list, [], "Additional arguments to use when compiling cython extensions.")
__default_opttree.cython.link_args = (list, [], "Additional arguments to use when linking cython extensions.")
__default_opttree.cython.extra_include_dirs = (list, [], "Additional include directories to pass to the compiler.")
__default_opttree.cython.extra_library_dirs = (list, [], "Additional library directories to pass to the linker.")