Skip to main content

fprime-fpp-python

Native Python bindings to the FPP compiler. Installed as fprime-fpp-python, imported as fpp.

The extension binds directly to the Rust FPP compiler via PyO3.

Installation

pip install fprime-fpp-python

An abi3 wheel, usable on CPython ≥ 3.10. Building from source needs Rust ≥ 1.85 and maturin.

Usage

import fpp

model = fpp.analyze(source="""
module M {
  array Arr = [4] U32
  constant answer = 6 * 7
}
""")

model.has_errors                             # False
for d in model.diagnostics:
    d.level                                  # fpp.DiagnosticLevel.Error
    print(d.display)                         # 'path:line:col: error: message'
    print(d)                                 # the compiler's console rendering

(unit,) = model.ast                          # one translation unit per input
(module,) = unit.members
[type(m).__name__ for m in module.members]   # ['DefArray', 'DefConstant']

arr = model.lookup("M.Arr")                                     # SymbolArrayType
arr.definition.resolved_type.array_size                         # 4
model.lookup("M.answer").definition.value.resolved_value.value  # 42

All inputs to one call are analyzed together. A bare string is a path, source= is text, and imports= — the counterpart of fpp-to-cpp -i — is analyzed the same way but is not part of what you asked about:

model = fpp.analyze(["MyComponent.fpp"], imports=["Fw/Fw.fpp"])
[u.uri for u in model.ast if u.is_source]    # ['MyComponent.fpp']

parse is the fast front end: it stops after include resolution, so you get syntax and nothing resolved.

tree = fpp.parse(["A.fpp", "B.fpp"])
[u.uri for u in tree.units]                  # ['A.fpp', 'B.fpp']

Subclass NodeVisitor and override visit_<type(node).__name__>. Traversal is deep by default: super() descends, omitting it prunes.

class Constants(fpp.NodeVisitor):
    def __init__(self):
        self.values = {}

    def visit_DefConstant(self, node):
        self.values[node.name] = node.value.resolved_value.value
        super().visit_DefConstant(node)

consts = Constants()
consts.visit(model)                          # or a SyntaxTree, TransUnit, or node
consts.values                                # {'answer': 42}

Semantic types are closed unions, so narrow them with isinstance or match rather than a string tag.

match arr.definition.resolved_type:
    case fpp.ArrayType() as a:
        elt = a.anon_array.elt_type
        isinstance(elt, fpp.PrimitiveIntType) and elt.value == fpp.IntegerKind.U32

Findings of your own report like compiler errors: build a Diagnostic against any node's span, add child annotations and notes, and print it.

node = model.lookup("M.answer").definition
print(fpp.Diagnostic(
    "answer is unused", level=fpp.DiagnosticLevel.Warning,
    span=node.span,
    children=[fpp.DiagnosticMessage("delete it")],
))
#  --> mem.fpp:4:3
#   |
# 4 |   constant answer = 6 * 7
#   |   ^^^^^^^^^^^^^^^^^^^^^^^ answer is unused
#   |
#   = note: delete it

A check can raise its finding instead of returning it: fpp.DiagnosticError carries a Diagnostic, and everything on that diagnostic stays writable, so each handler on the way out can add the context it knows.

try:
    check_component(instance.component)
except fpp.DiagnosticError as error:
    error.diagnostic.add_note("in this instance", span=instance.node.span)
    raise

fpp.pyi is the reference for the rest — every class, getter and return type — and the docstrings carry the contracts: help(fpp.analyze), help(fpp.Model), help(fpp.NodeVisitor).

Development

A Cargo workspace member of fpp-tools. The node wrappers and the recording walk are expanded by fpp_python_macros from checked-in declarations (src/ast/defs.rs, src/sem/defs.rs); the core (pipeline, ir_core, lower_core, noderef, model, visitor, diagnostics) is hand-written.

Those declarations and fpp.pyi are generated and checked in — change the generator or the macro, never the file, and re-run make. CI fails on drift.

maturin develop            # build + install into the active venv
pytest tests/              # run the tests

make nightly               # one-time: the nightly the bindgen's rustdoc needs
make                       # regenerate the declarations, then the stub
make help                  # the individual codegen targets

The bindgen reflects fpp_analysis from rustdoc JSON, whose schema is unstable, so the nightly is pinned exactly — in fpp_python_bindgen/nightly-toolchain alongside the rustdoc-types pin in its Cargo.toml. Bump the two together. FPP_BINDGEN_TOOLCHAIN overrides the toolchain for a one-off run.

Release files for fprime-fpp-python 3.3.20

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fprime-fpp-python 3.3.20
File Size Uploaded
fprime_fpp_python-3.3.20.tar.gz 469.9 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for fprime-fpp-python 3.3.20
File Interpreter ABI Platform
fprime_fpp_python-3.3.20-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
fprime_fpp_python-3.3.20-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details
fprime_fpp_python-3.3.20-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details

Total release size: 7.3 MB

Release files / fprime_fpp_python-3.3.20.tar.gz

Download URL fprime_fpp_python-3.3.20.tar.gz
Size 469.9 kB
Tags Source
SHA-256 checksum
How to use checksums
ac5074049c1b9be277bd31d2ad0734096b677d71cb1f1a148ffc872a6be3660c
BLAKE2b-256 checksum
How to use checksums
d7397511886d9f7c4364ce1e08db759f021cf7c094f8c889360161b05e0de86a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 12, 2026.

Transparency log

Release files / fprime_fpp_python-3.3.20-cp310-abi3-win_amd64.whl

Download URL fprime_fpp_python-3.3.20-cp310-abi3-win_amd64.whl
Size 2.3 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
57afc7c2a198a6f5fce1986caed924f0a72bab501298e8b9a166bca5854ebbab
BLAKE2b-256 checksum
How to use checksums
52e707788e8c96664588030bf08dfbd1e605f01a43fd256a190c6c71b0a9ce42
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 12, 2026.

Transparency log

Release files / fprime_fpp_python-3.3.20-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL fprime_fpp_python-3.3.20-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 2.4 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
d941d58cc689fd197ed0b9b5acb56c88f7806cc51211364bc4daa301449b4bb4
BLAKE2b-256 checksum
How to use checksums
c0d4f036d299f281847481eb177f88ab8e11ebd42c04f515b0caf89e94b2564c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 12, 2026.

Transparency log

Release files / fprime_fpp_python-3.3.20-cp310-abi3-macosx_11_0_arm64.whl

Download URL fprime_fpp_python-3.3.20-cp310-abi3-macosx_11_0_arm64.whl
Size 2.2 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
55cb3b2b3856d9952151d60e4dc23a4c01c9c9c492a60a26996dedee0d28c9f7
BLAKE2b-256 checksum
How to use checksums
7b0337a3ebcc4d6c1c2432277b34cf29d328a55e062113e7bc286f2505ac36be
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 12, 2026.

Transparency log

Release history Release notifications | RSS feed

3.3.25

4 release files

3.3.24

4 release files

3.3.23

4 release files

3.3.22

4 release files

3.3.21

4 release files

This release

3.3.20 This release

4 release files

3.3.19

4 release files

3.3.18

4 release files

3.3.17

4 release files

3.3.16

4 release files

3.3.15

4 release files

3.3.14

4 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page