summaryrefslogtreecommitdiff
path: root/numpy/distutils/fcompiler/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/distutils/fcompiler/__init__.py')
-rw-r--r--numpy/distutils/fcompiler/__init__.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/numpy/distutils/fcompiler/__init__.py b/numpy/distutils/fcompiler/__init__.py
index ecba3e5d5..5160e2abf 100644
--- a/numpy/distutils/fcompiler/__init__.py
+++ b/numpy/distutils/fcompiler/__init__.py
@@ -19,6 +19,7 @@ __all__ = ['FCompiler', 'new_fcompiler', 'show_fcompilers',
import os
import sys
import re
+from pathlib import Path
from distutils.sysconfig import get_python_lib
from distutils.fancy_getopt import FancyGetopt
@@ -37,6 +38,10 @@ from .environment import EnvironmentConfig
__metaclass__ = type
+
+FORTRAN_COMMON_FIXED_EXTENSIONS = ['.for', '.ftn', '.f77', '.f']
+
+
class CompilerNotFound(Exception):
pass
@@ -571,7 +576,8 @@ class FCompiler(CCompiler):
def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
"""Compile 'src' to product 'obj'."""
src_flags = {}
- if is_f_file(src) and not has_f90_header(src):
+ if Path(src).suffix.lower() in FORTRAN_COMMON_FIXED_EXTENSIONS \
+ and not has_f90_header(src):
flavor = ':f77'
compiler = self.compiler_f77
src_flags = get_f77flags(src)
@@ -970,7 +976,6 @@ def dummy_fortran_file():
return name[:-2]
-is_f_file = re.compile(r'.*\.(for|ftn|f77|f)\Z', re.I).match
_has_f_header = re.compile(r'-\*-\s*fortran\s*-\*-', re.I).search
_has_f90_header = re.compile(r'-\*-\s*f90\s*-\*-', re.I).search
_has_fix_header = re.compile(r'-\*-\s*fix\s*-\*-', re.I).search