<commit_before>from numscons.checkers.perflib_checkers import \
        _check_perflib
from numscons.checkers.common import \
        get_perflib_names, get_initialized_perflib_config, \
        save_and_set, restore, set_checker_result
from numscons.checkers.testcode_snippets import \
        BLAS_TEST_CODE, LAPACK_TEST_CODE, CBLAS_TEST_CODE
from numscons.checkers.fortran import CheckF77Mangling

__all__ = ['CheckF77Lapack', 'CheckF77Blas', 'CheckCblas']

def _check_fortran(context, name, autoadd, test_code_tpl, func):
    # Generate test code using name mangler
    try:
        mangler = context.env['F77_NAME_MANGLER']
    except KeyError:
        if not CheckF77Mangling(context):
            return 0
        mangler = context.env['F77_NAME_MANGLER']
    test_code = test_code_tpl % {'func': mangler(func)}

    # Detect which performance library to use
    info = None
    for perflib in get_perflib_names(context.env):
        _info = get_initialized_perflib_config(context.env, perflib)
        if  name in _info.interfaces() and _check_perflib(context, 0, _info):
            info = _info
            break

    context.Message("Checking for F77 %s ... " % name)

    if info is None:
        context.Result('no')
        return 0

    if not name in info.interfaces():
        raise RuntimeError("%s does not support %s interface" % \
                (info.__class__, name))

    saved = save_and_set(context.env, info._interfaces[name],
                info._interfaces[name].keys())
    ret = context.TryLink(test_code, extension='.c')
    if not ret or not autoadd:
        restore(context.env, saved)
    if not ret:
        context.Result('no')
    context.Result('yes - %s' % info.name)
    set_checker_result(context.env, name, info)
    return ret

def _check_c(context, name, autoadd, test_code):
    # Detect which performance library to use
    info = None
    for perflib in get_perflib_names(context.env):
        _info = get_initialized_perflib_config(context.env, perflib)
        if  name in _info.interfaces() and _check_perflib(context, 0, _info):
            info = _info<commit_msg>ENH: automatically check for fortran linkflags in netlib checker.<commit_after>from numscons.checkers.perflib_checkers import \
        _check_perflib
from numscons.checkers.common import \
        get_perflib_names, get_initialized_perflib_config, \
        save_and_set, restore, set_checker_result
from numscons.checkers.testcode_snippets import \
        BLAS_TEST_CODE, LAPACK_TEST_CODE, CBLAS_TEST_CODE
from numscons.checkers.fortran import CheckF77Mangling, CheckF77Clib

__all__ = ['CheckF77Lapack', 'CheckF77Blas', 'CheckCblas']

def _check_fortran(context, name, autoadd, test_code_tpl, func):
    # Generate test code using name mangler
    try:
        mangler = context.env['F77_NAME_MANGLER']
    except KeyError:
        if not CheckF77Mangling(context):
            return 0
        mangler = context.env['F77_NAME_MANGLER']
    test_code = test_code_tpl % {'func': mangler(func)}

    try:
        f77_ldflags = context.env['F77_LDFLAGS']
    except KeyError:
        if not CheckF77Clib(context, autoadd=0):
            return 0
        f77_ldflags = context.env['F77_LDFLAGS']

    # Detect which performance library to use
    info = None
    for perflib in get_perflib_names(context.env):
        _info = get_initialized_perflib_config(context.env, perflib)
        if  name in _info.interfaces() and _check_perflib(context, 0, _info):
            info = _info
            break

    context.Message("Checking for F77 %s ... " % name)

    if info is None:
        context.Result('no')
        return 0

    if not info._interfaces[name].has_key("LINKFLAGSEND"):
        info._interfaces[name]["LINKFLAGSEND"] = f77_ldflags[:]
    else:
        info._interfaces[name]["LINKFLAGSEND"].extend(f77_ldflags[:])

    if not name in info.interfaces():
        raise RuntimeError("%s does not support %s interface" % \
                (info.__class__, name))

    saved = save_and_set(context.env, info._interfaces[name],
                info._interfaces[name].keys())
    ret = context.TryLink(test_code, extension='.c')
    if not ret or not autoadd:
        restore(context.env, saved)
    if not ret:
        context.Result('no')
    context.Result('yes - %s' % info.name)
    set_checker_result(context.env, name, info)
    return ret

def _check_c(context, name, autoadd, test_code):
    # Detect which performance library to use
    info = None
    for perflib in get_perflib_names(context.env):
        _info = get_initialized_perflib_config(context.env, perflib)
        if  name in _info.interfaces() and _check_perflib(context, 0, _info):
            info = _info
{'fraction_non_alphanumeric': 0.09390269810919906, 'fraction_numerical': 0.011472275334608031, 'mean_word_length': 3.0412017167381973, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '112232', 'n_tokens_mistral': 1568, 'n_tokens_neox': 1526, 'n_words': 354}