MCPcopy Create free account
hub / github.com/pytorch/executorch / build_extension

Method build_extension

setup.py:518–538  ·  view source on GitHub ↗
(self, ext: _BaseExtension)

Source from the content-addressed store, hash-verified

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
541class CustomBuildPy(build_py):

Callers

nothing calls this directly

Calls 3

src_pathMethod · 0.45
dst_pathMethod · 0.45

Tested by

no test coverage detected