ModuleNotFoundError: No module named 'tools'

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

Blockquote
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/gen.py 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 setup.py clean, update it, and rebuild?