code: def customize_compiler_for_nvcc(self):
      """Inject deep into distutils to customize how the dispatch
      to gcc/nvcc works.
      If you subclass UnixCCompiler, it's not trivial to get your subclass
      injected in, and still have the right customizations (i.e.
      distutils.sysconfig.customize_compiler) run on it. So instead of going
      the OO route, I have this. Note, it's kindof like a wierd functional
      subclassing going on.
      """
  
      # Tell the compiler it can processes .cu
      self.src_extensions.append(".cu")
  
      # Save references to the default compiler_so and _comple methods
      default_compiler_so = self.compiler_so
      super = self._compile
  
      # Now redefine the _compile method. This gets executed for each
      # object but distutils doesn't have the ability to change compilers
      # based on source extension: we add it.
      def _compile(obj, src, ext, cc_args, extra_postargs, pp_opts):
          if os.path.splitext(src)[1] == ".cu":
              # use the cuda for .cu files
              self.set_executable("compiler_so", "nvcc")
              # use only a subset of the extra_postargs, which are 1-1
              # translated from the extra_compile_args in the Extension class
              postargs = extra_postargs["nvcc"]
          else:
              postargs = extra_postargs["gcc"]
  
          super(obj, src, ext, cc_args, postargs, pp_opts)
          # Reset the default compiler_so, which we might have changed for cuda
          self.compiler_so = default_compiler_so
  
      # Inject our redefined _compile method into the class
      self._compile = _compile
  
imports: from setuptools import find_packages, setup, Command, Extension
  from setuptools.command.build_ext import build_ext
  from distutils.errors import CompileError, DistutilsSetupError
  import os
  import io
  import sys
  import subprocess
  import shutil
  import shlex
  from pathlib import Path
  import numpy
  from datetime import date
label_desc: Use image node_id 7 for calling a global function with example usage: customize_compiler_for_nvcc() without return types