summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorcookedm <cookedm@localhost>2007-07-06 15:05:09 +0000
committercookedm <cookedm@localhost>2007-07-06 15:05:09 +0000
commit3bbfa8af671843476dacf27f5f42006d9fd462fa (patch)
tree3b64fef993dbb0664b859e911ae2495c9029921b /numpy
parent2b7dcc22d4385e15ccb651c06fa62eece0bb45e0 (diff)
downloadnumpy-3bbfa8af671843476dacf27f5f42006d9fd462fa.tar.gz
Add support for aliases for Fortran compilers.
- 'g77' for gnu, 'gfortran' for gnu95, 'ifort' for intel
Diffstat (limited to 'numpy')
-rw-r--r--numpy/distutils/fcompiler/__init__.py32
-rw-r--r--numpy/distutils/fcompiler/gnu.py2
-rw-r--r--numpy/distutils/fcompiler/intel.py3
3 files changed, 26 insertions, 11 deletions
diff --git a/numpy/distutils/fcompiler/__init__.py b/numpy/distutils/fcompiler/__init__.py
index 89b45ca49..bbfcc5076 100644
--- a/numpy/distutils/fcompiler/__init__.py
+++ b/numpy/distutils/fcompiler/__init__.py
@@ -149,6 +149,11 @@ class FCompiler(CCompiler):
}
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 @@ class FCompiler(CCompiler):
'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 @@ class FCompiler(CCompiler):
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 @@ _default_compilers = (
)
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 @@ def load_all_fcompiler_classes():
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 @@ def new_fcompiler(plat=None,
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
diff --git a/numpy/distutils/fcompiler/gnu.py b/numpy/distutils/fcompiler/gnu.py
index de1965d3c..cc6e90f0c 100644
--- a/numpy/distutils/fcompiler/gnu.py
+++ b/numpy/distutils/fcompiler/gnu.py
@@ -12,6 +12,7 @@ compilers = ['GnuFCompiler', 'Gnu95FCompiler']
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 GnuFCompiler(FCompiler):
class Gnu95FCompiler(GnuFCompiler):
compiler_type = 'gnu95'
+ compiler_aliases = ('gfortran',)
description = 'GNU Fortran 95 compiler'
def version_match(self, version_string):
diff --git a/numpy/distutils/fcompiler/intel.py b/numpy/distutils/fcompiler/intel.py
index f03a8b014..d64c6b5ae 100644
--- a/numpy/distutils/fcompiler/intel.py
+++ b/numpy/distutils/fcompiler/intel.py
@@ -24,6 +24,7 @@ class BaseIntelFCompiler(FCompiler):
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 IntelFCompiler(BaseIntelFCompiler):
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 IntelItaniumFCompiler(IntelFCompiler):
class IntelEM64TFCompiler(IntelFCompiler):
compiler_type = 'intelem'
+ compiler_aliases = ()
description = 'Intel Fortran Compiler for EM64T-based apps'
version_match = intel_version_match('EM64T-based')