code: def build_extension(self, ext):
      extdir = os.path.abspath(
          os.path.dirname(self.get_ext_fullpath(ext.name))
      )
      # required for auto-detection of auxiliary "native" libs
      if not extdir.endswith(os.path.sep):
          extdir += os.path.sep
  
      cmake_args = [
          # fixed for lightseq.inference
          "-DCMAKE_LIBRARY_OUTPUT_DIRECTORY="
          + os.path.join(extdir, "lightseq"),
          "-DPYTHON_EXECUTABLE=" + sys.executable,
      ]
  
      cfg = "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"]
          build_args += ["--", "/m"]
      else:
          cmake_args += ["-DCMAKE_BUILD_TYPE=" + cfg]
          cmake_args += (
              ["-DFP16_MODE=OFF"] if ENABLE_FP32 else ["-DFP16_MODE=ON"]
          )
          cmake_args += (
              ["-DDEBUG_MODE=ON"]
              if ENABLE_DEBUG
              else ["-DDEBUG_MODE=OFF"]
          )
          cmake_args += (
              ["-DUSE_NEW_ARCH=ON"]
              if ENABLE_NEW_ARCH
              else ["-DUSE_NEW_ARCH=OFF"]
          )
          cmake_args += ["-DDEVICE_ARCH={}".format(DEVICE_ARCH)]
          cmake_args += ["-DDYNAMIC_API=OFF"]
          build_args += ["--target", "lightseq"]
          build_args += [
              "--",
              "-j{}".format(multiprocessing.cpu_count()),
          ]
  
      env = os.environ.copy()
      env["CXXFLAGS"] = '{} -DVERSION_INFO=\\"{}\\"'.format(
          env.get("CXXFLAGS", ""), self.distribution.get_version()
      )
      if not os.path.exists(self.build_temp):
          os.makedirs(self.build_temp)
      subprocess.check_call(
          ["cmake", ext.sourcedir] + cmake_args,
          cwd=self.build_temp,
          env=env,
      )
      subprocess.check_call(
          ["cmake", "--build", "."] + build_args, cwd=self.build_temp
      )
  
file_path: lightseq/setup.py
imports: import os
  import re
  import sys
  import platform
  import subprocess
  import multiprocessing
  import glob
  import logging
  from setuptools import setup, Extension
  import setuptools
  from setuptools.command.build_ext import build_ext
  from distutils.version import LooseVersion
  from lightseq import __version__
label_desc: Use image node_id 2 for calling the CMakeBuild obj's underlying member method code with example usage: obj.build_extension(ext) without return types