Numpy区h

2024-06-16 07:51:02 发布

您现在位置:Python中文网/ 问答频道 /正文

我花了将近一个小时在谷歌上搜索解决方案,但是numpy.distutils公司非常稀少。在

我有一个f2py包装的模块。它基本上由3个文件组成:

a.f90
a.pyf
lib.a <- this is a static library that contains most of the computational code

使用下面的shell脚本命令可以很好地编译该模块。在

^{pr2}$

因此,我有python模块a.so(名称在.pyf文件中指定)。在

我该怎么做numpy.distutils公司(或其他面向python的构建工具)? 一个不太重要的问题是,我是否也可以包含lib.A的依赖关系(并在必要时重新构建它?)在


Tags: 模块文件numpyisliblibrary公司static
1条回答
网友
1楼 · 发布于 2024-06-16 07:51:02

所以,不是1小时的谷歌搜索,而是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())

相关问题 更多 >