import ctypes


def _get_openblas_version(openblas_dynlib):
    """Return the OpenBLAS version

    None means OpenBLAS is not loaded or version < 0.3.4, since OpenBLAS
    did not expose its version before that.
    """
    get_config = getattr(openblas_dynlib, "openblas_get_config")
    get_config.restype = ctypes.c_char_p
    config = get_config().split()
    if config[0] == b"OpenBLAS":
        return config[1].decode('utf-8')
    return None