def test_get_compilation_tool(): r"""Test get_compilation_tool for different name variations.""" from yggdrasil.drivers.CModelDriver import CModelDriver if CModelDriver.is_language_installed(): tooltype = 'compiler' out = CModelDriver.get_tool('compiler').__class__ toolname = out.toolname.lower() toolpath = os.path.join('somedir', toolname) toolfile = toolpath + '.exe' vals = [toolpath, toolfile] if platform._is_win: vals += [toolname.upper(), toolfile.upper()] for v in vals: assert_equal(CompiledModelDriver.get_compilation_tool(tooltype, v), out) assert_raises(ValueError, CompiledModelDriver.get_compilation_tool, 'compiler', 'invalid') # else: # assert_raises(NotImplementedError, CModelDriver.get_tool, 'compiler') # assert_equal(CModelDriver.get_tool( # 'compiler', default='invalid'), 'invalid') assert_equal( CompiledModelDriver.get_compilation_tool('compiler', 'invalid', default='invalid'), 'invalid')
def set_env(self, **kwargs): r"""Get environment variables that should be set for the model process. Returns: dict: Environment variables for the model process. """ out = super(RModelDriver, self).set_env(**kwargs) out['RETICULATE_PYTHON'] = PythonModelDriver.get_interpreter() if CModelDriver.is_language_installed(): c_linker = CModelDriver.get_tool('linker') search_dirs = c_linker.get_search_path(env_only=True) out = CModelDriver.update_ld_library_path(out, paths_to_add=search_dirs, add_to_front=True) return out