nanopb compilation doesn't work

I am using zephyr_nanopb_sources to add some protobuf files to my app target, and this works fine in a normal build without mcuboot. However, when building with mcuboot it doesn't work. Here is the error I get:

Failed to import nanopb_pb2.py: type object 'FileOptions' has no attribute 'RegisterExtension'
Will automatically attempt to rebuild this.
Verify that python-protobuf and protoc versions match.
Using grpcio-tools protoc from /opt/nordic/ncs/toolchains/15b490767d/lib/python3.12/site-packages/grpc_tools/protoc.py
protoc builtin include path: ['/Users/nick/Documents/Repos/AirTurnWearable/application/build_rel_nrf52dk/application/src/proto/nanopb/generator/proto', '/opt/nordic/ncs/toolchains/15b490767d/lib/python3.12/site-packages/grpc_tools/_proto']
Python version 3.12.4 (main, Jun  7 2024, 04:28:19) [Clang 14.0.0 (clang-1400.0.29.202)]
Using python-protobuf from /opt/nordic/ncs/toolchains/15b490767d/lib/python3.12/site-packages/google/protobuf/__init__.py
Python-protobuf version: 5.27.1

This appears to be related to this issue: https://github.com/zephyrproject-rtos/zephyr/issues/72265

What's strange is that running the command that fails from a nRF toolchain terminal succeeds. So it appears something about the mcuboot build environment is causing the failure.

I'm using toolchain and SDK 2.8.0

Related