Skip to content

scikit-build/f2py-cmake

Repository files navigation

f2py-cmake

Actions Status

PyPI version PyPI platforms

This provides helpers for using F2Py. Use:

include(UseF2Py)

You must have found a Python interpreter beforehand. This will define a F2Py::F2Py target (along with a matching F2PY_EXECUTABLE variable). It will also provide the following helper functions:

f2py_object_library(<name> <type>)

f2py_generate_module(<module> <files>...
                  [F2PY_ARGS <args> ...]
                  [F77 | F90]
                  [NOLOWER]
                  [OUTPUT_DIR <OutputDir>]
                  [OUTPUT_VARIABLE <OutputVariable>]
                  )

Example

find_package(
  Python
  COMPONENTS Interpreter Development.Module NumPy
  REQUIRED)

include(UseF2Py)

# Create the F2Py `numpyobject` library.
f2py_object_library(f2py_object OBJECT)

f2py_generate_module(fibby fib1.f OUTPUT_VARIABLE fibby_files)

python_add_library(fibby MODULE "${fibby_files}" WITH_SOABI)
target_link_library(fibby PRIVATE f2py_object)

scikit-build-core

To use this package with scikit-build-core, you need to include it in your build requirements:

[build-system]
requires = ["scikit-build-core", "numpy", "f2py-cmake"]
build-backend = "scikit_build_core.build"