skillfed

fypp

Python powered Fortran preprocessor

fypp v3.2 97.2K downloads/30d#13,165 on PyPI218
Permissive license BSD Active released

What it is and what it does

Fypp is a command-line preprocessor and Python module that extends Fortran with metaprogramming capabilities by interpreting Python expressions embedded in preprocessor directives. It reads Fortran source files annotated with special directives (like #:if, #:for, #:def), evaluates Python logic to conditionally include code or generate templates, and outputs the processed Fortran. The tool integrates into build toolchains as a preprocessing step before compilation.

Instead of inventing its own expression syntax, Fypp leverages Python's full expression language for metaprogramming tasks—defining variables, writing macros, iterating over types to generate overloaded procedures, and inserting dynamic content like timestamps. It handles multiline strings, file inclusion, line numbering directives for debugging, and automatic line folding, making it suitable for large Fortran projects that need code reuse and conditional compilation without leaving the Fortran ecosystem.

Use it for:

  • Generate type-specific Fortran procedure overloads (e.g., real, complex variants) from a single template definition.
  • Conditionally include MPI, OpenMP, or serial code paths based on preprocessor variables set at build time.
  • Insert build metadata (timestamps, version strings) or debug assertions into Fortran source during preprocessing.
  • Define reusable Fortran macros for common patterns (error checking, array bounds validation) to reduce code duplication.
  • Automate boilerplate Fortran code generation for numerical libraries with multiple precision or dimension variants.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Fypp is a Python-powered preprocessor for Fortran that adds conditional compilation, template metaprogramming, and macro support to Fortran source files using Python expressions in preprocessor directives.

Yes. Fypp is actively maintained, has no runtime dependencies, installs easily, carries a permissive BSD license, and solves a real problem for Fortran developers needing template metaprogramming and conditional compilation. It is production-stable and suitable for integration into scientific computing and numerical library build pipelines.

Install

fypp on PyPI

pip

pip install fypp

uv

uv add fypp

poetry

poetry add fypp

Installing fypp

Before you install

Low install friction with no runtime dependencies. Actively maintained as of 2026-03-03 with stable production status.

License in practice

BSD permissive license allows commercial and private use with minimal restrictions; suitable for most projects.

Quickstart

pip install fypp

fypp source.fpp source.f90

# Or import the module in Python:
from fypp import fypp
fypp.main()

Requires Python 3.5 or above; designed for Fortran development workflows.

Verify before relying

  • Whether the package works with Python versions beyond 3.9 (classifiers list up to 3.9 only).
  • Current test coverage and CI/CD status to assess stability beyond the active maintenance signal.

Package facts

License BSD (permissive)
Python support not specified
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance actively maintained — 1,088 days since the last release
Last repo commit
First released
Downloads 97,160/month — #13,165 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: fypp-3.2-py3-none-any.whl

Keywords: fortran, metaprogramming, pre-processor

Development Status :: 5 - Production/StableIntended Audience :: DevelopersIntended Audience :: Science/ResearchLicense :: OSI Approved :: BSD LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development :: Code GeneratorsTopic :: Software Development :: Pre-processors

Tags

fortran preprocessorfortran metaprogrammingfortran template generationconditional fortran compilationfortran macro systemcode generation fortranfypp preprocessor
fortrancode-generationbuild-tool

More Code Generators packages