Compiling .py files to .pyo without resorting to a wrapper script
===

i am looking into compiling quite a big set of python modules and packages to pyo. I know this is possible by either setting the PYTHONOPTIMIZE environment variable or by specifying -O on launch. I'd like to enforce pyo instead of pyc to yield the smallest footprint possible. In order to do that in my deploy module i have to create a wrapper script that launches the actual script with the -O option, because the environment variable needs to be specified prior to starting the interpreter.

Is there any way around this and enforce pyo creation programmatically?

Kind regards,
Thorsten