Fix local version generation (#52898)

Summary:
Add "git" prefix to PyTorch local version, otherwise it might strip leading zeroes from git hashum according to https://www.python.org/dev/peps/pep-0440/#local-version-identifiers:
> If a segment consists entirely of ASCII digits then that section should be considered an integer for comparison purposes

Fixes https://github.com/pytorch/pytorch/issues/52857

Pull Request resolved: https://github.com/pytorch/pytorch/pull/52898

Reviewed By: anjali411

Differential Revision: D26681878

Pulled By: malfet

fbshipit-source-id: 0e7baa2716fc06193cfacd7c4e6cdc6f4bbac4a9
This commit is contained in:
Nikita Shulga
2021-02-26 10:55:01 -08:00
committed by Facebook GitHub Bot
parent 155b19ef1a
commit 44b9fcfb55

View File

@ -24,7 +24,7 @@ def get_torch_version(sha: Optional[str] = None) -> str:
elif sha != 'Unknown':
if sha is None:
sha = get_sha(pytorch_root)
version += '+' + sha[:7]
version += '+git' + sha[:7]
return version
if __name__ == "__main__":