【问题标题】:How do I get setup.py test to use a specific fortran compiler?如何让 setup.py test 使用特定的 fortran 编译器?
【发布时间】:2011-06-29 16:09:11
【问题描述】:

我正在尝试测试包含一些 f90 文件的package。如果我构建或安装并指定 fortran 编译器,它工作正常。但是,当我尝试测试时,出现以下错误:

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

有没有办法解决这个问题?我在 Windows 7、python 2.6、numpy 1.4.1 上。

【问题讨论】:

  • 您使用的是 gfortran 还是 g95?还有,F90编译器安装在哪里?
  • 我正在使用 gfortran,虽然我可以安装 g95。 gfortran 安装在 C:\MinGW\bin
  • 我建议坚持使用 gfortran。我只是想确保你真的在使用 gfortran;人们经常混淆 g95 和 gfortran。

标签: python fortran setuptools distutils


【解决方案1】:

我认为问题在于“测试”命令需要就地构建。

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

产生了和以前一样的错误,但是

python setup.py config --fcompiler=gfortran build_ext

不是。

我能够解决这个问题

  1. 以交互方式运行设置 模式(python setup.py)

  2. 将 fortran 编译器设置为 gfortran

  3. 选择就地构建 (3)

【讨论】:

    【解决方案2】:

    该软件包的documentation 建议按如下方式构建:

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

    这应该适用于 mingw32 版本的 gfortran。我没有可访问的 Windows 机器,但是当我使用 gfortran 构建其他 Python 模块(例如 numpy)时,命令类似于:

    python setup.py build --fcompiler=gnu95
    

    ETA:我误读了您问题的开头,现在我看到您可以构建但不能测试。你试过只用“--compiler=mingw32”吗?

    【讨论】:

    • 不幸的是没有工作。有趣的是, python setup.py config --fcompiler=gfortran build_ext --inplace 不起作用,但是 python setup.py config --fcompiler=gfortran build_ext 起作用,我认为这可能是问题的根源,因为我认为'test ' 必须就地构建。
    • python setup.py build --fcompiler=gnu95 非常适合在 ubuntu 11.10 中安装 scipy。我整天都在搜索,这就是我的解决方案。
    猜你喜欢
    • 2016-03-19
    • 2010-11-19
    • 1970-01-01
    • 1970-01-01
    • 2014-10-25
    • 2016-04-26
    • 2016-04-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多