class_docstr: Compiles everything when `python setup.py build` is run using cmake.
  
  Custom args can be passed to cmake by specifying the `CMAKE_ARGS`
  environment variable.
  
  The number of CPUs used by `make` can be specified by passing `-j<ncpus>`
  to `setup.py build`.  By default all CPUs are used.
class_docstr_tok: ["Compiles","everything","when","`","python","setup.py","build","`","is","run","using","cmake",".","Custom","args","can","be","passed","to","cmake","by","specifying","the","`","CMAKE_ARGS","`","environment","variable",".","The","number","of","CPUs","used","by","`","make","`","can","be","specified","by","passing","`","-j","<","ncpus",">","`","to","`","setup.py","build","`",".","By","default","all","CPUs","are","used","."]
code: def run(self):
      os.makedirs(CMAKE_BUILD_DIR, exist_ok=True)
  
      with cd(CMAKE_BUILD_DIR):
          build_type = "Release"
          # configure
          cmake_args = [
              CMAKE,
              f"-DPYTHON_INCLUDE_DIR={sysconfig.get_path('include')}",
              f"-DPYTHON_EXECUTABLE={sys.executable}",
              "-DBUILD_ONNX_PYTHON=ON",
              "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON",
              f"-DONNX_NAMESPACE={ONNX_NAMESPACE}",
              f"-DPY_EXT_SUFFIX={get_ext_suffix() or ''}",
          ]
          if COVERAGE:
              cmake_args.append("-DONNX_COVERAGE=ON")
          if COVERAGE or DEBUG:
              # in order to get accurate coverage information, the
              # build needs to turn off optimizations
              build_type = "Debug"
          cmake_args.append(f"-DCMAKE_BUILD_TYPE={build_type}")
          if WINDOWS:
              cmake_args.extend(
                  [
                      # we need to link with libpython on windows, so
                      # passing python version to window in order to
                      # find python in cmake
                      f"-DPY_VERSION={'{}.{}'.format(*sys.version_info[:2])}",
                  ]
              )
              if USE_MSVC_STATIC_RUNTIME:
                  cmake_args.append("-DONNX_USE_MSVC_STATIC_RUNTIME=ON")
              if platform.architecture()[0] == "64bit":
                  if "arm" in platform.machine().lower():
                      cmake_args.extend(["-A", "ARM64"])
                  else:
                      cmake_args.extend(["-A", "x64", "-T", "host=x64"])
              else:  # noqa: PLR5501
                  if "arm" in platform.machine().lower():
                      cmake_args.extend(["-A", "ARM"])
                  else:
                      cmake_args.extend(
                          ["-A", "Win32", "-T", "host=x86"]
                      )
          if ONNX_ML:
              cmake_args.append("-DONNX_ML=1")
          if ONNX_VERIFY_PROTO3:
              cmake_args.append("-DONNX_VERIFY_PROTO3=1")
          if ONNX_BUILD_TESTS:
              cmake_args.append("-DONNX_BUILD_TESTS=ON")
          if ONNX_DISABLE_EXCEPTIONS:
              cmake_args.append("-DONNX_DISABLE_EXCEPTIONS=ON")
          if ONNX_DISABLE_STATIC_REGISTRATION:
              cmake_args.append("-DONNX_DISABLE_STATIC_REGISTRATION=ON")
          if "CMAKE_ARGS" in os.environ:
              extra_cmake_args = shlex.split(os.environ["CMAKE_ARGS"])
              # prevent crossfire with downstream scripts
              del os.environ["CMAKE_ARGS"]
              logging.info("Extra cmake args: %s", extra_cmake_args)
              cmake_args.extend(extra_cmake_args)
          cmake_args.append(TOP_DIR)
          logging.info("Using cmake args: %s", cmake_args)
          if "-DONNX_DISABLE_EXCEPTIONS=ON" in cmake_args:
              raise RuntimeError(
                  "-DONNX_DISABLE_EXCEPTIONS=ON option is only available for c++ builds. Python binding require exceptions to be enabled."
              )
          if (
              "PYTHONPATH" in os.environ
              and "pip-build-env" in os.environ["PYTHONPATH"]
          ):
              # When the users use `pip install -e .` to install onnx and
              # the cmake executable is a python entry script, there will be
              # `Fix ModuleNotFoundError: No module named 'cmake'` from the cmake script.
              # This is caused by the additional PYTHONPATH environment variable added by pip,
              # which makes cmake python entry script not able to find correct python cmake packages.
              # Actually, sys.path is well enough for `pip install -e .`.
              # Therefore, we delete the PYTHONPATH variable.
              del os.environ["PYTHONPATH"]
          subprocess.check_call(cmake_args)
  
          build_args = [CMAKE, "--build", os.curdir]
          if WINDOWS:
              build_args.extend(["--config", build_type])
              build_args.extend(["--", f"/maxcpucount:{self.jobs}"])
          else:
              build_args.extend(["--", "-j", str(self.jobs)])
          subprocess.check_call(build_args)
  
imports: import contextlib
  import datetime
  import glob
  import logging
  import multiprocessing
  import os
  import platform
  import shlex
  import shutil
  import subprocess
  import sys
  import sysconfig
  import textwrap
  from typing import ClassVar
  import setuptools
  import setuptools.command.build_ext
  import setuptools.command.build_py
  import setuptools.command.develop
label_desc: Use image node_id 3 for calling the CmakeBuild obj's underlying member method code with example usage: obj.run() without return types