Make compile_str able to compile a lib that is not a Python module

This is useful to compile support code shared by different ops.