1import os 2from numpy.distutils.ccompiler import simple_version_match 3from numpy.distutils.fcompiler import FCompiler 4 5compilers = ['F2CCompiler'] 6 7class F2CCompiler(FCompiler): 8 9 compiler_type = 'f2c' 10 description = 'f2c (Fortran to C Translator)' 11 # ex: 12 # f2c (Fortran to C Translator) version 20100827. 13 version_match = simple_version_match( 14 start=r'.* f2c \(Fortran to C Translator\) version ', pat=r'\d+') 15 16 archflags = [] 17 if 'ARCHFLAGS' in os.environ: 18 archflags = os.environ['ARCHFLAGS'].split() 19 executables = { 20 'version_cmd' : ["<F77>", "-v"], 21 'compiler_f77' : ["f77"], 22 'linker_so' : ["cc", "-bundle", "-undefined dynamic_lookup"] + archflags, 23 'archiver' : ["ar", "-cr"], 24 'ranlib' : ["ranlib"] 25 } 26 module_include_switch = '-I' 27 libraries = ['f2c'] 28 29 def get_flags_opt(self): 30 return ['-g','-Os'] 31 def get_flags_debug(self): 32 return ['-g'] 33 34if __name__ == '__main__': 35 from distutils import log 36 log.set_verbosity(2) 37 from numpy.distutils.fcompiler import new_fcompiler 38 compiler = new_fcompiler(compiler='f2c') 39 compiler.customize() 40 print(compiler.get_version()) 41