+关注
已关注

分类  

暂无分类

标签  

暂无标签

日期归档  

暂无数据

关于如何将scikit-build与f2py一起使用,是否有任何可行的示例?

发布于2021-03-02 15:20     阅读(811)     评论(0)     点赞(16)     收藏(5)


0

1

2

3

4

5

scikit-build发行版提供了FindF2PY和UseF2PY的用法示例,但它们并不完整,仅提供了部分CMakeLists.txt文件,而没有其他必需的文件。根据文档,我无法进行构建。

按照scikit-build文档中的示例,我创建了以下文件:

CMakeLists.txt:

cmake_minimum_required(VERSION 3.10.2)

project(skbuild_test)

enable_language(Fortran)

find_package(F2PY REQUIRED)

add_f2py_target(f2py_test f2py_test.f90)
add_library(f2py_test MODULE f2py_test.f90)
install(TARGETS f2py_test LIBRARY DESTINATION f2py_test)

setup.py:

import setuptools
from skbuild import setup

requires=['numpy']

setup(
    name="skbuild-test",
    version='0.0.1',
    description='Performs line integrals through SAMI3 grids',
    author='John Haiducek',
    requires=requires,
    packages=['f2py_test']
)

f2py_test.f90:

module mod_f2py_test
  implicit none
contains
  subroutine f2py_test(a,b,c)
    real(kind=8), intent(in)::a,b
    real(kind=8), intent(out)::c
  end subroutine f2py_test
end module mod_f2py_test

另外,我创建了一个目录f2py_test,其中包含一个空的init .py。

的输出python setup.py develop显示scikit-build调用CMake并编译我的Fortran代码。但是,在编译f2py包装器代码时找不到Python.h:

[2/7] Building C object CMakeFiles/_f2...kages/numpy/f2py/src/fortranobject.c.o
FAILED: CMakeFiles/_f2py_runtime_library.dir/venv/lib/python3.8/site-packages/numpy/f2py/src/fortranobject.c.o 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc   -O3 -DNDEBUG -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -mmacosx-version-min=10.14 -MD -MT CMakeFiles/_f2py_runtime_library.dir/venv/lib/python3.8/site-packages/numpy/f2py/src/fortranobject.c.o -MF CMakeFiles/_f2py_runtime_library.dir/venv/lib/python3.8/site-packages/numpy/f2py/src/fortranobject.c.o.d -o CMakeFiles/_f2py_runtime_library.dir/venv/lib/python3.8/site-packages/numpy/f2py/src/fortranobject.c.o   -c ../../../venv/lib/python3.8/site-packages/numpy/f2py/src/fortranobject.c
In file included from ../../../venv/lib/python3.8/site-packages/numpy/f2py/src/fortranobject.c:2:
../../../venv/lib/python3.8/site-packages/numpy/f2py/src/fortranobject.h:7:10: fatal error: 'Python.h' file not found
#include "Python.h"
         ^~~~~~~~~~
1 error generated.

解决方案


暂无回答

0

1

2

3

4

5

6

7



所属网站分类: 技术文章 > 问答

作者:黑洞官方问答小能手

链接: https://www.pythonheidong.com/blog/article/869845/4b6947d6bb97c6c19d2a/

来源: python黑洞网

任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任

16 0
收藏该文
已收藏

评论内容:(最多支持255个字符)