Is Python a must for building Libtorch from source?

I manage to build pytorch(libtorch) from source on my Raspian (armv7l).
After finding CMakeLists.txt, I just use cmake to build it. (I knew the official instructions of building it, I just want to have another try)

However, I find that if directly use cmake to get the configure. I have the following error (I only build libtorch):

Failed to get generated_cpp list. 

I checked the cmake file, and I found the reason. in cmake/codegen.cmake:166-182 . The code generation process indeed needs python.

And I found that using python3 tools/ to get a libtorch build. Then rebuild libtorch or pytorch in another directory, cmake+make actually works. (because of the cached generated_cpp.txt ?)

So I want to ask that… Are there some other methods (except for the method mentioned above) to get generated_cpp.txt? Or, are there any other methods to build libtorch? (For example, a device with no python installed at all, but cmake and make are installed)

yours sincerely,


I never asked that question but given that all of the codegen we do is implemented in python, I would say that python is required to build libtorch yes (even though it is not required to use it!).