Fortran 扩展编译期间安装脚本中出现错误:"No such file or directory"



我已经设法使用f2py手动包装了一组Fortran 90源代码。为此,我生成了签名文件,如中所述:http://docs.scipy.org/doc/numpy/user/c-info.python-as-glue.html并且我可以获得一个.so,我可以从一些Python接口文件中调用它。

现在我想从中创建一个包,它将自动构建Fortran扩展。在包含Fortran源代码和签名文件的文件夹中,现在唯一添加的是一个setup.py文件,其内容如下:

from numpy.distutils.core import setup, Extension
from numpy.distutils.misc_util import Configuration
DISTNAME = 'greengard'
def configuration(parent_package='',top_path=None):
    config = Configuration(DISTNAME, parent_package, top_path)
    # the Fortran sources
    f90_sources = ['_greengard.pyf'
                   'nufft1df90.f',
                   'nufft2df90.f',
                   'nufft3df90.f',
                   'next235.f',
                   'dfftpack.f',
                   ]
    config.add_extension('_greengard', f90_sources)
return config
if __name__ == "__main__":
    setup(configuration=configuration) 

然后激活了一个virtualenv并尝试安装包

python setup.py install 

但最终会出现以下错误:

creating build/temp.linux-x86_64-2.7/build/src.linux-x86_64-2.7/greengard
compile options: '-Ibuild/src.linux-x86_64-2.7 -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/include/python2.7 -c'
gcc: build/src.linux-x86_64-2.7/greengard/_greengardmodule.c
gcc: build/src.linux-x86_64-2.7/fortranobject.c
compiling Fortran sources
Fortran f77 compiler: /usr/bin/gfortran -Wall -ffixed-form -fno-second-underscore -fPIC -O3 -funroll-loops
Fortran f90 compiler: /usr/bin/gfortran -Wall -fno-second-underscore -fPIC -O3 -funroll-loops
Fortran fix compiler: /usr/bin/gfortran -Wall -ffixed-form -fno-second-underscore -Wall -fno-second-underscore -fPIC -O3 -funroll-loops
compile options: '-Ibuild/src.linux-x86_64-2.7 -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/include/python2.7 -c'
error: _greengard.pyfnufft1df90.f: No such file or directory

启动setup.py后的第一行给出:

non-existing path in '': '_greengard.pyfnufft1df90.f'

但是设置过程一直在进行,Fortran扩展似乎已经编译好了(显示的行看起来像我手动运行f2py得到的行)。

我试图从网上的例子中找到一个解决方案,但大多数都有点太简单了,没有帮助。有Python打包经验的人能在这方面帮我吗?

在尝试了更多之后,我意识到我没有正确地清理在调用安装脚本时创建的中间"Build"目录。后者一定保留了我之前一次不成功的尝试,其中共享扩展的路径设置错误。

我用一个空白的例子重试,并成功地安装到我的virtualenv的站点包中。

相关内容

最新更新