Fortran 的扩展和带有 distutils 的库(.mod 未找到)
我开发了 Fortran 例程,并将其集成到我的 Python 代码中。因此,我将 numpy.distutils
与以下 setup.py
结合使用:
#!/usr/bin/env python
def configuration(parent_package='', top_path=None):
from numpy.distutils.misc_util import Configuration
config = Configuration('name', parent_package, top_path)
src = ['dir1/dir2/a.f90']
config.add_library('libname', sources=src,
extra_f90_compile_args=['-O3','-ffast-math','-funroll-loops'])
config.add_extension(name='wrapper_name', sources=['dir1/dir2/wrapper_name.f90'],
extra_f90_compile_args=['-O3','-ffast-math','-funroll-loops'], l
libraries=['libname'])
return config
if __name__ == "__main__":
from numpy.distutils.core import setup
setup(configuration=configuration)
此 setup.py
在我的 macOS 上运行良好,但在 Debian 上
Fortran f77 compiler: /usr/bin/gfortran -Wall -g -ffixed-form -fno-second-underscore -fPIC -O3 -funroll-loops
Fortran f90 compiler: /usr/bin/gfortran -Wall -g -fno-second-underscore -fPIC -O3 -funroll-loops
Fortran fix compiler: /usr/bin/gfortran -Wall -g -ffixed-form -fno-second-underscore -Wall -g -fno-second-underscore -fPIC -O3 -funroll-loops
compile options: '-Ibuild/src.linux-x86_64-3.7/build/src.linux-x86_64-3.7/dir1/dir2 -I/YYY/anaconda3/lib/python3.7/site-packages/numpy/core/include -Ibuild/src.linux-x86_64-3.7/numpy/distutils/include -I/YYY/anaconda3/include/python3.7m -c'
extra options: '-Jbuild/temp.linux-x86_64-3.7/dir1/dir2 -Ibuild/temp.linux-x86_64-3.7/dir1/dir2'
gfortran:f90: dir1/dir2/wrapper_name.f90
dir1/dir2/wrapper_name.f90:872:8:
use a, only : RR
1
Fatal Error: Can't open module file a.mod’ for reading at (1): Aucun fichier ou dossier de ce type
compilation terminated.
error: Command "/usr/bin/gfortran -Wall -g -fno-second-underscore -fPIC -O3 -funroll-loops -Ibuild/src.linux-x86_64-3.7/build/src.linux-x86_64-3.7/dir1/dir2 -I/YYY/anaconda3/lib/python3.7/site-packages/numpy/core/include -Ibuild/src.linux-x86_64-3.7/numpy/distutils/include -I/YYY/anaconda3/include/python3.7m -c -c dir1/dir2/wrapper_name.f90 -o build/temp.linux-x86_64-3.7/dir1/dir2/wrapper_name.o -Jbuild/temp.linux-x86_64-3.7/dir1/dir2 -Ibuild/temp.linux-x86_64-3.7/dir1/dir2" failed with exit status 1
运行不佳。 code>.mod 似乎不在正确的位置,但我不明白为什么它在 macOS 上工作而在 Debian 上不起作用。
I have developped Fortran's routines that I have integrated in my Python code. So I use numpy.distutils
with the following setup.py
:
#!/usr/bin/env python
def configuration(parent_package='', top_path=None):
from numpy.distutils.misc_util import Configuration
config = Configuration('name', parent_package, top_path)
src = ['dir1/dir2/a.f90']
config.add_library('libname', sources=src,
extra_f90_compile_args=['-O3','-ffast-math','-funroll-loops'])
config.add_extension(name='wrapper_name', sources=['dir1/dir2/wrapper_name.f90'],
extra_f90_compile_args=['-O3','-ffast-math','-funroll-loops'], l
libraries=['libname'])
return config
if __name__ == "__main__":
from numpy.distutils.core import setup
setup(configuration=configuration)
This setup.py
works well on my macOS but not on Debian
Fortran f77 compiler: /usr/bin/gfortran -Wall -g -ffixed-form -fno-second-underscore -fPIC -O3 -funroll-loops
Fortran f90 compiler: /usr/bin/gfortran -Wall -g -fno-second-underscore -fPIC -O3 -funroll-loops
Fortran fix compiler: /usr/bin/gfortran -Wall -g -ffixed-form -fno-second-underscore -Wall -g -fno-second-underscore -fPIC -O3 -funroll-loops
compile options: '-Ibuild/src.linux-x86_64-3.7/build/src.linux-x86_64-3.7/dir1/dir2 -I/YYY/anaconda3/lib/python3.7/site-packages/numpy/core/include -Ibuild/src.linux-x86_64-3.7/numpy/distutils/include -I/YYY/anaconda3/include/python3.7m -c'
extra options: '-Jbuild/temp.linux-x86_64-3.7/dir1/dir2 -Ibuild/temp.linux-x86_64-3.7/dir1/dir2'
gfortran:f90: dir1/dir2/wrapper_name.f90
dir1/dir2/wrapper_name.f90:872:8:
use a, only : RR
1
Fatal Error: Can't open module file a.mod’ for reading at (1): Aucun fichier ou dossier de ce type
compilation terminated.
error: Command "/usr/bin/gfortran -Wall -g -fno-second-underscore -fPIC -O3 -funroll-loops -Ibuild/src.linux-x86_64-3.7/build/src.linux-x86_64-3.7/dir1/dir2 -I/YYY/anaconda3/lib/python3.7/site-packages/numpy/core/include -Ibuild/src.linux-x86_64-3.7/numpy/distutils/include -I/YYY/anaconda3/include/python3.7m -c -c dir1/dir2/wrapper_name.f90 -o build/temp.linux-x86_64-3.7/dir1/dir2/wrapper_name.o -Jbuild/temp.linux-x86_64-3.7/dir1/dir2 -Ibuild/temp.linux-x86_64-3.7/dir1/dir2" failed with exit status 1
The missing .mod
seems to not be at the right place but I don't understand why it is working on macOS and not working in Debian.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论