@@ -258,46 +258,42 @@ def getInstallPath(prefix, type=0):
258258# Functions returning the names of the remote repo & branch and the commit hash
259259#==============================================================================
260260def getGitOrigin (cassiopeeIncDir ):
261- if not shutil .which ("git" ): return "unknown"
262- mySystem = getSystem ()[0 ]
263- if mySystem == 'mingw' or mySystem == 'Windows' :
264- lpath = cassiopeeIncDir .replace ('/' , '\\ ' )
265- cmd = "cd {} && git config --get remote.origin.url" .format (lpath )
266- else : # unix
267- lpath = cassiopeeIncDir
268- cmd = "cd {}; git config --get remote.origin.url 2>/dev/null" .format (lpath )
261+ if not shutil .which ("git" ):
262+ return "unknown"
269263 try :
270- origin = subprocess .check_output (cmd , shell = True )
271- return origin .decode ('utf-8' , 'ignore' ).strip ()
272- except : return "unknown"
264+ return subprocess .check_output (
265+ ["git" , "-C" , cassiopeeIncDir ,
266+ "config" , "--get" , "remote.origin.url" ],
267+ stderr = subprocess .DEVNULL ,
268+ text = True
269+ ).strip ()
270+ except Exception :
271+ return "unknown"
273272
274273def getGitBranch (cassiopeeIncDir ):
275- if not shutil .which ("git" ): return "unknown"
276- mySystem = getSystem ()[0 ]
277- if mySystem == 'mingw' or mySystem == 'Windows' :
278- lpath = cassiopeeIncDir .replace ('/' , '\\ ' )
279- cmd = "cd {} && git rev-parse --abbrev-ref HEAD" .format (lpath )
280- else : # unix
281- lpath = cassiopeeIncDir
282- cmd = "cd {}; git rev-parse --abbrev-ref HEAD 2>/dev/null" .format (lpath )
274+ if not shutil .which ("git" ):
275+ return "unknown"
283276 try :
284- branchName = subprocess .check_output (cmd , shell = True )
285- return branchName .decode ('utf-8' , 'ignore' ).strip ()
286- except : return "unknown"
277+ return subprocess .check_output (
278+ ["git" , "-C" , cassiopeeIncDir , "rev-parse" , "--abbrev-ref" , "HEAD" ],
279+ stderr = subprocess .DEVNULL ,
280+ text = True
281+ ).strip ()
282+ except Exception :
283+ return "unknown"
284+
287285
288286def getGitHash (cassiopeeIncDir ):
289- if not shutil .which ("git" ): return "unknown"
290- mySystem = getSystem ()[0 ]
291- if mySystem == 'mingw' or mySystem == 'Windows' :
292- lpath = cassiopeeIncDir .replace ('/' , '\\ ' )
293- cmd = "cd {} && git rev-parse --short HEAD" .format (lpath )
294- else : # unix
295- lpath = cassiopeeIncDir
296- cmd = "cd {}; git rev-parse --short HEAD 2>/dev/null" .format (lpath )
287+ if not shutil .which ("git" ):
288+ return "unknown"
297289 try :
298- sha = subprocess .check_output (cmd , shell = True )
299- return sha .decode ('utf-8' , 'ignore' ).strip ()
300- except : return "unknown"
290+ return subprocess .check_output (
291+ ["git" , "-C" , cassiopeeIncDir , "rev-parse" , "--short" , "HEAD" ],
292+ stderr = subprocess .DEVNULL ,
293+ text = True
294+ ).strip ()
295+ except Exception :
296+ return "unknown"
301297
302298#=============================================================================
303299# nom de l'egg cree par setup tools
@@ -2216,6 +2212,14 @@ def checkFortranLibs():
22162212
22172213 return (ret , libs , paths )
22182214
2215+ # Run the make command to build the wdir target
2216+ def runMakeFortran (forCompiler , opt , wdir ):
2217+ import shlex
2218+ subprocess .run (
2219+ ["make" , "-e" , f"FC={ forCompiler } " , f"WDIR={ wdir } " , * shlex .split (opt )],
2220+ check = True
2221+ )
2222+
22192223#=============================================================================
22202224# Check Cpp libs
22212225# additionalLibs: si les libs requises ont des noms non conventionnels
0 commit comments