我花了将近一个小时在谷歌上搜索解决方案,但numpy.distutils的文档非常稀少。
我有一个f2py包装的模块。它基本上由3个文件组成:
a.f90
a.pyf
lib.a <- this is a static library that contains most of the computational code使用以下shell-script命令可以很好地编译该模块。
f2py --build-dir temp -c a.pyf a.f90 lib.a --fcompiler=gnu95
--fcompiler-flags="Zillions of compiler options"因此,我得到了python模块a.so (名称在.pyf文件中指定)。
我如何使用numpy.distutils (或其他一些面向python的构建工具)做到这一点?一个不太重要的问题是,我是否也可以包含lib.a中的依赖项(并在必要时重新构建它?)
发布于 2012-08-28 03:22:31
所以,这不是一个小时的谷歌,它花了2天的谷歌,但最终我找到了这样做的方法。希望,这会对某些人有所帮助。
def configuration(parent_package='',top_path=None):
from numpy.distutils.misc_util import Configuration, get_info
config = Configuration('a', parent_package, top_path)
lib = ['./libdir/lib.a']
src = ['a.f90','a.pyf']
inc_dir = ['libdir']
config.add_extension('mya',sources=src,depends=lib_tt,
include_dirs=inc_dir,extra_objects="lib.a")
#The main trick was to use extra_objects keyword
return config
if __name__ == '__main__':
from numpy.distutils.core import setup
setup(**configuration(top_path='').todict())https://stackoverflow.com/questions/12115990
复制相似问题