code: def compile_cutils():
      """
      Do just the compilation of cutils_ext.
  
      """
      code = """
          #include <Python.h>
          #include "theano_mod_helper.h"
  
          extern "C"{
          static PyObject *
          run_cthunk(PyObject *self, PyObject *args)
          {
            PyObject *py_cthunk = NULL;
            if(!PyArg_ParseTuple(args,"O",&py_cthunk))
              return NULL;
  
            if (!PyCObject_Check(py_cthunk)) {
              PyErr_SetString(PyExc_ValueError,
                             "Argument to run_cthunk must be a PyCObject.");
              return NULL;
            }
            void * ptr_addr = PyCObject_AsVoidPtr(py_cthunk);
            int (*fn)(void*) = (int (*)(void*))(ptr_addr);
            void* it = PyCObject_GetDesc(py_cthunk);
            int failure = fn(it);
  
            return Py_BuildValue("i", failure);
           }
           static PyMethodDef CutilsExtMethods[] = {
              {"run_cthunk",  run_cthunk, METH_VARARGS|METH_KEYWORDS,
               "Run a theano cthunk."},
              {NULL, NULL, 0, NULL}        /* Sentinel */
          };"""
      if PY3:
          # This is not the most efficient code, but it is written this way to
          # highlight the changes needed to make 2.x code compile under python 3.
          code = code.replace("<Python.h>", '"numpy/npy_3kcompat.h"', 1)
          code = code.replace("PyCObject", "NpyCapsule")
          code += """
          static struct PyModuleDef moduledef = {
              PyModuleDef_HEAD_INIT,
              "cutils_ext",
              NULL,
              -1,
              CutilsExtMethods,
          };
  
          PyMODINIT_FUNC
          PyInit_cutils_ext(void) {
              return PyModule_Create(&moduledef);
          }
          }
          """
      else:
          code += """
          PyMODINIT_FUNC
          initcutils_ext(void)
          {
            (void) Py_InitModule("cutils_ext", CutilsExtMethods);
          }
      } //extern C
          """
  
      loc = os.path.join(config.compiledir, "cutils_ext")
      if not os.path.exists(loc):
          try:
              os.mkdir(loc)
          except OSError as e:
              assert e.errno == errno.EEXIST
              assert os.path.exists(loc), loc
  
      args = cmodule.GCC_compiler.compile_args(march_flags=False)
      cmodule.GCC_compiler.compile_str(
          "cutils_ext", code, location=loc, preargs=args
      )
  
file_path: Theano/theano/gof/cutils.py
imports: from __future__ import absolute_import, print_function, division
  import errno
  import os
  import sys
  from theano.compat import PY3
  from theano.gof.compilelock import get_lock, release_lock
  from theano import config
  from .None import cmodule
label_desc: Use image node_id 1 for calling a global function with example usage: compile_cutils() without return types