Invoke CMake to build the Python native extension.
(self, ext_fullpath, ext_dir, build_dir)
| 421 | artifact.unlink() |
| 422 | |
| 423 | def _build_extension_impl(self, ext_fullpath, ext_dir, build_dir): |
| 424 | """Invoke CMake to build the Python native extension.""" |
| 425 | ext_basename = ext_fullpath.stem.split(".")[0] |
| 426 | built_filename = Path(self.get_ext_filename(self.extensions[0].name)).name |
| 427 | py_ext_suffix = built_filename.removeprefix(ext_basename) |
| 428 | if not py_ext_suffix: |
| 429 | py_ext_suffix = sysconfig.get_config_var("EXT_SUFFIX") or ext_fullpath.suffix |
| 430 | |
| 431 | cmake_args = [ |
| 432 | f"-S{Path(ENGINE_SOURCE_DIR).resolve()}", |
| 433 | f"-B{build_dir}", |
| 434 | "-DCMAKE_BUILD_TYPE=Release", |
| 435 | f"-DOV_PY_OUTPUT_DIR={ext_dir}", |
| 436 | f"-DOV_PY_EXT_SUFFIX={py_ext_suffix}", |
| 437 | f"-DOV_X86_BUILD_VARIANTS={';'.join(ENGINE_BUILD_CONFIG.cmake_variants)}", |
| 438 | "-DCMAKE_VERBOSE_MAKEFILE=ON", |
| 439 | "-DCMAKE_INSTALL_RPATH=$ORIGIN", |
| 440 | f"-DPython3_EXECUTABLE={sys.executable}", |
| 441 | f"-DPython3_INCLUDE_DIRS={sysconfig.get_path('include')}", |
| 442 | f"-DPython3_LIBRARIES={sysconfig.get_config_vars().get('LIBRARY')}", |
| 443 | f"-DCMAKE_C_COMPILER={C_COMPILER_PATH}", |
| 444 | f"-DCMAKE_CXX_COMPILER={CXX_COMPILER_PATH}", |
| 445 | ] |
| 446 | |
| 447 | if sys.platform == "darwin": |
| 448 | cmake_args.append("-DCMAKE_OSX_DEPLOYMENT_TARGET=10.15") |
| 449 | target_arch = os.environ.get("CMAKE_OSX_ARCHITECTURES") |
| 450 | if target_arch: |
| 451 | cmake_args.append(f"-DCMAKE_OSX_ARCHITECTURES={target_arch}") |
| 452 | elif sys.platform == "win32": |
| 453 | windows_python_sabi_library = _get_windows_python_sabi_library() |
| 454 | cmake_args.append(f"-DOV_PYTHON_SABI_LIBRARY={windows_python_sabi_library}") |
| 455 | cmake_args.extend(["-G", "MinGW Makefiles"]) |
| 456 | |
| 457 | self.spawn([self.cmake_executable] + cmake_args) |
| 458 | |
| 459 | build_args = ["--build", str(build_dir), "--config", "Release", f"-j{os.cpu_count() or 4}"] |
| 460 | self.spawn([self.cmake_executable] + build_args) |
| 461 | |
| 462 | |
| 463 | def _build_web_studio(): |
no test coverage detected