@@ -278,13 +278,16 @@ def _check_env_flag(name, default=''):
278278
279279
280280def 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
469472def 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