Skip to content

Build fprime_py for the Python deployment only, install Python files on every build, and add a CMake hook and component cookiecutter - #17

Merged
LeStarch merged 7 commits into
fprime-community:mainfrom
lestarch-autobot:devin/1794267899-review-4958-fixes
Nov 10, 2026
Merged

LeStarch merged 7 commits into
fprime-community:mainfrom
lestarch-autobot:devin/1794267899-review-4958-fixes

Conversation

@lestarch-autobot

Copy link
Copy Markdown
Contributor

Change Description

Fixes to the tool found while reviewing the how-to Develop Components in Python (nasa/fprime#4958).

  • C++ deployments beside a Python deployment. fprime_py was built for whichever deployment CMake registered first. A C++-only deployment registered first claimed it, the Python deployment was skipped, and import fprime_py failed with undefined symbol: setup_user_deployment. fprime_py is now built only for a deployment whose topology is @ fprime-python; other deployments are left alone in any order. A second Python deployment is skipped with a warning instead of silently.
  • Stale Python files. The install was a post-link step of fprime_py, so editing only a .py file never reinstalled it. It is now its own target, run by every build of the project or of the deployment.
  • pybind11::embed. The Python deployment's executable is linked against it by the tool, so projects no longer add that themselves.
  • cmake/FprimePython.cmake. include(FprimePython) replaces the pybind11 / position-independent-code / register_fprime_target block each project copied.
  • cookiecutters/component. A component template in this repository: fprime-util new --from-source <fprime-python>/cookiecutters/component.
  • README. fprime_python. corrected to fprime_py.; the two TODO sections (custom bindings, deployments) written.

Rationale

Each item is a point where a reader following the how-to on a new project was blocked or misled.

Testing/Review Recommendations

  • python -m mypy: clean. python -m pytest tests: 28 passed. New tests/test_cmake.py drives the real target functions and the hook from a stand-in CMake project; tests/test_generator.py renders the cookiecutter through the autocoder for each component kind.
  • fprime-python-reference built against this branch: GDS integration tests pass (4).
  • A new project built by following the how-to, with one C++ and one Python deployment: GDS tests pass; HELLO returns its event.
  • Tested on Linux x86_64 only.

Future Work

  • One Python deployment per build: all would share fprime_py and build-artifacts/python.
  • The deployment executable of a Python deployment is still built although nothing runs it; that is the only reason for pybind11::embed.
  • An exception escaping a Python handler ends the flight software.

AI Usage

Generative AI was used in this contribution: AI. Code, tests, and documentation were written by Devin (AI agent) at the direction of @LeStarch, and reviewed locally before submission.

IAMAI

lestarch-autobot and others added 7 commits November 10, 2026 00:00
…etup friction

- Install Python files on every build: the install ran after fprime_py linked, so an edit to a .py file alone was never installed.
- Build fprime_py only for a deployment whose topology is annotated: a C++ deployment registered first claimed the module and the Python deployment was skipped, leaving an fprime_py that failed to import. A second Python deployment is now skipped with a warning.
- Add cmake/FprimePython.cmake, one include replacing the pybind11 and target registration block each project copied.
- Add the component cookiecutter, previously in a personal repository.
- README: module is fprime_py, document custom bindings, running, and CMake setup.

Co-authored-by: M Starch <LeStarch@googlemail.com>
Co-authored-by: M Starch <LeStarch@googlemail.com>
… build target

- The executable of a Python deployment links modules that call into Python, so it failed to link unless each project added pybind11::embed itself.
- Add tests of target/fprime_python.cmake against a stand-in project: deployment order, C++-only builds, a second Python deployment, Python reinstall without relinking, and template copy-back.

Co-authored-by: M Starch <LeStarch@googlemail.com>
Covers target registration, the missing-pybind11 error, and the sub-build early return.

Co-authored-by: M Starch <LeStarch@googlemail.com>
Co-authored-by: M Starch <LeStarch@googlemail.com>
fprime-util build from the deployment directory builds the deployment target, which did not depend on fprime_py or its install, leaving build-artifacts/python stale.

Co-authored-by: M Starch <LeStarch@googlemail.com>
Co-authored-by: M Starch <LeStarch@googlemail.com>
@LeStarch
LeStarch merged commit 0a8a0c3 into fprime-community:main Nov 10, 2026
2 checks passed
lestarch-autobot added a commit to lestarch-autobot/fprime-python-reference that referenced this pull request Nov 10, 2026
fprime-community/fprime-python#17 was squash-merged; the tree is identical to the commit pinned before.

Co-authored-by: M Starch <LeStarch@googlemail.com>
LeStarch added a commit to fprime-community/fprime-python-reference that referenced this pull request Nov 10, 2026
* Drop the FPP JSON model, adopt the FprimePython CMake hook, and document running

- Remove FPRIME_ENABLE_JSON_MODEL_GENERATION and fprime-python-model: fprime-python reads FPP directly.
- Replace the pybind11 and target registration block with include(FprimePython); the build now links the deployment to pybind11::embed.
- README: start the GDS and the Python flight software separately; the deployment README no longer describes a C++ binary.
- Update lib/fprime-python.

Co-authored-by: M Starch <LeStarch@googlemail.com>

* Bump fprime-python to the tested hook

Co-authored-by: M Starch <LeStarch@googlemail.com>

* Bump fprime-python: install on deployment builds

Co-authored-by: M Starch <LeStarch@googlemail.com>

* Bump fprime-python to merged main (0a8a0c3)

fprime-community/fprime-python#17 was squash-merged; the tree is identical to the commit pinned before.

Co-authored-by: M Starch <LeStarch@googlemail.com>

---------

Co-authored-by: M Starch <LeStarch@googlemail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants