Kicad build error netlist

Wow, couldn’t think that the source code tree was being ‘modified’ during the build. Indeed cloning again from git helped. The build now ‘almost’ completed, it only failed at 99%:

[100%] Building CXX object pcbnew/CMakeFiles/pcbnew_kiface_objects.dir/specctra_import_export/specctra_keywords.cpp.o
/opt/kicad/pcbnew/python/scripting/pcb_scripting_tool.cpp: In member function ‘virtual bool SCRIPTING_TOOL::Init()’:
/opt/kicad/pcbnew/python/scripting/pcb_scripting_tool.cpp:60:34: error: ‘PyImport_GetModule’ was not declared in this scope
     if( PyObject* existing_mod = PyImport_GetModule( mod_name ) )
                                  ^~~~~~~~~~~~~~~~~~
/opt/kicad/pcbnew/python/scripting/pcb_scripting_tool.cpp:60:34: note: suggested alternative: ‘PyImport_AddModule’
     if( PyObject* existing_mod = PyImport_GetModule( mod_name ) )
                                  ^~~~~~~~~~~~~~~~~~
                                  PyImport_AddModule
pcbnew/CMakeFiles/pcbnew_kiface_objects.dir/build.make:4069: recipe for target 'pcbnew/CMakeFiles/pcbnew_kiface_objects.dir/python/scripting/pcb_scripting_tool.cpp.o' failed
make[2]: *** [pcbnew/CMakeFiles/pcbnew_kiface_objects.dir/python/scripting/pcb_scripting_tool.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
CMakeFiles/Makefile2:2304: recipe for target 'pcbnew/CMakeFiles/pcbnew_kiface_objects.dir/all' failed
make[1]: *** [pcbnew/CMakeFiles/pcbnew_kiface_objects.dir/all] Error 2
Makefile:165: recipe for target 'all' failed
make: *** [all] Error 2
12:36:03: The process "/snap/bin/cmake" exited with code 2.
Error while building/deploying project kicad (kit: Desktop)
When executing step "Build"

It looks like this function is only available in Python 3.7, not in 3.6. I reported it here https://gitlab.com/kicad/code/kicad/-/issues/8554

If I comment out a couple of lines in that cpp file, the build finally succeeds. Thanks for all the help!