예제 #1
0
def test_update_ld_library_path():
    r"""Test update_ld_library_path method."""
    lang_dir = CModelDriver.get_language_dir()
    total = os.pathsep.join(['test', lang_dir])
    env = {'LD_LIBRARY_PATH': 'test'}
    env = CModelDriver.update_ld_library_path(env)
    assert (env['LD_LIBRARY_PATH'] == total)
    # Second time to ensure that path not added twice
    env = CModelDriver.update_ld_library_path(env)
    assert (env['LD_LIBRARY_PATH'] == total)
예제 #2
0
    def set_env(self, **kwargs):
        r"""Get environment variables that should be set for the model process.

        Args:
            **kwargs: Additional keyword arguments are passed to the parent
                class's method.

        Returns:
            dict: Environment variables for the model process.

        """
        if kwargs.get('for_compile', False):
            kwargs.setdefault('compile_kwargs', {})
            kwargs['compile_kwargs']['language'] = self.target_language
            kwargs['compile_kwargs'][
                'language_driver'] = self.target_language_driver
            for k in [
                    'env_compiler', 'env_compiler_flags', 'env_linker',
                    'env_linker_flags'
            ]:
                kwargs['compile_kwargs'][k] = getattr(self, k)
        out = super(MakeModelDriver, self).set_env(**kwargs)
        if not kwargs.get('for_compile', False):
            if hasattr(self.target_language_driver, 'update_ld_library_path'):
                self.target_language_driver.update_ld_library_path(out)
            # C++ may also need the C libraries
            if self.target_language == 'c++':
                out = CModelDriver.update_ld_library_path(out)
        return out
예제 #3
0
    def set_env_class(cls, **kwargs):
        r"""Set environment variables that are instance independent.

        Args:
            **kwargs: Additional keyword arguments are passed to the parent
                class's method and update_ld_library_path.

        Returns:
            dict: Environment variables for the model process.

        """
        out = super(CPPModelDriver, cls).set_env_class(**kwargs)
        out = CModelDriver.update_ld_library_path(out, **kwargs)
        return out
예제 #4
0
    def set_env(self, **kwargs):
        r"""Get environment variables that should be set for the model process.

        Args:
            **kwargs: Additional keyword arguments are passed to the parent
                class's method.

        Returns:
            dict: Environment variables for the model process.

        """
        out = super(CPPModelDriver, self).set_env(**kwargs)
        out = CModelDriver.update_ld_library_path(out)
        return out
예제 #5
0
    def set_env(self):
        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()
        out['RETICULATE_PYTHON'] = PythonModelDriver.get_interpreter()
        c_linker = CModelDriver.get_tool('linker')
        search_dirs = c_linker.get_search_path(conda_only=True)
        out = CModelDriver.update_ld_library_path(out,
                                                  paths_to_add=search_dirs,
                                                  add_to_front=True)
        return out