MCPcopy Create free account
hub / github.com/numpy/numpy / GnuFCompiler

Class GnuFCompiler

numpy/distutils/fcompiler/gnu.py:26–263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24
25
26class GnuFCompiler(FCompiler):
27 compiler_type = 'gnu'
28 compiler_aliases = ('g77', )
29 description = 'GNU Fortran 77 compiler'
30
31 def gnu_version_match(self, version_string):
32 """Handle the different versions of GNU fortran compilers"""
33 # Strip warning(s) that may be emitted by gfortran
34 while version_string.startswith('gfortran: warning'):
35 version_string =\
36 version_string[version_string.find('\n') + 1:].strip()
37
38 # Gfortran versions from after 2010 will output a simple string
39 # (usually "x.y", "x.y.z" or "x.y.z-q") for ``-dumpversion``; older
40 # gfortrans may still return long version strings (``-dumpversion`` was
41 # an alias for ``--version``)
42 if len(version_string) <= 20:
43 # Try to find a valid version string
44 m = re.search(r'([0-9.]+)', version_string)
45 if m:
46 # g77 provides a longer version string that starts with GNU
47 # Fortran
48 if version_string.startswith('GNU Fortran'):
49 return ('g77', m.group(1))
50
51 # gfortran only outputs a version string such as #.#.#, so check
52 # if the match is at the start of the string
53 elif m.start() == 0:
54 return ('gfortran', m.group(1))
55 else:
56 # Output probably from --version, try harder:
57 m = re.search(r'GNU Fortran\s+95.*?([0-9-.]+)', version_string)
58 if m:
59 return ('gfortran', m.group(1))
60 m = re.search(
61 r'GNU Fortran.*?\-?([0-9-.]+\.[0-9-.]+)', version_string)
62 if m:
63 v = m.group(1)
64 if v.startswith('0') or v.startswith('2') or v.startswith('3'):
65 # the '0' is for early g77's
66 return ('g77', v)
67 else:
68 # at some point in the 4.x series, the ' 95' was dropped
69 # from the version string
70 return ('gfortran', v)
71
72 # If still nothing, raise an error to make the problem easy to find.
73 err = 'A valid Fortran version was not found in this string:\n'
74 raise ValueError(err + version_string)
75
76 def version_match(self, version_string):
77 v = self.gnu_version_match(version_string)
78 if not v or v[0] != 'g77':
79 return None
80 return v[1]
81
82 possible_executables = ['g77', 'f77']
83 executables = {

Callers 1

get_flags_archMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected