(self, ext: _BaseExtension)
| 516 | # TODO(dbort): Depend on the "build" command to ensure it runs first |
| 517 | |
| 518 | def build_extension(self, ext: _BaseExtension) -> None: |
| 519 | if not ext.is_cmake_artifact_used(self): |
| 520 | return |
| 521 | |
| 522 | src_file: Path = ext.src_path(self) |
| 523 | dst_file: Path = ext.dst_path(self) |
| 524 | |
| 525 | # Ensure that the destination directory exists. |
| 526 | if not dst_file.parent.exists(): |
| 527 | self.mkpath(os.fspath(dst_file.parent)) |
| 528 | |
| 529 | # Copy the file. |
| 530 | self.copy_file(os.fspath(src_file), os.fspath(dst_file)) |
| 531 | |
| 532 | # Ensure that the destination file is writable, even if the source was |
| 533 | # not. build_py does this by passing preserve_mode=False to copy_file, |
| 534 | # but that would clobber the X bit on any executables. TODO(dbort): This |
| 535 | # probably won't work on Windows. |
| 536 | if not os.access(src_file, os.W_OK): |
| 537 | # Make the file writable. This should respect the umask. |
| 538 | os.chmod(src_file, os.stat(src_file).st_mode | 0o222) |
| 539 | |
| 540 | |
| 541 | class CustomBuildPy(build_py): |
nothing calls this directly
no test coverage detected