小编leo*_*irz的帖子

python3中f2py的Makefile

为了在 python2 中使用 f2py 构建扩展模块,我一直在使用类似于以下内容的 Makefile:

default: fortran_lib.so

%.so::  %.f90
    f2py -c -m $* $<
Run Code Online (Sandbox Code Playgroud)

为了完整起见,这里还有一个虚拟fortran_lib.f90文件

subroutine square(d)
implicit none
!f2py intent(inout) d
integer, intent(inout)  ::  d

d = d*d
end subroutine square
Run Code Online (Sandbox Code Playgroud)

这曾经工作正常,make只会产生fortran_lib.so.

现在我也想支持 python3,但是在使用时f2py3make会生成版本号fortran_lib.cpython-35m-x86_64-linux-gnu.so(在我的特定设置中)。

由于这与指定的目标名称不同,make因此无法识别目标已经创建。因此,每次运行时它都会重新制作目标make

我如何解决这个问题(无需对版本进行硬编码)?

  • 我可以告诉 f2py3 关闭版本控制吗?
  • 我可以以某种方式解决 Makefile 中的版本控制吗?
  • 还是我被迫切换到其他工具来构建扩展模块(distutils,...)?

makefile cpython f2py python-3.x

1
推荐指数
1
解决办法
1208
查看次数

标签 统计

cpython ×1

f2py ×1

makefile ×1

python-3.x ×1