The py_compile module provides a single function to generate a byte-code file from a source file.
Though not often needed, this function can be useful when installing modules for shared use, especially if some of the users may not have permission to write the byte-code cache files in the directory containing the source code.
See Also:
Module compileall (Utilities to compile all Python source files in a directory tree.)