[Numpy-svn] r3882 - trunk/numpy/distutils/fcompiler

numpy-svn@scip... numpy-svn@scip...
Fri Jul 6 10:05:15 CDT 2007


Author: cookedm
Date: 2007-07-06 10:05:09 -0500 (Fri, 06 Jul 2007)
New Revision: 3882

Modified:
   trunk/numpy/distutils/fcompiler/__init__.py
   trunk/numpy/distutils/fcompiler/gnu.py
   trunk/numpy/distutils/fcompiler/intel.py
Log:
Add support for aliases for Fortran compilers.
 - 'g77' for gnu, 'gfortran' for gnu95, 'ifort' for intel


Modified: trunk/numpy/distutils/fcompiler/__init__.py
===================================================================
--- trunk/numpy/distutils/fcompiler/__init__.py	2007-07-05 07:00:57 UTC (rev 3881)
+++ trunk/numpy/distutils/fcompiler/__init__.py	2007-07-06 15:05:09 UTC (rev 3882)
@@ -149,6 +149,11 @@
                     }
     language_order = ['f90','f77']
 
+
+    # These will be set by the subclass
+
+    compiler_type = None
+    compiler_aliases = ()
     version_pattern = None
 
     possible_executables = []
@@ -163,6 +168,11 @@
         'ranlib'       : None,
         }
 
+    # If compiler does not support compiling Fortran 90 then it can
+    # suggest using another compiler. For example, gnu would suggest
+    # gnu95 compiler type when there are F90 sources.
+    suggested_f90_compiler = None
+
     compile_switch = "-c"
     object_switch = "-o "   # Ending space matters! It will be stripped
                             # but if it is missing then object_switch
@@ -188,11 +198,6 @@
     shared_lib_format = "%s%s"
     exe_extension = ""
 
-    # If compiler does not support compiling Fortran 90 then it can
-    # suggest using another compiler. For example, gnu would suggest
-    # gnu95 compiler type when there are F90 sources.
-    suggested_f90_compiler = None
-
     _exe_cache = {}
 
     _executable_keys = ['version_cmd', 'compiler_f77', 'compiler_f90',
@@ -688,17 +693,19 @@
     )
 
 fcompiler_class = None
+fcompiler_aliases = None
 
 def load_all_fcompiler_classes():
     """Cache all the FCompiler classes found in modules in the
     numpy.distutils.fcompiler package.
     """
     from glob import glob
-    global fcompiler_class
+    global fcompiler_class, fcompiler_aliases
     if fcompiler_class is not None:
         return
     pys = os.path.join(os.path.dirname(__file__), '*.py')
     fcompiler_class = {}
+    fcompiler_aliases = {}
     for fname in glob(pys):
         module_name, ext = os.path.splitext(os.path.basename(fname))
         module_name = 'numpy.distutils.fcompiler.' + module_name
@@ -707,9 +714,10 @@
         if hasattr(module, 'compilers'):
             for cname in module.compilers:
                 klass = getattr(module, cname)
-                fcompiler_class[klass.compiler_type] = (klass.compiler_type,
-                                                        klass,
-                                                        klass.description)
+                desc = (klass.compiler_type, klass, klass.description)
+                fcompiler_class[klass.compiler_type] = desc
+                for alias in klass.compiler_aliases:
+                    fcompiler_aliases[alias] = desc
 
 def _find_existing_fcompiler(compiler_types,
                              osname=None, platform=None,
@@ -785,9 +793,11 @@
         plat = os.name
     if compiler is None:
         compiler = get_default_fcompiler(plat, requiref90=requiref90)
-    try:
+    if compiler in fcompiler_class:
         module_name, klass, long_description = fcompiler_class[compiler]
-    except KeyError:
+    elif compiler in fcompiler_aliases:
+        module_name, klass, long_description = fcompiler_aliases[compiler]
+    else:
         msg = "don't know how to compile Fortran code on platform '%s'" % plat
         if compiler is not None:
             msg = msg + " with '%s' compiler." % compiler

Modified: trunk/numpy/distutils/fcompiler/gnu.py
===================================================================
--- trunk/numpy/distutils/fcompiler/gnu.py	2007-07-05 07:00:57 UTC (rev 3881)
+++ trunk/numpy/distutils/fcompiler/gnu.py	2007-07-06 15:05:09 UTC (rev 3882)
@@ -12,6 +12,7 @@
 
 class GnuFCompiler(FCompiler):
     compiler_type = 'gnu'
+    compiler_aliases = ('g77',)
     description = 'GNU Fortran 77 compiler'
 
     def gnu_version_match(self, version_string):
@@ -270,6 +271,7 @@
 
 class Gnu95FCompiler(GnuFCompiler):
     compiler_type = 'gnu95'
+    compiler_aliases = ('gfortran',)
     description = 'GNU Fortran 95 compiler'
 
     def version_match(self, version_string):

Modified: trunk/numpy/distutils/fcompiler/intel.py
===================================================================
--- trunk/numpy/distutils/fcompiler/intel.py	2007-07-05 07:00:57 UTC (rev 3881)
+++ trunk/numpy/distutils/fcompiler/intel.py	2007-07-06 15:05:09 UTC (rev 3882)
@@ -24,6 +24,7 @@
 class IntelFCompiler(BaseIntelFCompiler):
 
     compiler_type = 'intel'
+    compiler_aliases = ('ifort',)
     description = 'Intel Fortran Compiler for 32-bit apps'
     version_match = intel_version_match('32-bit|IA-32')
 
@@ -102,6 +103,7 @@
 
 class IntelItaniumFCompiler(IntelFCompiler):
     compiler_type = 'intele'
+    compiler_aliases = ()
     description = 'Intel Fortran Compiler for Itanium apps'
 
     version_match = intel_version_match('Itanium')
@@ -125,6 +127,7 @@
 
 class IntelEM64TFCompiler(IntelFCompiler):
     compiler_type = 'intelem'
+    compiler_aliases = ()
     description = 'Intel Fortran Compiler for EM64T-based apps'
 
     version_match = intel_version_match('EM64T-based')



More information about the Numpy-svn mailing list