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)