Returns the path to the source file, resolving globs. Args: installer: The InstallerBuildExt instance that is installing the file.
(self, installer: "InstallerBuildExt")
| 252 | ) |
| 253 | |
| 254 | def src_path(self, installer: "InstallerBuildExt") -> Path: |
| 255 | """Returns the path to the source file, resolving globs. |
| 256 | |
| 257 | Args: |
| 258 | installer: The InstallerBuildExt instance that is installing the |
| 259 | file. |
| 260 | """ |
| 261 | build_dir = self._get_build_dir(installer) |
| 262 | |
| 263 | src_path = self.src.replace("%CMAKE_CACHE_DIR%/", "") |
| 264 | |
| 265 | cfg = get_build_type(installer.debug) |
| 266 | |
| 267 | if os.name == "nt": |
| 268 | # Replace %BUILD_TYPE% with the current build type. |
| 269 | src_path = src_path.replace("%BUILD_TYPE%", cfg) |
| 270 | else: |
| 271 | # Remove %BUILD_TYPE% from the path. |
| 272 | src_path = src_path.replace("/%BUILD_TYPE%", "") |
| 273 | |
| 274 | # Construct the full source path, resolving globs. If there are no glob |
| 275 | # pattern characters, this will just ensure that the source file exists. |
| 276 | srcs = tuple(build_dir.glob(src_path)) |
| 277 | if len(srcs) != 1: |
| 278 | raise ValueError( |
| 279 | f"Expecting exactly 1 file matching {self.src} in {build_dir}, " |
| 280 | f"found {repr(srcs)}. Resolved src pattern: {src_path}." |
| 281 | ) |
| 282 | return srcs[0] |
| 283 | |
| 284 | def inplace_dir(self, installer: "InstallerBuildExt") -> Path: |
| 285 | """Returns the path of this file to be installed to, under inplace mode. |
no test coverage detected