class_docstr: Patch SKBuild logic to only take files related to the Python package
  and construct a file hierarchy that SKBuild expects (see below)
class_docstr_tok: ["Patch","SKBuild","logic","to","only","take","files","related","to","the","Python","package","and","construct","a","file","hierarchy","that","SKBuild","expects","(","see","below",")"]
docstr: From all CMake output, we're only interested in a few files
  and must place them into CMake install dir according
  to Python conventions for SKBuild to find them:
      package                    file
          subpackage                        etc.
docstr_tok: ["From","all","CMake","output",",","we","'re","only","interested","in","a","few","files","and","must","place","them","into","CMake","install","dir","according","to","Python","conventions","for","SKBuild","to","find","them",":","package","file","subpackage","etc","."]
code: def _classify_installed_files_override(
      self,
      install_paths,
      package_data,
      package_prefixes,
      py_modules,
      new_py_modules,
      scripts,
      new_scripts,
      data_files,
      cmake_source_dir,
      cmake_install_reldir,
  ):
      """
              From all CMake output, we're only interested in a few files
              and must place them into CMake install dir according
              to Python conventions for SKBuild to find them:
                  package\
                      file
                      subpackage\
                          etc.
          """
  
      cls = self.__class__
  
      # 'relpath'/'reldir' = relative to CMAKE_INSTALL_DIR/cmake_install_dir
      # 'path'/'dir' = relative to sourcetree root
      cmake_install_dir = os.path.join(
          cls._setuptools_wrap.CMAKE_INSTALL_DIR(), cmake_install_reldir
      )
      install_relpaths = [
          os.path.relpath(p, cmake_install_dir) for p in install_paths
      ]
      fslash_install_relpaths = [
          p.replace(os.path.sep, "/") for p in install_relpaths
      ]
      relpaths_zip = list(
          zip(fslash_install_relpaths, install_relpaths)
      )
  
      final_install_relpaths = []
  
      print("Copying files from CMake output")
  
      # add lines from the old __init__.py file to the config file
      with open(
          os.path.join(
              os.path.dirname(os.path.abspath(__file__)),
              "scripts",
              "__init__.py",
          ),
          "r",
      ) as custom_init:
          custom_init_data = custom_init.read()
  
      # OpenCV generates config with different name for case with PYTHON3_LIMITED_API=ON
      config_py = os.path.join(
          cmake_install_dir,
          "python",
          "cv2",
          "config-%s.%s.py"
          % (sys.version_info[0], sys.version_info[1]),
      )
      if not os.path.exists(config_py):
          config_py = os.path.join(
              cmake_install_dir,
              "python",
              "cv2",
              "config-%s.py" % sys.version_info[0],
          )
  
      with open(config_py, "w") as opencv_init_config:
          opencv_init_config.write(custom_init_data)
  
      if sys.version_info >= (3, 6):
          for p in install_relpaths:
              if p.endswith(".pyi"):
                  target_rel_path = os.path.relpath(p, "python/cv2")
                  cls._setuptools_wrap._copy_file(
                      os.path.join(cmake_install_dir, p),
                      os.path.join(
                          cmake_install_dir, "cv2", target_rel_path
                      ),
                      hide_listing=False,
                  )
                  final_install_relpaths.append(
                      os.path.join("cv2", target_rel_path)
                  )
  
      del install_relpaths, fslash_install_relpaths
  
      for package_name, relpaths_re in cls.package_paths_re.items():
          package_dest_reldir = package_name.replace(".", os.path.sep)
          for relpath_re in relpaths_re:
              found = False
              r = re.compile(relpath_re + "$")
              for fslash_relpath, relpath in relpaths_zip:
                  m = r.match(fslash_relpath)
                  if not m:
                      continue
                  found = True
                  new_install_relpath = os.path.join(
                      package_dest_reldir, os.path.basename(relpath)
                  )
                  cls._setuptools_wrap._copy_file(
                      os.path.join(cmake_install_dir, relpath),
                      os.path.join(
                          cmake_install_dir, new_install_relpath
                      ),
                      hide_listing=False,
                  )
                  final_install_relpaths.append(new_install_relpath)
                  del m, fslash_relpath, new_install_relpath
              else:
                  # gapi can be missed if ADE was not downloaded (network issue)
                  if not found and "gapi" not in relpath_re:
                      raise Exception("Not found: '%s'" % relpath_re)
              del r, found
  
      del relpaths_zip
  
      print("Copying files from non-default sourcetree locations")
  
      for package_name, paths in cls.files_outside_package.items():
          package_dest_reldir = package_name.replace(".", os.path.sep)
          for path in paths:
              new_install_relpath = os.path.join(
                  package_dest_reldir,
                  # Don't yet have a need to copy
                  # to subdirectories of package dir
                  os.path.basename(path),
              )
              cls._setuptools_wrap._copy_file(
                  path,
                  os.path.join(cmake_install_dir, new_install_relpath),
                  hide_listing=False,
              )
              final_install_relpaths.append(new_install_relpath)
  
      final_install_paths = [
          os.path.join(cmake_install_dir, p)
          for p in final_install_relpaths
      ]
  
      return (cls.wraps._classify_installed_files)(
          final_install_paths,
          package_data,
          package_prefixes,
          py_modules,
          new_py_modules,
          scripts,
          new_scripts,
          data_files,
          # To get around a check that prepends source dir to paths and breaks package detection code.
          cmake_source_dir="",
          _cmake_install_dir=cmake_install_reldir,
      )
  
file_path: opencv-python/setup.py
imports: import io
  import os
  import os.path
  import sys
  import runpy
  import subprocess
  import re
  import sysconfig
  import platform
  from skbuild import cmaker, setup
label_desc: Use image node_id 3 for calling the RearrangeCMakeOutput obj's underlying member method code with example usage: obj._classify_installed_files_override(install_paths, package_data, package_prefixes, py_modules, new_py_modules, scripts, new_scripts, data_files, cmake_source_dir, cmake_install_reldir) and returns: cls