@@ -46,6 +46,11 @@ class editable_wheel:
46
46
from python .build_helpers import get_base_dir , get_cmake_dir
47
47
48
48
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
+
49
54
@dataclass
50
55
class Backend :
51
56
name : str
@@ -67,13 +72,14 @@ def prepare(backend_name: str, backend_src_dir: str = None, is_external: bool =
67
72
assert backend_name in os .listdir (
68
73
root_dir ), f"{ backend_name } is requested for install but not present in { root_dir } "
69
74
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
77
83
78
84
backend_src_dir = os .path .join (root_dir , backend_name )
79
85
@@ -756,7 +762,7 @@ def get_git_branch():
756
762
757
763
758
764
def get_git_version_suffix ():
759
- if not ( Path ( __file__ ). parent / ".git" ). is_dir ():
765
+ if not is_git_repo ():
760
766
return "" # Not a git checkout
761
767
branch = get_git_branch ()
762
768
if branch .startswith ("release" ):
0 commit comments