code: def _run_cmake(self):
      # check if build_type is correctly passed / set
      if self.build_type.lower() not in (
          "release",
          "debug",
          "relwithdebinfo",
      ):
          raise ValueError(
              "--build-type (or PYARROW_BUILD_TYPE) needs to "
              "be 'release', 'debug' or 'relwithdebinfo'"
          )
  
      # The directory containing this setup.py
      source = os.path.dirname(os.path.abspath(__file__))
  
      # The staging directory for the module being built
      build_cmd = self.get_finalized_command("build")
      saved_cwd = os.getcwd()
      build_temp = pjoin(saved_cwd, build_cmd.build_temp)
      build_lib = pjoin(saved_cwd, build_cmd.build_lib)
  
      if not os.path.isdir(build_temp):
          self.mkpath(build_temp)
  
      if self.inplace:
          # a bit hacky
          build_lib = saved_cwd
  
      install_prefix = pjoin(build_lib, "pyarrow")
  
      # Change to the build directory
      with changed_dir(build_temp):
          # Detect if we built elsewhere
          if os.path.isfile("CMakeCache.txt"):
              cachefile = open("CMakeCache.txt", "r")
              cachedir = re.search(
                  "CMAKE_CACHEFILE_DIR:INTERNAL=(.*)", cachefile.read()
              ).group(1)
              cachefile.close()
              if cachedir != build_temp:
                  build_base = pjoin(saved_cwd, build_cmd.build_base)
                  print(
                      f"-- Skipping build. Temp build {build_temp} does "
                      f"not match cached dir {cachedir}"
                  )
                  print(
                      "---- For a clean build you might want to delete "
                      f"{build_base}."
                  )
                  return
  
          cmake_options = [
              f"-DCMAKE_INSTALL_PREFIX={install_prefix}",
              f"-DPYTHON_EXECUTABLE={sys.executable}",
              f"-DPython3_EXECUTABLE={sys.executable}",
              f"-DPYARROW_CXXFLAGS={self.cmake_cxxflags}",
          ]
  
          def append_cmake_bool(value, varname):
              cmake_options.append(
                  "-D{0}={1}".format(varname, "on" if value else "off")
              )
  
          if self.cmake_generator:
              cmake_options += ["-G", self.cmake_generator]
  
          append_cmake_bool(self.with_cuda, "PYARROW_BUILD_CUDA")
          append_cmake_bool(
              self.with_substrait, "PYARROW_BUILD_SUBSTRAIT"
          )
          append_cmake_bool(self.with_flight, "PYARROW_BUILD_FLIGHT")
          append_cmake_bool(self.with_gandiva, "PYARROW_BUILD_GANDIVA")
          append_cmake_bool(self.with_acero, "PYARROW_BUILD_ACERO")
          append_cmake_bool(self.with_dataset, "PYARROW_BUILD_DATASET")
          append_cmake_bool(self.with_orc, "PYARROW_BUILD_ORC")
          append_cmake_bool(self.with_parquet, "PYARROW_BUILD_PARQUET")
          append_cmake_bool(
              self.with_parquet_encryption,
              "PYARROW_BUILD_PARQUET_ENCRYPTION",
          )
          append_cmake_bool(self.with_gcs, "PYARROW_BUILD_GCS")
          append_cmake_bool(self.with_s3, "PYARROW_BUILD_S3")
          append_cmake_bool(self.with_hdfs, "PYARROW_BUILD_HDFS")
          append_cmake_bool(
              self.bundle_arrow_cpp, "PYARROW_BUNDLE_ARROW_CPP"
          )
          append_cmake_bool(
              self.bundle_cython_cpp, "PYARROW_BUNDLE_CYTHON_CPP"
          )
          append_cmake_bool(
              self.generate_coverage, "PYARROW_GENERATE_COVERAGE"
          )
  
          cmake_options.append(
              f"-DCMAKE_BUILD_TYPE={self.build_type.lower()}"
          )
  
          extra_cmake_args = shlex.split(self.extra_cmake_args)
  
          build_tool_args = []
          if sys.platform == "win32":
              if not is_64_bit:
                  raise RuntimeError("Not supported on 32-bit Windows")
          else:
              build_tool_args.append("--")
              if os.environ.get("PYARROW_BUILD_VERBOSE", "0") == "1":
                  cmake_options.append("-DCMAKE_VERBOSE_MAKEFILE=ON")
              parallel = os.environ.get("PYARROW_PARALLEL")
              if parallel:
                  build_tool_args.append(f"-j{parallel}")
  
          # Generate the build files
          print("-- Running cmake for PyArrow")
          self.spawn(
              ["cmake"] + extra_cmake_args + cmake_options + [source]
          )
          print("-- Finished cmake for PyArrow")
  
          print("-- Running cmake --build for PyArrow")
          self.spawn(
              ["cmake", "--build", ".", "--config", self.build_type]
              + build_tool_args
          )
          print("-- Finished cmake --build for PyArrow")
  
          print("-- Running cmake --build --target install for PyArrow")
          self.spawn(
              ["cmake", "--build", ".", "--config", self.build_type]
              + ["--target", "install"]
              + build_tool_args
          )
          print(
              "-- Finished cmake --build --target install for PyArrow"
          )
  
          self._found_names = []
          for name in self.CYTHON_MODULE_NAMES:
              built_path = pjoin(install_prefix, name + ext_suffix)
              if not os.path.exists(built_path):
                  print(f"Did not find {built_path}")
                  if self._failure_permitted(name):
                      print(f"Cython module {name} failure permitted")
                      continue
                  raise RuntimeError(
                      "PyArrow C-extension failed to build:",
                      os.path.abspath(built_path),
                  )
  
              self._found_names.append(name)
  
imports: import contextlib
  import os
  import os.path
  from os.path import join
  import re
  import shlex
  import sys
  import pkg_resources
  from setuptools import setup, Extension, Distribution, find_namespace_packages
  from Cython.Distutils import build_ext
  import Cython
label_desc: Use image node_id 4 for calling the build_ext obj's underlying member method code with example usage: obj._run_cmake() without return types