def configure(self, candidates=None, use_distutils=True):
        ctx = self.ctx
        # How we do it
        # 1: for distutils-based configuration
        #   - get compile/flags flags from sysconfig
        #   - detect yaku tool name from CC used by distutils:
        #       - get the compiler executable used by distutils ($CC
        #       variable)
        #       - try to determine yaku tool name from $CC
        #   - apply necessary variables from yaku tool to $PYEXT_
        #   "namespace"
        if candidates is None:
            compiler_type = "default"
        else:
            compiler_type = candidates[0]

        if use_distutils:
            dist_env = setup_pyext_env(ctx, compiler_type)
            ctx.env.update(dist_env)

            cc_exec = get_distutils_cc_exec(ctx, compiler_type)
            yaku_cc_type = detect_cc_type(ctx, cc_exec)
            if yaku_cc_type is None:
                raise ValueError("No adequate C compiler found (distutils mode)")

            _setup_compiler(ctx, yaku_cc_type)

            cxx_exec = get_distutils_cxx_exec(ctx, compiler_type)
            yaku_cxx_type = detect_cxx_type(ctx, cxx_exec)
            if yaku_cxx_type is None:
                raise ValueError("No adequate CXX compiler found (distutils mode)")

            _setup_cxxcompiler(ctx, yaku_cxx_type)
        else:
            dist_env = setup_pyext_env(ctx, compiler_type, False)
            ctx.env.update(dist_env)
            _setup_compiler(ctx, compiler_type)

        pycode = r"""\
#include <Python.h>
#include <stdio.h>

static PyObject*
hello(PyObject *self, PyObject *args)
{
    printf("Hello from C\n");
    Py_INCREF(Py_None);
    return Py_None;
}

static PyMethodDef HelloMethods[] = {
    {"hello",  hello, METH_VARARGS, "Print a hello world."},
    {NULL, NULL, 0, NULL}        /* Sentinel */
};

PyMODINIT_FUNC
init_bar(void)
{
    (void) Py_InitModule("_bar", HelloMethods);
}
"""
        ctx.start_message("Checking whether %s can build python object code" % compiler_type)
        try:
            self.try_compile("foo", pycode)
            ctx.end_message("yes")
        except TaskRunFailure:
            e = get_exception()
            ctx.end_message("no")
            ctx.fail_configuration(str(e))

        ctx.start_message("Checking whether %s can build python extension" % compiler_type)
        try:
            self.try_extension("foo", pycode)
            ctx.end_message("yes")
        except TaskRunFailure:
            e = get_exception()
            ctx.end_message("no")
            ctx.fail_configuration(str(e))
        self.configured = True
dataset/ETHPy150Open cournape/Bento/bento/private/_yaku/yaku/tools/pyext.py/PythonBuilder.configure/original