summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2014-12-01 14:28:53 -0500
committerCharles Harris <charlesr.harris@gmail.com>2014-12-01 14:28:53 -0500
commite31dcad0aca659acd89ca90ae5030731d0eccf91 (patch)
tree8691f5f3a69fc4895485fcee37546081df9937cd /numpy
parent8a2dd0680e8470aab7ad63622c0d0af703f58d42 (diff)
parentc4c2f21a784d94f2708163243dbfea846d527f77 (diff)
downloadnumpy-e31dcad0aca659acd89ca90ae5030731d0eccf91.tar.gz
Merge pull request #5333 from rnelsonchem/comp_exe
BLD: Change Fortran version flag and string check
Diffstat (limited to 'numpy')
-rw-r--r--numpy/distutils/fcompiler/gnu.py35
-rw-r--r--numpy/distutils/tests/test_fcompiler_gnu.py8
2 files changed, 20 insertions, 23 deletions
diff --git a/numpy/distutils/fcompiler/gnu.py b/numpy/distutils/fcompiler/gnu.py
index 368506470..1f9f3404c 100644
--- a/numpy/distutils/fcompiler/gnu.py
+++ b/numpy/distutils/fcompiler/gnu.py
@@ -35,22 +35,23 @@ class GnuFCompiler(FCompiler):
def gnu_version_match(self, version_string):
"""Handle the different versions of GNU fortran compilers"""
- m = re.search(r'GNU Fortran', version_string)
- if not m:
- return None
- m = re.search(r'GNU Fortran\s+95.*?([0-9-.]+)', version_string)
- if m:
- return ('gfortran', m.group(1))
- m = re.search(r'GNU Fortran.*?\-?([0-9-.]+)', version_string)
+ # Try to find a valid version string
+ m = re.search(r'([0-9.]+)', version_string)
if m:
- v = m.group(1)
- if v.startswith('0') or v.startswith('2') or v.startswith('3'):
- # the '0' is for early g77's
- return ('g77', v)
- else:
- # at some point in the 4.x series, the ' 95' was dropped
- # from the version string
- return ('gfortran', v)
+ # g77 provides a longer version string that starts with GNU
+ # Fortran
+ if version_string.startswith('GNU Fortran'):
+ return ('g77', m.group(1))
+
+ # gfortran only outputs a version string such as #.#.#, so check
+ # if the match is at the start of the string
+ elif m.start() == 0:
+ return ('gfortran', m.group(1))
+
+ # If these checks fail, then raise an error to make the problem easy
+ # to find.
+ err = 'A valid Fortran verison was not found in this string:\n'
+ raise ValueError(err + version_string)
def version_match(self, version_string):
v = self.gnu_version_match(version_string)
@@ -68,7 +69,7 @@ class GnuFCompiler(FCompiler):
possible_executables = ['g77', 'f77']
executables = {
- 'version_cmd' : [None, "--version"],
+ 'version_cmd' : [None, "-dumpversion"],
'compiler_f77' : [None, "-g", "-Wall", "-fno-second-underscore"],
'compiler_f90' : None, # Use --fcompiler=gnu95 for f90 codes
'compiler_fix' : None,
@@ -254,7 +255,7 @@ class Gnu95FCompiler(GnuFCompiler):
possible_executables = ['gfortran', 'f95']
executables = {
- 'version_cmd' : ["<F90>", "--version"],
+ 'version_cmd' : ["<F90>", "-dumpversion"],
'compiler_f77' : [None, "-Wall", "-g", "-ffixed-form",
"-fno-second-underscore"] + _EXTRAFLAGS,
'compiler_f90' : [None, "-Wall", "-g",
diff --git a/numpy/distutils/tests/test_fcompiler_gnu.py b/numpy/distutils/tests/test_fcompiler_gnu.py
index a0d191819..ecbd85e76 100644
--- a/numpy/distutils/tests/test_fcompiler_gnu.py
+++ b/numpy/distutils/tests/test_fcompiler_gnu.py
@@ -14,12 +14,8 @@ g77_version_strings = [
]
gfortran_version_strings = [
- ('GNU Fortran 95 (GCC 4.0.3 20051023 (prerelease) (Debian 4.0.2-3))',
- '4.0.3'),
- ('GNU Fortran 95 (GCC) 4.1.0', '4.1.0'),
- ('GNU Fortran 95 (GCC) 4.2.0 20060218 (experimental)', '4.2.0'),
- ('GNU Fortran (GCC) 4.3.0 20070316 (experimental)', '4.3.0'),
- ('GNU Fortran (rubenvb-4.8.0) 4.8.0', '4.8.0'),
+ ('4.8.0', '4.8.0'),
+ ('4.0.3-7', '4.0.3'),
]
class TestG77Versions(TestCase):