[Numpy-discussion] [f2py] How to specify compile options in setup.py

Jose Gomez-Dans jgomezdans@gmail....
Tue Aug 16 11:50:25 CDT 2011


Hi,

Up to now, I have managed to build Fortran extensions with f2py by ussing
the following command:
$ python setup.py config_fc --fcompiler=gnu95
 --f77flags='-fmy_flags' --f90flags='-fmy_flags' build

I think that these options should be able to go in a setup.py file, and use
the f2py_options file. One way of doing this is to extend sys.argv with the
required command line options:
import sys
sys.argv.extend ( ['config_fc', '--fcompiler=gnu95',
 '--f77flags="-fmy_flags"', "--f90flags='-fmy_flags"] )

This works well if all the extensions require the same flags. In my case,
however, One of the extensions requires a different set of flags (in
particular, it requires that flag  -fdefault-real-8 isn't set, which is
required by the extensions). I tried setting the f2py_options in the
add_extension method call:

config.add_extension( 'my_extension', sources = my_sources,
 f2py_options=['f77flags="-ffixed-line-length-0" -fdefault-real-8',
'f90flags="-fdefault-real-8"']  )

This compiles the extensions (using the two dashes in front of the f2py
option eg --f77flags results in an unrecognised option), but the f2p_options
goes unheeded. Here's the relevant bit of the output from python setup.py
build:

compiling Fortran sources
Fortran f77 compiler: /usr/bin/gfortran -ffixed-line-length-0 -fPIC -O3
-march=native
Fortran f90 compiler: /usr/bin/gfortran -ffixed-line-length-0 -fPIC -O3
-march=native
Fortran fix compiler: /usr/bin/gfortran -Wall -ffixed-form
-fno-second-underscore -ffixed-line-length-0 -fPIC -O3 -march=native
compile options: '-Ibuild/src.linux-i686-2.7
-I/usr/lib/pymodules/python2.7/numpy/core/include -I/usr/include/python2.7
-c'
extra options: '-Jbuild/temp.linux-i686-2.7/my_dir
-Ibuild/temp.linux-i686-2.7/my_dir'

How can I disable (or enable) one option for compiling one particular
extension?

Thanks!
Jose
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20110816/8637a549/attachment-0001.html 


More information about the NumPy-Discussion mailing list