Return full path to the shared library.

        A couple of regular unix paths like ``/usr/lib/`` is searched by
        default. If your library is not in one of those, set a
        ``LD_LIBRARY_PATH`` environment variable to the directory with your
        shared library.

        If the library cannot be found, a ``RuntimeError`` with debug
        information is raised.

def _library_path(self):
        """Return full path to the shared library.

        A couple of regular unix paths like ``/usr/lib/`` is searched by
        default. If your library is not in one of those, set a
        ``LD_LIBRARY_PATH`` environment variable to the directory with your
        shared library.

        If the library cannot be found, a ``RuntimeError`` with debug
        information is raised.
        """

        # engine is an existing library name
        # TODO change add directory to library path
        if os.path.isfile(self.engine):
            return self.engine

        pathname = 'LD_LIBRARY_PATH'
        separator = ':'
        if platform.system() == 'Darwin':
            pathname = 'DYLD_LIBRARY_PATH'
            separator = ':'
        if platform.system() == 'Windows':
            # windows does not separate between dll path's and exe paths
            pathname = 'PATH'
            separator = ';'

        lib_path_from_environment = os.environ.get(pathname, '')
        # Expand the paths with the system path if it exists
        if lib_path_from_environment:
            known_paths = [
                path for path in lib_path_from_environment.split(separator)] + self.known_paths
        else:
            known_paths = self.known_paths
        # expand ~
        known_paths = [os.path.expanduser(path) for path in known_paths]

        possible_libraries = [os.path.join(path, self._libname())
                              for path in known_paths]
        for library in possible_libraries:
            if os.path.exists(library):
                logger.info("Using model fortran library %s", library)
                return library
        msg = "Library not found, looked in %s" % ', '.join(possible_libraries)
        raise RuntimeError(msg)