Skip to main content

CMake helpers for building F2Py modules

Project description

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"

Vendoring

You can vendor UseF2Py into your package, as well. This avoids requiring a dependency at build time and protects you against changes in this package, at the expense of requiring manual re-vendoring to get bugfixes and/or improvements. This mechanism is also ideal if you want to support direct builds, outside of scikit-build-core.

You should make a CMake helper directory, such as cmake. Add this to your CMakeLists.txt like this:

list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")

Then, you can vendor our file into that folder:

pipx run f2py-cmake vendor cmake

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

f2py_cmake-0.1.0.tar.gz (17.3 kB view details)

Uploaded Source

Built Distribution

f2py_cmake-0.1.0-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

Details for the file f2py_cmake-0.1.0.tar.gz.

File metadata

  • Download URL: f2py_cmake-0.1.0.tar.gz
  • Upload date:
  • Size: 17.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for f2py_cmake-0.1.0.tar.gz
Algorithm Hash digest
SHA256 dd4bbc80b2e975b5c535412ba798e1682e259a40c984b7ce82770998f577c073
MD5 e951fc31edc30a449339febc66b2ee43
BLAKE2b-256 6250d4ff19fe6dee4e5817cab9029d6352a9c2ede3fc75a1c7413874176f491c

See more details on using hashes here.

File details

Details for the file f2py_cmake-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: f2py_cmake-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for f2py_cmake-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4fb5597d1ef6f6f34d3e468e28d239b368181a24fabfa8c53ea2da9d6a59f475
MD5 31f58d8cb983b90204745a5fb997b948
BLAKE2b-256 b01ea49b072702a625fda12bc6e927b7b13fac1e7e5ab12d75bd3f3b172b9636

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page