code: def build_extension_cmake(self, ext):
      extdir = os.path.abspath(
          os.path.dirname(self.get_ext_fullpath(ext.name))
      )
      cfg = "Debug" if self.debug else "Release"
  
      PYTHON_VERSION = "{}.{}".format(
          sys.version_info.major, sys.version_info.minor
      )
  
      cmake_args = [
          "-DCMAKE_LIBRARY_OUTPUT_DIRECTORY="
          + os.path.abspath(
              os.path.join(extdir, "perspective", "table")
          ).replace("\\", "/"),
          "-DCMAKE_BUILD_TYPE=" + cfg,
          "-DPSP_CPP_BUILD=1",
          "-DPSP_WASM_BUILD=0",
          "-DPSP_PYTHON_BUILD=1",
          "-DPSP_PYTHON_VERSION={}".format(PYTHON_VERSION),
          "-DPython_ADDITIONAL_VERSIONS={}".format(PYTHON_VERSION),
          "-DPython_FIND_VERSION={}".format(PYTHON_VERSION),
          "-DPython_EXECUTABLE={}".format(sys.executable).replace(
              "\\", "/"
          ),
          "-DPYTHON_LIBRARY={}".format(
              sysconfig.get_config_var("LIBDIR")
          ).replace("\\", "/"),
          "-DPYTHON_INCLUDE_DIR={}".format(
              sysconfig.get_config_var("INCLUDEPY")
          ).replace("\\", "/"),
          "-DPython_ROOT_DIR={}".format(sys.prefix).replace("\\", "/"),
          "-DPython_ROOT={}".format(sys.prefix).replace("\\", "/"),
          "-DPSP_CMAKE_MODULE_PATH={folder}".format(
              folder=os.path.join(ext.sourcedir, "cmake")
          ).replace("\\", "/"),
          "-DPSP_CPP_SRC={folder}".format(folder=ext.sourcedir).replace(
              "\\", "/"
          ),
          "-DPSP_PYTHON_SRC={folder}".format(
              folder=os.path.join(
                  ext.sourcedir, "..", "perspective"
              ).replace("\\", "/")
          ),
      ]
  
      build_args = ["--config", cfg]
      env = os.environ.copy()
  
      if platform.system() == "Windows":
          import distutils.msvccompiler as dm
  
          # https://wiki.python.org/moin/WindowsCompilers#Microsoft_Visual_C.2B-.2B-_14.0_with_Visual_Studio_2015_.28x86.2C_x64.2C_ARM.29
          msvc = {
              "12": "Visual Studio 12 2013",
              "14": "Visual Studio 14 2015",
              "14.0": "Visual Studio 14 2015",
              "14.1": "Visual Studio 15 2017",
              "14.2": "Visual Studio 16 2019",
              "14.3": "Visual Studio 17 2022",
          }.get(dm.get_build_version(), "Visual Studio 15 2017")
  
          cmake_args.extend(
              [
                  "-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{}={}".format(
                      cfg.upper(), extdir
                  ).replace("\\", "/"),
                  "-G",
                  os.environ.get("PSP_GENERATOR", msvc),
              ]
          )
  
          vcpkg_toolchain_file = os.path.abspath(
              os.environ.get(
                  "PSP_VCPKG_PATH",
                  os.path.join(
                      "..",
                      "..",
                      "vcpkg\\scripts\\buildsystems\\vcpkg.cmake",
                  ),
              )
          )
  
          if os.path.exists(vcpkg_toolchain_file):
              cmake_args.append(
                  "-DCMAKE_TOOLCHAIN_FILE={}".format(
                      vcpkg_toolchain_file.replace("\\", "/")
                  )
              )
  
          if sys.maxsize > 2**32:
              # build 64 bit to match python
              cmake_args += ["-A", "x64"]
  
          build_args += [
              "--",
              "/m:{}".format(CPU_COUNT),
              "/p:Configuration={}".format(cfg),
          ]
      else:
          cmake_args += ["-DCMAKE_BUILD_TYPE=" + cfg]
          build_args += [
              "--",
              "-j2"
              if os.environ.get("DOCKER", "")
              else "-j{}".format(env.get("PSP_NUM_CPUS", CPU_COUNT)),
          ]
  
      env["PSP_ENABLE_PYTHON"] = "1"
      env["OSX_DEPLOYMENT_TARGET"] = os.environ.get(
          "PSP_OSX_DEPLOYMENT_TARGET", "10.13"
      )
      env["MACOSX_DEPLOYMENT_TARGET"] = os.environ.get(
          "PSP_OSX_DEPLOYMENT_TARGET", "10.13"
      )
  
      if not os.path.exists(self.build_temp):
          os.makedirs(self.build_temp)
  
      subprocess.check_call(
          [self.cmake_cmd, os.path.abspath(ext.sourcedir)] + cmake_args,
          cwd=self.build_temp,
          env=env,
          stderr=subprocess.STDOUT,
      )
      subprocess.check_call(
          [self.cmake_cmd, "--build", "."] + build_args,
          cwd=self.build_temp,
          env=env,
          stderr=subprocess.STDOUT,
      )
      print()
  
imports: from __future__ import print_function
  import os
  import os.path
  import platform
  import re
  import subprocess
  import sys
  import sysconfig
  from codecs import open
  from distutils.version import LooseVersion
  from jupyter_packaging import get_data_files, wrap_installers, get_version
  from setuptools import Extension, find_packages, setup
  from setuptools.command.build_ext import build_ext
  from setuptools.command.sdist import sdist
label_desc: Use image node_id 3 for calling the PSPBuild obj's underlying member method code with example usage: obj.build_extension_cmake(ext) without return types