ModuleNotFoundError: No module named 'tools'

I am trying to compile pytorch from source for static setting. I am getting this error

Error while finding module specification for ‘tools.codegen.gen’ (ModuleNotFoundError: No module named ‘tools’)

CMake Error at cmake/Codegen.cmake:202 (message):
Failed to get generated_cpp list
Call Stack (most recent call first):
caffe2/CMakeLists.txt:2 (include)

tools/codegen/ was added quite recently, so could it be that you have updated some files but not the complete repository?
Could you clean the build via python clean, update it, and rebuild?