diff options
author | Pearu Peterson <pearu.peterson@gmail.com> | 2011-08-16 23:33:32 +0300 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2011-08-20 17:19:08 -0600 |
commit | a90754d673aa4af4d605a657134d76422c390510 (patch) | |
tree | a7f226d4281c7b5501970e413ca14c47975a08e9 /numpy/distutils/fcompiler | |
parent | ea529d4081a38acf85a759dda25e3edf0bd307dc (diff) | |
download | numpy-a90754d673aa4af4d605a657134d76422c390510.tar.gz |
ENH: Introduce new options extra_f77_compile_args and extra_f90_compile_args to
Configuration.add_extension. Configuration.add_library, and Extension. These options
allow specifying extra compile options for compiling Fortran sources within a
setup.py file.
Diffstat (limited to 'numpy/distutils/fcompiler')
-rw-r--r-- | numpy/distutils/fcompiler/__init__.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/numpy/distutils/fcompiler/__init__.py b/numpy/distutils/fcompiler/__init__.py index 69d9d68d3..550ae208a 100644 --- a/numpy/distutils/fcompiler/__init__.py +++ b/numpy/distutils/fcompiler/__init__.py @@ -213,6 +213,10 @@ class FCompiler(CCompiler): # command/{build_ext.py, build_clib.py, config.py} files. c_compiler = None + # extra_{f77,f90}_compile_args are set by build_ext.build_extension method + extra_f77_compile_args = [] + extra_f90_compile_args = [] + def __init__(self, *args, **kw): CCompiler.__init__(self, *args, **kw) self.distutils_vars = self.distutils_vars.clone(self._environment_hook) @@ -560,18 +564,21 @@ class FCompiler(CCompiler): flavor = ':f77' compiler = self.compiler_f77 src_flags = get_f77flags(src) + extra_compile_args = self.extra_f77_compile_args or [] elif is_free_format(src): flavor = ':f90' compiler = self.compiler_f90 if compiler is None: raise DistutilsExecError('f90 not supported by %s needed for %s'\ % (self.__class__.__name__,src)) + extra_compile_args = self.extra_f90_compile_args or [] else: flavor = ':fix' compiler = self.compiler_fix if compiler is None: raise DistutilsExecError('f90 (fixed) not supported by %s needed for %s'\ % (self.__class__.__name__,src)) + extra_compile_args = self.extra_f90_compile_args or [] if self.object_switch[-1]==' ': o_args = [self.object_switch.strip(),obj] else: @@ -580,13 +587,17 @@ class FCompiler(CCompiler): assert self.compile_switch.strip() s_args = [self.compile_switch, src] + if extra_compile_args: + log.info('extra %s options: %r' \ + % (flavor[1:], ' '.join(extra_compile_args))) + extra_flags = src_flags.get(self.compiler_type,[]) if extra_flags: log.info('using compile options from source: %r' \ % ' '.join(extra_flags)) command = compiler + cc_args + extra_flags + s_args + o_args \ - + extra_postargs + + extra_postargs + extra_compile_args display = '%s: %s' % (os.path.basename(compiler[0]) + flavor, src) @@ -961,5 +972,7 @@ def get_f77flags(src): f.close() return flags +# TODO: implement get_f90flags and use it in _compile similarly to get_f77flags + if __name__ == '__main__': show_fcompilers() |