code: def build_extension(self, ext):
      extdir = os.path.abspath(
          os.path.dirname(self.get_ext_fullpath(ext.name))
      )
  
      cmake_args = [
          "-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=" + extdir,
          "-DPYTHON_EXECUTABLE=" + sys.executable,
      ]
  
      cmake_args += cmake_extra_options
  
      cfg = "Debug" if self.debug else "Release"
      build_args = ["--config", cfg]
  
      if platform.system() == "Windows":
          cmake_args += [
              "-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{}={}".format(
                  cfg.upper(), extdir
              )
          ]
          if sys.maxsize > 2**32:
              cmake_args += ["-A", "x64"]
          # Do a parallel build
          build_args += ["--", "/m"]
      else:
          cmake_args += ["-DCMAKE_BUILD_TYPE=" + cfg]
          # Do a parallel build
          build_args += ["--", "-j" + str(num_available_cpu_cores(2))]
  
      build_folder = os.path.abspath(self.build_temp)
  
      if clean_build_folder:
          rmtree(build_folder)
      if not os.path.exists(build_folder):
          os.makedirs(build_folder)
  
      cmake_setup = ["cmake", ext.sourcedir] + cmake_args
      cmake_build = ["cmake", "--build", "."] + build_args
  
      print(
          "Building extension for Python {}".format(
              sys.version.split("\n", 1)[0]
          )
      )
      print("Invoking CMake setup: '{}'".format(" ".join(cmake_setup)))
      sys.stdout.flush()
      subprocess.check_call(cmake_setup, cwd=build_folder)
      print("Invoking CMake build: '{}'".format(" ".join(cmake_build)))
      sys.stdout.flush()
      subprocess.check_call(cmake_build, cwd=build_folder)
  
imports: import os
  import re
  import sys
  import shutil
  import platform
  import subprocess
  import multiprocessing
  from distutils import log
  from math import ceil, floor
  from setuptools import find_packages, setup, Extension
  from setuptools.command.build_ext import build_ext
  from distutils.version import LooseVersion
  from setuptools.command.test import test
label_desc: Use image node_id 3 for calling the CMakeBuild obj's underlying member method code with example usage: obj.build_extension(ext) without return types