0

does anyone know if there is a way to print the compiler (and its version) that is used when I use the Fortran magic and Cython magic in IPython

For example, like the compiler that was used to build Python: platform.python_compiler()

1 Answers1

0

There are probably better ways to do this, but here are two quick ones.

For Cython, the first thing that came to mind was to make a Cython file that passes the Cython compiler and causes an error at the C level. Here's a simple one.

cdef extern from "nosuchheader.h":
    void myfakefunction(int a, double b)

On my computer IPython shows an error from distutils saying that "gcc failed with exit status 1".

I don't currently use the %%fortran magic, but you should be able to see what f2py is doing based on its output. f2py usually shows which compiler it is using, both when it searches for a compiler, and when it actually calls the Fortran compiler. To figure that out, I'd recommend compiling some snippet of Fortran code via f2py and looking at the output. On my windows machine it shows the output as f2py searches for a Fortran compiler, and prints the lines

'Found executable C:\\mingw64\\bin\\gfortran.exe',
'Found executable C:\\mingw64\\bin\\gfortran.exe',

This tells me it is using gfortran.

Further down in the output it also shows the commands used to build the Fortran source code.

The documentation for the fortran magic mentions how to get verbose output. If you pass the flag -vvv to the fortran magic, it will print the output from f2py.

You could also try looking at the %fortran_config magic mentioned in the documentation.

IanH
  • 10,250
  • 1
  • 28
  • 32