Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get setup.py test to use a specific fortran compiler?

I am trying to test a package that includes some f90 files. If I build or install and specify the fortran compiler, it works fine. However, when I try to test I get the following error:

C:\Users\jsalvatier\workspace\scikits.bvp_solver>python setup.py config_fc --fcompiler=gfortran test
running config_fc
unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
running test
running egg_info
running build_src
build_src
building extension "scikits.bvp_solver.bvp_solverf" sources
f2py options: []
  adding 'build\src.win32-2.6\fortranobject.c' to sources.
  adding 'build\src.win32-2.6' to include_dirs.
  adding 'build\src.win32-2.6\scikits\bvp_solver\lib\bvp_solverf-f2pywrappers2.f90' to sources.
building data_files sources
build_src: building npy-pkg config files
writing scikits.bvp_solver.egg-info\PKG-INFO
writing namespace_packages to scikits.bvp_solver.egg-info\namespace_packages.txt
writing top-level names to scikits.bvp_solver.egg-info\top_level.txt
writing dependency_links to scikits.bvp_solver.egg-info\dependency_links.txt
reading manifest file 'scikits.bvp_solver.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'scikits.bvp_solver.egg-info\SOURCES.txt'
running build_ext
customize Mingw32CCompiler
customize Mingw32CCompiler using build_ext
customize GnuFCompiler
Found executable C:\mingw\bin\g77.exe
gnu: no Fortran 90 compiler found
gnu: no Fortran 90 compiler found
Found executable C:\mingw\bin\g77.exe
customize GnuFCompiler
gnu: no Fortran 90 compiler found
gnu: no Fortran 90 compiler found
customize GnuFCompiler using build_ext
building 'scikits.bvp_solver.bvp_solverf' extension
compiling C sources
C compiler: gcc -mno-cygwin -O2 -Wall -Wstrict-prototypes

compile options: '-Ibuild\src.win32-2.6 -IC:\Python26\lib\site-packages\numpy\core\include -IC:\Python26\include -IC:\Python26\PC -c'
gcc -mno-cygwin -O2 -Wall -Wstrict-prototypes -Ibuild\src.win32-2.6 -IC:\Python26\lib\site-packages\numpy\core\include -IC:\Python26\include -IC:\Python26\PC -c build\src.win32-2.6\scikits\bvp_solver\lib\bvp_solverfmodule.c -o build\temp.win32-2.6\Release\build\src.win32-2.6\scikits\bvp_solver\lib\bvp_solverfmodule.o
Found executable C:\mingw\bin\gcc.exe
gcc -mno-cygwin -O2 -Wall -Wstrict-prototypes -Ibuild\src.win32-2.6 -IC:\Python26\lib\site-packages\numpy\core\include -IC:\Python26\include -IC:\Python26\PC -c build\src.win32-2.6\fortranobject.c -o build\temp.win32-2.6\Release\build\src.win32-2.6\fortranobject.o
compiling Fortran 90 module sources
XXX: module_build_dir='build\\temp.win32-2.6\\Release\\scikits\\bvp_solver' option ignored
XXX: Fix module_dir_switch for  GnuFCompiler
XXX: module_dirs=[] option ignored
XXX: Fix module_include_switch for  GnuFCompiler
Fortran f77 compiler: C:\mingw\bin\g77.exe -g -Wall -fno-second-underscore -mno-cygwin -O3 -funroll-loops
compile options: '-Ibuild\src.win32-2.6 -IC:\Python26\lib\site-packages\numpy\core\include -IC:\Python26\include -IC:\Python26\PC -c'
error: f90 not supported by GnuFCompiler needed for scikits\bvp_solver\lib\BVP_M.f90

Is there a way to work around this? I'm on windows 7, python 2.6, numpy 1.4.1.

like image 630
John Salvatier Avatar asked Jun 29 '11 16:06

John Salvatier


People also ask

How do I get a Fortran compiler?

The gfortran compiler is part of the standard “gcc” compiler package, and may be pre-installed on recent unix systems. Check the version using “gfortran –version”. To install from the standard repository use: “sudo apt-get update; sudo apt-get install gfortran”

How do I add Gfortran to my path?

To add it go to Start>; right click Computer and select Properties; go to Advanced System Settings; select the Advanced tab; select Environment Variables (the bottom one); scroll down in the bottom menu until you find the Path variable and then add the MinGW\bin directory at the end (be careful not to delete your ...

What should be in setup py?

The setup.py file may be the most significant file that should be placed at the root of the Python project directory. It primarily serves two purposes: It includes choices and metadata about the program, such as the package name, version, author, license, minimal dependencies, entry points, data files, and so on.


2 Answers

I think the issue is that the 'test' command requires building inplace.

python setup.py config --fcompiler=gfortran build_ext --inplace

was generating the same error as before, but

python setup.py config --fcompiler=gfortran build_ext

was not.

I was able to work around the problem by

  1. Running setup in interactive mode(python setup.py)

  2. Setting the fortran compiler to gfortran

  3. selecting inplace build (3)

like image 63
John Salvatier Avatar answered Oct 13 '22 21:10

John Salvatier


The documentation for that package recommends building as follows:

python setup.py config --compiler=mingw32 build --compiler=mingw32 install

That's supposed to work with the mingw32 version of gfortran. I don't have a Windows machine accessible, but when I've built other Python modules (numpy, for example) with gfortran, the command was something like:

python setup.py build --fcompiler=gnu95

ETA: I misread the beginning of your question, and now I see that you can build but not test. Have you tried this with only "--compiler=mingw32"?

like image 29
Asher L. Avatar answered Oct 13 '22 22:10

Asher L.