Re: [f2py] Override f2py compiler settings

Sturla Molden <[email protected]> Fri, 28 Mar 2014 14:46:33 +0000 (UTC)
Newsgroups gmane.comp.python.f2py.user
Message-ID <[email protected]>
Justin M Wozniak <wozniak-zhzY/AYb9nBYTrM/[email protected]> wrote:
> Hi
>      I am trying to run f2py on the Blue Gene/Q.  I am running it as:
> 
> f2py -c -m lib_discus  --compiler=gnu --fcompiler=gnu ...
> 
> I get:
> 
> build_src: building npy-pkg config files
> running build_ext
> error: don't know how to compile C/C++ code on platform 'posix' with 
> 'gnu' compiler
> 
>      Is there some way to override the detected platform (to linux?), or 
> to completely override the compiler settings?
>      Thanks

--fcompiler=gnu is the g77 compiler (only Fortran 77)
--fcompiler=gnu95 is the gfortran compiler (any Fortran version)

The C compiler should default to system CC on Unix-like systems. It is
called UnixCCompiler in distutils. You can override it like this:

$ export CC=gcc 
$ export CXX=g++

There is no "gnu" C compiler in distutils.

Normally you should use the same C compiler as was used to build Python,
which is nearly always the system cc. Trying to control which C compiler to
use is usually inherently bad on Linux. The only exception is if you have
built your whole Python and NumPy stack with a different compiler than the
vendor supplied (e.g. Intel icc instead of GNU gcc). 

On Windows, however, controlling the C compiler is very important. Here the
GNU compilers are called "mingw" or "cygwin".  The option --compiler to
f2py and distutils is mostly useful on Windows.

Sturla