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 # fpp.ast.DefModule
[type(m).__name__ for m in module.members] # ['DefArray', 'DefConstant']
arr = model.lookup("M.Arr") # Symbol.ArrayType
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']
The syntax tree lives in the fpp.ast submodule — one class per grammar
production, plus the AstNode base and the enums the grammar spells
(fpp.ast.IntegerKind, fpp.ast.ComponentKind). fpp itself is the analysis:
Model, Analysis, the symbol/type/value unions, and the semantic entities. The
split is what lets both keep the compiler's own names, since three of them belong
to each — fpp.Connection is the analyzed connection, fpp.ast.Connection the
syntax it came from.
from fpp.ast import DefArray
isinstance(module.members[0], DefArray) # True
type(module.members[0]).__module__ # 'fpp.ast'
Subclass fpp.AstVisitor — it takes AST nodes, but it is an entry point, so it
stays in fpp beside analyze — and override visit_<type(node).__name__>.
Traversal is deep by default: super() descends, omitting it prunes.
class Constants(fpp.AstVisitor):
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.
match arr.definition.resolved_type:
case fpp.Type.Array() as a:
elt = a.anon_array.elt_type
isinstance(elt, fpp.Type.PrimitiveInt) and elt.value == fpp.ast.IntegerKind.U32
Annotate with <Base>.Variant — fpp.Type.Variant, fpp.Value.Variant — rather
than the base class. It is the closed union over the variants, so a type checker can tell you which case you forgot.
def describe(v: fpp.Value.Variant) -> str:
match v:
case fpp.Value.Integer():
return f"integer {v.value}"
case fpp.Value.String():
return f"string {v.value}"
...
case _:
typing.assert_never(v) # fails while any variant is unhandled
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
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 the two stubs 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 stubs
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.
Metadata
Release files for fprime-fpp-python 3.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fprime_fpp_python-3.4.0.tar.gz | 487.1 kB | With provenance | Details for fprime_fpp_python-3.4.0.tar.gz |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fprime_fpp_python-3.4.0-cp310-abi3-win_amd64.whl | CPython 3.10 | abi3 | Windows x86-64 | Details for fprime_fpp_python-3.4.0-cp310-abi3-win_amd64.whl |
| fprime_fpp_python-3.4.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ x86-64 | Details for fprime_fpp_python-3.4.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
| fprime_fpp_python-3.4.0-cp310-abi3-macosx_11_0_arm64.whl | CPython 3.10 | abi3 | macOS 11.0+ ARM64 | Details for fprime_fpp_python-3.4.0-cp310-abi3-macosx_11_0_arm64.whl |
Total release size: 7.4 MB
Release files / fprime_fpp_python-3.4.0.tar.gz
| Download URL | fprime_fpp_python-3.4.0.tar.gz |
|---|---|
| Size | 487.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
65e9ed7585e88aff2a64c281264372592a2bcd6150cd55b2292c078fd59c1061
|
|
BLAKE2b-256 checksum How to use checksums |
458dd1e222c81dac3a1e0bf28d3d8af10d9930d5d37c8d88f3bb48a64685025b
|
| 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 Oct 1, 2026.
Transparency logRelease files / fprime_fpp_python-3.4.0-cp310-abi3-win_amd64.whl
| Download URL | fprime_fpp_python-3.4.0-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 2.3 MB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
0d527df46065e65f9dcf1c89acc1eb56b3f570d4fbedda1b5209d13a93677247
|
|
BLAKE2b-256 checksum How to use checksums |
fa21d125c43c44162a40b5048db13c7f708e53013d0b032dda2c87d31a426aa5
|
| 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 Oct 1, 2026.
Transparency logRelease files / fprime_fpp_python-3.4.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | fprime_fpp_python-3.4.0-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 |
033d84717346241531a23761be68354938814c7459f471991052f32cb78be3da
|
|
BLAKE2b-256 checksum How to use checksums |
c126211dd5085633464fa6abbda102d1d0234cae453ec47e143aa468fec06110
|
| 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 Oct 1, 2026.
Transparency logRelease files / fprime_fpp_python-3.4.0-cp310-abi3-macosx_11_0_arm64.whl
| Download URL | fprime_fpp_python-3.4.0-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 |
5d65ccd7ad602ce61323e45898f0199be6247e67d3ad55d7b5fe1da857ecc9da
|
|
BLAKE2b-256 checksum How to use checksums |
0b931bef97793d68bd9e52347a0c1064e0c2e8685d90e4943f8819485b77d373
|
| 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 Oct 1, 2026.
Transparency logSecurity for fprime-fpp-python 3.4.0
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.
Full provenance
All 4 files in this release have been uploaded with provenance metadata.
Attestation for fprime_fpp_python-3.4.0.tar.gz
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 Oct 1, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.