为了在 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,但是在使用时f2py3,make会生成版本号fortran_lib.cpython-35m-x86_64-linux-gnu.so(在我的特定设置中)。
由于这与指定的目标名称不同,make因此无法识别目标已经创建。因此,每次运行时它都会重新制作目标make。
我如何解决这个问题(无需对版本进行硬编码)?
distutils,...)?