|
192 | 192 | import distutils.command.clean
|
193 | 193 | import distutils.sysconfig
|
194 | 194 | import filecmp
|
195 |
| -import subprocess |
196 | 195 | import shutil
|
197 | 196 | import os
|
198 | 197 | import json
|
|
203 | 202 | from tools.setup_helpers.env import (IS_WINDOWS, IS_DARWIN, IS_LINUX,
|
204 | 203 | check_env_flag, build_type)
|
205 | 204 | from tools.setup_helpers.cmake import CMake
|
| 205 | +from tools.generate_torch_version import get_torch_version |
206 | 206 |
|
207 | 207 | ################################################################################
|
208 | 208 | # Parameters parsed from environment
|
@@ -276,22 +276,7 @@ def report(*args):
|
276 | 276 | # Version, create_version_file, and package_name
|
277 | 277 | ################################################################################
|
278 | 278 | package_name = os.getenv('TORCH_PACKAGE_NAME', 'torch')
|
279 |
| -version = open('version.txt', 'r').read().strip() |
280 |
| -sha = 'Unknown' |
281 |
| - |
282 |
| -try: |
283 |
| - sha = subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=cwd).decode('ascii').strip() |
284 |
| -except Exception: |
285 |
| - pass |
286 |
| - |
287 |
| -if os.getenv('PYTORCH_BUILD_VERSION'): |
288 |
| - assert os.getenv('PYTORCH_BUILD_NUMBER') is not None |
289 |
| - build_number = int(os.getenv('PYTORCH_BUILD_NUMBER')) |
290 |
| - version = os.getenv('PYTORCH_BUILD_VERSION') |
291 |
| - if build_number > 1: |
292 |
| - version += '.post' + str(build_number) |
293 |
| -elif sha != 'Unknown': |
294 |
| - version += '+' + sha[:7] |
| 279 | +version = get_torch_version() |
295 | 280 | report("Building wheel {}-{}".format(package_name, version))
|
296 | 281 |
|
297 | 282 | cmake = CMake()
|
@@ -330,18 +315,6 @@ def check_file(f):
|
330 | 315 | cmake_only=CMAKE_ONLY,
|
331 | 316 | cmake=cmake)
|
332 | 317 |
|
333 |
| - version_path = os.path.join(cwd, 'torch', 'version.py') |
334 |
| - with open(version_path, 'w') as f: |
335 |
| - f.write("__version__ = '{}'\n".format(version)) |
336 |
| - # NB: This is not 100% accurate, because you could have built the |
337 |
| - # library code with DEBUG, but csrc without DEBUG (in which case |
338 |
| - # this would claim to be a release build when it's not.) |
339 |
| - f.write("debug = {}\n".format(repr(build_type.is_debug()))) |
340 |
| - cmake_cache_vars = defaultdict(lambda: None, cmake.get_cmake_cache_variables()) |
341 |
| - f.write("cuda = {}\n".format(repr(cmake_cache_vars['CUDA_VERSION']))) |
342 |
| - f.write("git_version = {}\n".format(repr(sha))) |
343 |
| - f.write("hip = {}\n".format(repr(cmake_cache_vars['HIP_VERSION']))) |
344 |
| - |
345 | 318 | if CMAKE_ONLY:
|
346 | 319 | report('Finished running cmake. Run "ccmake build" or '
|
347 | 320 | '"cmake-gui build" to adjust build options and '
|
|
0 commit comments