[Numpy-discussion] seeking help with f2py_options

Pearu Peterson pearu@cens.ioc...
Sat Jun 21 08:04:23 CDT 2008

On Sat, June 21, 2008 3:28 pm, Helmut Rathgen wrote:
> Dear all,
> I am trying to write a setp.py based on numpy.distutils for a mixed
> python/fortran90 package.
> I'd like to specify the fortran compiler, such as the path to the
> compiler, compiler flags, etc. in setup.py.
> I seemed to understand that this should be done by passing 'f2py_options
> = [ "...", "..." ]' to numpy.distutils.core.Extension()
> However, I get errors such as
> helmut@ncv77:~/src/testdistutils$ python setup.py build
> running build
> running scons
> customize UnixCCompiler
> Found executable /usr/bin/gcc
> customize GnuFCompiler
> Could not locate executable g77
> Could not locate executable f77
> customize IntelFCompiler
> Found executable /opt/intel/fc/10.0.026/bin/ifort
> customize IntelFCompiler
> customize UnixCCompiler
> customize UnixCCompiler using scons
> running config_cc
> unifing config_cc, config, build_clib, build_ext, build commands
> --compiler options
> running config_fc
> unifing config_fc, config, build_clib, build_ext, build commands
> --fcompiler options
> running build_src
> building extension "mrcwaf" sources
> f2py options: ['--fcompiler=intel',
> '--f90exec=/opt/intel/fc/10.0.026/bin/ifort', '--opt="-O3 -xW -ipo"',
> '--noarch']
> f2py: src/mrcwaf/mrcwaf.pyf
> Unknown option '--fcompiler=intel'
> How to use f2py_options - or should flags be passed in a different way?

Note that --fcompiler= and other such options are actually options
to numpy.distutils (f2py script would just pass these options
forward to numpy.distutils). f2py_options can contain only f2py
specific options.
Hence you should try to modify sys.path
in the beggining of the setup.py file to specify the fortran
compiler options. For example, in setup.py file, insert:

import sys
sys.path.extend('config_fc --fcompiler=intel ....'.split())

  python setup.py config_fc --help
  python setup.py build_ext --help
for more information about possible options.


More information about the Numpy-discussion mailing list