MCPcopy Create free account
hub / github.com/opencv/opencv-python / _classify_installed_files_override

Method _classify_installed_files_override

setup.py:358–488  ·  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

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected