#NEWLINE# def detect_swift_compiler( self ) : #NEWLINE# #INDENT# exelist = [ 'swiftc' ] #NEWLINE# try : #NEWLINE# #INDENT# p = subprocess . Popen ( ( exelist + [ '-v' ] ) , stdout = subprocess . PIPE , stderr = subprocess . PIPE ) #NEWLINE# #UNINDENT# except OSError : #NEWLINE# #INDENT# raise EnvironmentException ( ( 'Could not execute Swift compiler "%s"' % ' ' . join ( exelist ) ) ) #NEWLINE# #UNINDENT# ( _ , err ) = p . communicate ( ) #NEWLINE# err = err . decode ( errors = 'ignore' ) #NEWLINE# vmatch = re . search ( Environment . version_regex , err ) #NEWLINE# if vmatch : #NEWLINE# #INDENT# version = vmatch . group ( 0 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# version = 'unknown version' #NEWLINE# #UNINDENT# if ( 'Swift' in err ) : #NEWLINE# #INDENT# return SwiftCompiler ( exelist , version ) #NEWLINE# #UNINDENT# raise EnvironmentException ( ( ( 'Unknown compiler "' + ' ' . join ( exelist ) ) + '"' ) )