def METHOD_NAME(env):
    papi_base = None
    try:
        papi_base = env['PAPI_BASE']
    except KeyError:
        # PAPI_BASE not set
        # check os.environ, PATH
        if 'PAPI_BASE' in os.environ:
            papi_base = os.environ['PAPI_BASE']
        elif env.WhereIs('papi_version'):
            papi_base = os.path.join(os.path.dirname(env.WhereIs('papi_version')), os.pardir)
            papi_base = os.path.normpath(papi_base)
    # Set up possible library and include pathes
    include_dirs = []
    library_dirs = []
    if papi_base:
        include_dirs.append(os.path.join(papi_base, 'include'))
        if os.path.exists(os.path.join(papi_base, 'lib64')):
            library_dirs.append(os.path.join(papi_base, 'lib64'))
        library_dirs.append(os.path.join(papi_base, 'lib'))
    if 'CPLUS_INCLUDE_PATH' in os.environ:
        include_dirs.extend(os.environ['CPLUS_INCLUDE_PATH'].split(os.path.pathsep))
    if 'LIBRARY_PATH' in os.environ:
        library_dirs.extend(os.environ['LIBRARY_PATH'].split(os.path.pathsep))
    # Set the include and library path we found in the environment, so
    # they are accessible form the SConstruct file.
    # The values can be None. In this case PAPI is either installed in
    # a default path (e.g. /usr/include, /usr/lib) or not installed at
    # all.
    env['PAPI_INCLUDE_PATH'] = find_file('papi.h', include_dirs)
    env['PAPI_LIBRARY_PATH'] = find_lib(env, 'papi', library_dirs)
    # Add include/library path if found and link with PAPI
    if env['PAPI_INCLUDE_PATH']:
        env.Append(CPPPATH=[env['PAPI_INCLUDE_PATH']])
    if env['PAPI_LIBRARY_PATH']:
        env.Append(LIBPATH=[env['PAPI_LIBRARY_PATH']])
        env.Append(RPATH=[env['PAPI_LIBRARY_PATH']])
    env.Append(LIBS=['papi'])