fypp
Python powered Fortran preprocessor
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 fyppuv
uv add fypppoetry
poetry add fyppInstalling 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
Tags
More Code Generators packages
Proto Plus wraps protocol buffers to provide…
permissive · top 1,000 on PyPI
CythonCython is a source code translator that…
permissive · top 1,000 on PyPI
asttokensAnnotates Python abstract syntax trees with the…
permissive · top 1,000 on PyPI
beartypeBeartype is a runtime type checker that…
permissive · top 1,000 on PyPI
llvmlitellvmlite provides a lightweight Python binding…
permissive · top 1,000 on PyPI
astorastor converts Python abstract syntax trees…
permissive · top 5,000 on PyPI
pcppA pure Python implementation of a C99…
permissive · top 15,000 on PyPI
fparserfparser parses Fortran source code (Fortran 77…
permissive · top 15,000 on PyPI
fckitlibProvides Fortran modules and a unit testing…
unclear · top 15,000 on PyPI
f90nmlf90nml reads, writes, and modifies Fortran…
permissive · top 15,000 on PyPI
intel-openmpProvides Intel's OpenMP runtime library for…
unclear · top 5,000 on PyPI
lesscpyCompiles LESS stylesheets to CSS using Python,…
permissive · top 15,000 on PyPI
tree-sitter-fortranProvides a Fortran language grammar for…
permissive · top 5,000 on PyPI
astevalAsteval is a safe Python expression and…
permissive · top 5,000 on PyPI
powerfxProvides a Python bridge to invoke C# Power Fx…
permissive · top 15,000 on PyPI