在 *NIX 平台上构建源代码的一种常见方法是使用configure
脚本。在后台,configure 尝试构建一堆测试程序来确定您可以访问哪些库。然后它生成一个包含在项目中的头文件,该文件有条件地定义了一堆宏,以便程序员可以在缺少特定“依赖项”时提供替代方案或构建库/程序的精简版本。是否有任何功能等效的使用numpy.distutils
?
例如,这是我的setup.py
:
from numpy.distutils.misc_util import Configuration
def configuration(parent_package='',top_path=None):
config = Configuration('pyggcm',parent_package,top_path)
#TODO: Currently, I have some macros to conditionally build the seek-code
#Unfortunately, that's not the best solution (by far). Perhaps if we
#changed to using stream access it would work better, without the need
#for these silly macros.
config.add_extension('_fortfile',sources=['_fortfile/_fortfile.F90'],
define_macros=[
('FSEEKABLE',1), #compiler provides fseek and ftell
('HAVE_STREAM',1) #compiler provides access='stream' for opening files. (f2003 standard)
])
config.add_extension('jrrle',sources=['jrrle/jrrle.f90'])
config.add_scripts(['scripts/ggcm_timehist',
'scripts/ggcm_plasmasheet',
'scripts/ggcm_plot'])
return config
from numpy.distutils.core import setup
setup(configuration=configuration)
这是无条件地构建FSEEKABLE
代码,如果用户 Fortran 编译器不支持,则需要手动编辑(宏包装fseek
和ftell
GNU 内在函数)。有没有办法确定 Fortran 编译器是否提供这些内在函数?