MCPcopy Index your code
hub / github.com/opencv/opencv-python / _classify_installed_files_override

Method _classify_installed_files_override

setup.py:362–492  ·  view source on GitHub ↗

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\

(
        self,
        install_paths,
        package_data,
        package_prefixes,
        py_modules,
        new_py_modules,
        scripts,
        new_scripts,
        data_files,
        cmake_source_dir,
        cmake_install_reldir,
    )

Source from the content-addressed store, hash-verified

360 cls._setuptools_wrap = None
361
362 def _classify_installed_files_override(
363 self,
364 install_paths,
365 package_data,
366 package_prefixes,
367 py_modules,
368 new_py_modules,
369 scripts,
370 new_scripts,
371 data_files,
372 cmake_source_dir,
373 cmake_install_reldir,
374 ):
375 """
376 From all CMake output, we're only interested in a few files
377 and must place them into CMake install dir according
378 to Python conventions for SKBuild to find them:
379 package\
380 file
381 subpackage\
382 etc.
383 """
384
385 cls = self.__class__
386
387 # 'relpath'/'reldir' = relative to CMAKE_INSTALL_DIR/cmake_install_dir
388 # 'path'/'dir' = relative to sourcetree root
389 cmake_install_dir = os.path.join(
390 cls._setuptools_wrap.CMAKE_INSTALL_DIR(), cmake_install_reldir
391 )
392 install_relpaths = [
393 os.path.relpath(p, cmake_install_dir) for p in install_paths
394 ]
395 fslash_install_relpaths = [
396 p.replace(os.path.sep, "/") for p in install_relpaths
397 ]
398 relpaths_zip = list(zip(fslash_install_relpaths, install_relpaths))
399
400 final_install_relpaths = []
401
402 print("Copying files from CMake output")
403
404 # add lines from the old __init__.py file to the config file
405 with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'scripts', '__init__.py'), 'r') as custom_init:
406 custom_init_data = custom_init.read()
407
408 # OpenCV generates config with different name for case with PYTHON3_LIMITED_API=ON
409 config_py = os.path.join(cmake_install_dir, 'python', 'cv2', 'config-%s.%s.py'
410 % (sys.version_info[0], sys.version_info[1]))
411 if not os.path.exists(config_py):
412 config_py = os.path.join(cmake_install_dir, 'python', 'cv2', 'config-%s.py' % sys.version_info[0])
413
414 with open(config_py, 'w') as opencv_init_config:
415 opencv_init_config.write(custom_init_data)
416
417 if sys.version_info >= (3, 6):
418 for p in install_relpaths:
419 if p.endswith(".pyi"):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected