I have an application written in python 2.7. In my application, I want to give users the ability to compile the python source file (from pyto pyc).
An inline function compiledoes this, but the output file is only compatible with python 2.7.
I want to compile a file into a number of different versions of python (specifically python 2.5, 2.6and 2.7)
I know that one way to solve this problem is to overwrite my application in each of these versions and just use the built-in function compile, but I do not want to do this.
I am open to all suggestions, including writing a C extension, implementing python, etc.
EDIT
The application that I am writing is a tool that allows you to insert / modify arbitrary code inside exinstaller pyinstaller.
Now you can know that pyinstaller actually puts the compiled python source files in exe. My application simply extracts these embedded pyc files, decompiles them, allows the user to modify them, and then restore the exe.
Since exe may be from a different version of python, so I need functionality to compile decompiled output to this version.
Here is a screenshot of this application.

source
share