Initializes a BuiltExtension. Args: src_dir: The directory of the file to install, relative to the cmake-out directory. A placeholder %BUILD_TYPE% will be replaced with the build type for multi-config generators (like Visual Studio) where the buil
(
self,
src: str,
modpath: str,
dependent_cmake_flags: List[str],
src_dir: Optional[str] = None,
)
| 378 | """An extension that installs a python extension that was built by cmake.""" |
| 379 | |
| 380 | def __init__( |
| 381 | self, |
| 382 | src: str, |
| 383 | modpath: str, |
| 384 | dependent_cmake_flags: List[str], |
| 385 | src_dir: Optional[str] = None, |
| 386 | ): |
| 387 | """Initializes a BuiltExtension. |
| 388 | |
| 389 | Args: |
| 390 | src_dir: The directory of the file to install, relative to the cmake-out |
| 391 | directory. A placeholder %BUILD_TYPE% will be replaced with the build |
| 392 | type for multi-config generators (like Visual Studio) where the build |
| 393 | output is in a subdirectory named after the build type. For single- |
| 394 | config generators (like Makefile Generators or Ninja), this placeholder |
| 395 | will be removed. |
| 396 | src_name: The name of the file to install. If the path ends in `.so`, |
| 397 | modpath: The dotted path of the python module that maps to the |
| 398 | extension. |
| 399 | """ |
| 400 | assert ( |
| 401 | "/" not in modpath |
| 402 | ), f"modpath must be a dotted python module path: saw '{modpath}'" |
| 403 | full_src = src |
| 404 | if src_dir is None and _is_windows(): |
| 405 | src_dir = "%BUILD_TYPE%/" |
| 406 | if src_dir is not None: |
| 407 | full_src = os.path.join(src_dir, src) |
| 408 | self.dependent_cmake_flags = dependent_cmake_flags |
| 409 | # This is a real extension, so use the modpath as the name. |
| 410 | super().__init__( |
| 411 | src=f"%CMAKE_CACHE_DIR%/{full_src}", |
| 412 | dst=modpath, |
| 413 | name=modpath, |
| 414 | dependent_cmake_flags=self.dependent_cmake_flags, |
| 415 | ) |
| 416 | |
| 417 | def src_path(self, installer: "InstallerBuildExt") -> Path: |
| 418 | """Returns the path to the source file, resolving globs. |
nothing calls this directly
no test coverage detected