diff options
author | Gao, Xiang <qasdfgtyuiop@gmail.com> | 2019-03-25 19:54:27 -0700 |
---|---|---|
committer | Facebook Github Bot <facebook-github-bot@users.noreply.github.com> | 2019-03-25 19:59:40 -0700 |
commit | a40e0a7f2d235586237122e92561eef13169bb8f (patch) | |
tree | 0abe2e976a0c648597c89ad1b0dcc10c8c190e19 /setup.py | |
parent | 674c274d92e5fde6218d39fa5d65658ad0efef05 (diff) | |
download | pytorch-a40e0a7f2d235586237122e92561eef13169bb8f.tar.gz pytorch-a40e0a7f2d235586237122e92561eef13169bb8f.tar.bz2 pytorch-a40e0a7f2d235586237122e92561eef13169bb8f.zip |
Add torch.version.git_version (#18299)
Summary:
Fixes: https://github.com/pytorch/pytorch/issues/18293
cc: colesbury
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18299
Differential Revision: D14611972
Pulled By: soumith
fbshipit-source-id: cdb48ef37c8869713a9a43ea0da08e1bed9279a2
Diffstat (limited to 'setup.py')
-rw-r--r-- | setup.py | 16 |
1 files changed, 10 insertions, 6 deletions
@@ -231,18 +231,21 @@ cmake_python_include_dir = distutils.sysconfig.get_python_inc() ################################################################################ package_name = os.getenv('TORCH_PACKAGE_NAME', 'torch') version = '1.1.0a0' +sha = 'Unknown' + +try: + sha = subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=cwd).decode('ascii').strip() +except Exception: + pass + if os.getenv('PYTORCH_BUILD_VERSION'): assert os.getenv('PYTORCH_BUILD_NUMBER') is not None build_number = int(os.getenv('PYTORCH_BUILD_NUMBER')) version = os.getenv('PYTORCH_BUILD_VERSION') if build_number > 1: version += '.post' + str(build_number) -else: - try: - sha = subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=cwd).decode('ascii').strip() - version += '+' + sha[:7] - except Exception: - pass +elif sha != 'Unknown': + version += '+' + sha[:7] report("Building wheel {}-{}".format(package_name, version)) @@ -257,6 +260,7 @@ def build_deps(): # this would claim to be a release build when it's not.) f.write("debug = {}\n".format(repr(DEBUG))) f.write("cuda = {}\n".format(repr(CUDA_VERSION))) + f.write("git_version = {}\n".format(repr(sha))) def check_file(f): if not os.path.exists(f): |