@@ -46,6 +46,11 @@ class editable_wheel:
4646from python .build_helpers import get_base_dir , get_cmake_dir
4747
4848
49+ def is_git_repo ():
50+ """Return True if this file resides in a git repository"""
51+ return (Path (__file__ ).parent / ".git" ).is_dir ()
52+
53+
4954@dataclass
5055class Backend :
5156 name : str
@@ -67,13 +72,14 @@ def prepare(backend_name: str, backend_src_dir: str = None, is_external: bool =
6772 assert backend_name in os .listdir (
6873 root_dir ), f"{ backend_name } is requested for install but not present in { root_dir } "
6974
70- try :
71- subprocess .run (["git" , "submodule" , "update" , "--init" , f"{ backend_name } " ], check = True ,
72- stdout = subprocess .DEVNULL , cwd = root_dir )
73- except subprocess .CalledProcessError :
74- pass
75- except FileNotFoundError :
76- pass
75+ if is_git_repo ():
76+ try :
77+ subprocess .run (["git" , "submodule" , "update" , "--init" , f"{ backend_name } " ], check = True ,
78+ stdout = subprocess .DEVNULL , cwd = root_dir )
79+ except subprocess .CalledProcessError :
80+ pass
81+ except FileNotFoundError :
82+ pass
7783
7884 backend_src_dir = os .path .join (root_dir , backend_name )
7985
@@ -756,7 +762,7 @@ def get_git_branch():
756762
757763
758764def get_git_version_suffix ():
759- if not ( Path ( __file__ ). parent / ".git" ). is_dir ():
765+ if not is_git_repo ():
760766 return "" # Not a git checkout
761767 branch = get_git_branch ()
762768 if branch .startswith ("release" ):
0 commit comments