#NEWLINE# def _os_supports_avx( ) : #NEWLINE# #INDENT# '\n    Whether the current OS supports AVX, regardless of the CPU.\n\n    This is necessary because the user may be running a very old Linux\n    kernel (e.g. CentOS 5) on a recent CPU.\n    ' #NEWLINE# if ( ( not sys . platform . startswith ( 'linux' ) ) or ( platform . machine ( ) not in ( 'i386' , 'i586' , 'i686' , 'x86_64' ) ) ) : #NEWLINE# #INDENT# return True #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# f = open ( '/proc/cpuinfo' , 'r' ) #NEWLINE# #UNINDENT# except OSError : #NEWLINE# #INDENT# return True #NEWLINE# #UNINDENT# with f : #NEWLINE# #INDENT# for line in f : #NEWLINE# #INDENT# ( head , _ , body ) = line . partition ( ':' ) #NEWLINE# if ( ( head . strip ( ) == 'flags' ) and ( 'avx' in body . split ( ) ) ) : #NEWLINE# #INDENT# return True #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# return False