跳转到主要内容

Python Fortran导入钩子

项目描述

Python导入Fortran模块的钩子。

用法

import fimport
fimport.install(reload_support=True)

import somefortrancode # <- builds and imports somefortrancode.f90

但为什么要在世界上需要这个?一个原因是交互式使用,其中能够重新加载模块通常非常方便。

此代码基于Cython的pyximport模块。

构建自定义

可以通过一个 <modulename>.fbld 文件定义自定义 numpy.distutils.core.Extension 实例和 setup() 参数(分发),例如

import os
from numpy.distutils.core import Extension

def make_ext(modname, ffilename):
    cwd = os.path.dirname(__file__)
    return Extension(name=modname,
                     sources=[ffilename, 'other_file.f90'],
                     f2py_options=['only:', 'some_subroutine', ':'],
                     libraries=['lapack', 'blas'],
                     library_dirs=[cwd],
                     include_dirs=['/myinclude', cwd])

def make_setup_args():
    return dict(script_args=["--fcompiler=gnu"])

可以在 <modulename>.fdep 中列出额外的依赖项

other_file.f90
some_include.inc
examplemodule.fbld

项目详情


下载文件

下载适用于您平台的文件。如果您不确定选择哪个,请了解有关 安装包 的更多信息。

源分发

fimport-0.2.tar.gz (11.2 kB 查看哈希)

上传时间:

由以下支持

AWSAWS云计算和安全赞助商DatadogDatadog监控FastlyFastlyCDNGoogleGoogle下载分析MicrosoftMicrosoftPSF赞助商PingdomPingdom监控SentrySentry错误日志StatusPageStatusPage状态页面