Libevents generation error in Python script

I’m trying to build QGC and I get this error:

[0/1] Re-running CMake...
-- Build Type: Debug
-- Qt version: 5.12.6
-- Qt spec: gcc_64
-- Submodule update
-- QGroundControl version: refs/pull/9561/merge-47-g4b2998d56
-- Checking for modules 'gstreamer-1.0>=1.14;gstreamer-video-1.0>=1.14;gstreamer-gl-1.0>=1.14;egl'
--   No package 'gstreamer-1.0' found
--   No package 'gstreamer-video-1.0' found
--   No package 'gstreamer-gl-1.0' found
-- CMake version = 3.16.3
-- CMAKE_SYSTEM_NAME = Linux
CMake Deprecation Warning at libs/shapelib/CMakeLists.txt:34 (cmake_policy):
  The OLD behavior for policy CMP0026 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.


-- Not enabling format target (clang-format not found)
-- Configuring done
-- Generating done
-- Build files have been written to: /home/phma/build/qgroundcontrol/cdbg
[9/94] Generating test event header file
FAILED: libs/libevents/libevents/libs/cpp/tests/events_generated.h 
cd /home/phma/src/qgroundcontrol/libs/libevents/libevents/libs/cpp/tests && /home/phma/src/qgroundcontrol/libs/libevents/libevents/libs/cpp/../../scripts/generate.py --language cpp --output /home/phma/build/qgroundcontrol/cdbg/libs/libevents/libevents/libs/cpp/tests /home/phma/src/qgroundcontrol/libs/libevents/libevents/libs/cpp/../../libs/test.json
  File "/home/phma/src/qgroundcontrol/libs/libevents/libevents/libs/cpp/../../scripts/generate.py", line 112
    def jinja_cpp_namespace(arg_type: str):
                                    ^
SyntaxError: invalid syntax
[22/70] Building CXX object libs/libevents/...vents_parser_autogen/mocs_compilation.cpp.o
ninja: build stopped: subcommand failed.

I’m on Ubuntu Focal. Python version is 2.7.18. Does the script need Python 3; if so, how do I tell it to use it?

How did you solve ths?