Hi,
It looks like most of the code for making the rotamer library is in the RotData class and the MakeRotLib collection of functions.
src/protocols/make_rot_lib/RotData.hh
src/protocols/make_rot_lib/MakeRotLib.hh
I am, however, having trouble importing them into PyRosetta.
If you download Rosetta C++, and take a look at the file, rosetta_source/src/apps/public/make_rot_lib.cc you could theoretically reproduce most of this in Python if you could get the imports to work.
For simplicity, though, I would just use compile Rosetta C++ and use the full compiled executable, make_rot_lib.