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

Method write_to_python_file

setup.py:158–169  ·  view source on GitHub ↗

Creates a file similar to PyTorch core's `torch/version.py`.

(cls, path: str)

Source from the content-addressed store, hash-verified

156
157 @classmethod
158 def write_to_python_file(cls, path: str) -> None:
159 """Creates a file similar to PyTorch core's `torch/version.py`."""
160
161 lines = [
162 "from typing import Optional",
163 '__all__ = ["__version__", "git_version"]',
164 f'__version__ = "{cls.string()}"',
165 # A string or None.
166 f"git_version: Optional[str] = {repr(cls.git_hash())}",
167 ]
168 with open(path, "w") as fp:
169 fp.write("\n".join(lines) + "\n")
170
171
172# The build type is determined by the DEBUG environment variable. If DEBUG is

Callers 1

runMethod · 0.80

Calls 3

git_hashMethod · 0.80
writeMethod · 0.80
stringMethod · 0.45

Tested by

no test coverage detected