Skip to content

Commit febdb6c

Browse files
committed
Xu fix torch version missing (#1210)
* fix missing torch version info issue. * enhance import torch logical. * short ipex git commit id.
1 parent 99b5907 commit febdb6c

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

setup.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -278,13 +278,16 @@ def _check_env_flag(name, default=''):
278278

279279

280280
def get_git_head_sha(base_dir):
281-
ipex_git_sha = subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=base_dir).decode('ascii').strip()
282-
if os.path.isdir(os.path.join(base_dir, '..', '.git')):
283-
torch_git_sha = subprocess.check_output(
284-
['git', 'rev-parse', 'HEAD'],
285-
cwd=os.path.join(base_dir, '..')).decode('ascii').strip()
286-
else:
287-
torch_git_sha = ''
281+
ipex_git_sha = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD'], cwd=base_dir).decode('ascii').strip()
282+
283+
try:
284+
import torch
285+
except ImportError as e:
286+
print("Unable to import torch from the local environment.")
287+
raise e
288+
289+
torch_git_sha = torch.__version__
290+
288291
return ipex_git_sha, torch_git_sha
289292

290293

@@ -467,7 +470,12 @@ def get_cpp_test_build_dir():
467470
return os.path.join(get_build_type_dir(), 'tests', 'cpu', 'cpp')
468471

469472
def get_pybind11_abi_compiler_flags():
470-
import torch
473+
try:
474+
import torch
475+
except ImportError as e:
476+
print("Unable to import torch from the local environment.")
477+
raise e
478+
471479
pybind11_abi_flags = []
472480

473481
for pname in ["COMPILER_TYPE", "STDLIB", "BUILD_ABI"]:

0 commit comments

Comments
 (0)